2019-07-03 00:10:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2019-07-10 23:10:39 +00:00
|
|
|
# Build using a Docker container.
|
2019-07-03 00:10:17 +00:00
|
|
|
function docker-build() {
|
|
|
|
local containerId
|
|
|
|
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
|
|
|
|
docker start "${containerId}"
|
|
|
|
docker exec "${containerId}" mkdir -p /src
|
|
|
|
|
|
|
|
function docker-exec() {
|
2019-07-10 23:10:39 +00:00
|
|
|
local command="${1}" ; shift
|
|
|
|
local args="'${codeServerVersion}' '${vscodeVersion}' '${target}' '${arch}'"
|
|
|
|
docker exec "${containerId}" \
|
|
|
|
bash -c "cd /src && CI=true yarn ${command} ${args}"
|
2019-07-03 00:10:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
docker cp ./. "${containerId}":/src
|
2019-07-10 23:10:39 +00:00
|
|
|
docker-exec build
|
|
|
|
docker-exec binary
|
|
|
|
docker-exec package
|
2019-07-03 00:10:17 +00:00
|
|
|
docker cp "${containerId}":/src/release/. ./release/
|
|
|
|
|
|
|
|
docker stop "${containerId}"
|
|
|
|
}
|
|
|
|
|
2019-07-10 23:10:39 +00:00
|
|
|
# Build locally.
|
|
|
|
function local-build() {
|
|
|
|
function local-exec() {
|
|
|
|
local command="${1}" ; shift
|
|
|
|
CI=true yarn "${command}" \
|
|
|
|
"${codeServerVersion}" "${vscodeVersion}" "${target}" "${arch}"
|
|
|
|
}
|
|
|
|
|
|
|
|
local-exec build
|
|
|
|
local-exec binary
|
|
|
|
local-exec package
|
|
|
|
}
|
|
|
|
|
2019-07-03 00:10:17 +00:00
|
|
|
# Build code-server in the CI.
|
|
|
|
function main() {
|
2019-07-10 23:10:39 +00:00
|
|
|
local codeServerVersion="${VERSION:-}"
|
2019-07-03 00:10:17 +00:00
|
|
|
local vscodeVersion="${VSCODE_VERSION:-}"
|
|
|
|
local ostype="${OSTYPE:-}"
|
|
|
|
local target="${TARGET:-}"
|
|
|
|
local arch=x64
|
|
|
|
|
2019-07-10 23:10:39 +00:00
|
|
|
if [[ -z "${codeServerVersion}" ]] ; then
|
2019-07-03 00:10:17 +00:00
|
|
|
>&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
|
|
|
|
target=darwin
|
2019-07-10 23:10:39 +00:00
|
|
|
local-build
|
2019-07-03 00:10:17 +00:00
|
|
|
else
|
|
|
|
local image
|
|
|
|
if [[ "${target}" == alpine ]]; then
|
|
|
|
image=codercom/nbin-alpine
|
|
|
|
target=musl
|
|
|
|
else
|
|
|
|
image=codercom/nbin-centos
|
|
|
|
target=linux
|
|
|
|
fi
|
2019-07-10 23:10:39 +00:00
|
|
|
docker-build
|
2019-07-03 00:10:17 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|