-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
Copy pathci.bash
executable file
·95 lines (80 loc) · 2.44 KB
/
ci.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
set -euo pipefail
# Build using a Docker container.
function docker-build() {
local target="${TARGET:-}"
local image="codercom/nbin-${target}"
local token="${GITHUB_TOKEN:-}"
local minify="${MINIFY:-}"
if [[ "${target}" == "linux" ]] ; then
image="codercom/nbin-centos"
fi
local containerId
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker start "${containerId}"
docker exec "${containerId}" mkdir -p /src
case "${image}" in
codercom/nbin-alpine-arm | codercom/nbin-apline-arm64 | codercom/nbin-alpine)
docker exec "${containerId}" apk add libxkbfile-dev libsecret-dev git
;;
codercom/nbin-arm | codercom-nbin-arm64)
docker exec "${containerId}" apt -y install libxkbfile-dev libsecret-dev git
;;
*)
# Assume anything else is CentOS/Fedora/RHEL
docker exec "${containerId}" yum install -y libxkbfile-devel libsecret-devel git
;;
esac
function docker-exec() {
local command="${1}" ; shift
local args="'${vscodeVersion}' '${codeServerVersion}'"
docker exec "${containerId}" \
bash -c "cd /src && CI=true GITHUB_TOKEN=${token} MINIFY=${minify} yarn ${command} ${args}"
}
docker cp ./. "${containerId}":/src
docker-exec build
if [[ -n "${package}" ]] ; then
#FIXME: Packages is not being preloaded in-container.
docker exec "${containerId}" bash -c "cd /src && yarn"
docker-exec binary
docker-exec package
mkdir -p release
docker cp "${containerId}":/src/release/. ./release/
fi
docker stop "${containerId}"
}
# Build locally.
function local-build() {
function local-exec() {
local command="${1}" ; shift
CI=true yarn "${command}" "${vscodeVersion}" "${codeServerVersion}"
}
local-exec build
if [[ -n "${package}" ]] ; then
# FIXME: initialize node_modules as always
yarn
local-exec binary
local-exec package
fi
}
# Build code-server in the CI.
function main() {
cd "$(dirname "${0}")/.."
local codeServerVersion="${VERSION:-}"
local vscodeVersion="${VSCODE_VERSION:-}"
local ostype="${OSTYPE:-}"
local package="${PACKAGE:-}"
if [[ -z "${codeServerVersion}" ]] ; then
>&2 echo "Must set VERSION environment variable"; exit 1
fi
if [[ -z "${vscodeVersion}" ]] ; then
>&2 echo "Must set VSCODE_VERSION environment variable"; exit 1
fi
if [[ "${ostype}" == "darwin"* ]]; then
local-build
else
docker-build
fi
}
main "$@"