1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-28 13:15:25 +00:00
code-server-2/scripts/ci.bash

80 lines
1.9 KiB
Bash
Raw Normal View History

2019-07-03 00:10:17 +00:00
#!/bin/bash
set -euo pipefail
function docker-build() {
local target="${TARGET:-}"
2019-07-11 22:12:52 +00:00
local image="codercom/nbin-${target}"
local token="${GITHUB_TOKEN:-}"
local minify="${MINIFY:-}"
2019-07-11 22:12:52 +00:00
if [[ "${target}" == "linux" ]] ; then
image="codercom/nbin-centos"
fi
2019-07-03 00:10:17 +00:00
local containerId
# Use a mount so we can cache the results.
containerId=$(docker create --network=host --rm -it -v "$(pwd)":/src "${image}")
2019-07-03 00:10:17 +00:00
docker start "${containerId}"
# TODO: Might be better to move these dependencies to the images or create new
# ones on top of these.
2019-07-11 22:12:52 +00:00
if [[ "${image}" == "codercom/nbin-alpine" ]] ; then
docker exec "${containerId}" apk add libxkbfile-dev libsecret-dev
2019-07-15 18:23:29 +00:00
else
2019-07-24 16:23:00 +00:00
docker exec "${containerId}" yum install -y libxkbfile-devel libsecret-devel git
2019-07-11 22:12:52 +00:00
fi
2019-07-03 00:10:17 +00:00
function docker-exec() {
2019-07-10 23:10:39 +00:00
local command="${1}" ; shift
local args="'${vscodeVersion}' '${codeServerVersion}'"
2019-07-10 23:10:39 +00:00
docker exec "${containerId}" \
bash -c "cd /src && CI=true GITHUB_TOKEN=${token} MINIFY=${minify} yarn ${command} ${args}"
2019-07-03 00:10:17 +00:00
}
2019-07-10 23:10:39 +00:00
docker-exec build
if [[ -n "${package}" ]] ; then
docker-exec binary
docker-exec package
fi
2019-07-03 00:10:17 +00:00
docker kill "${containerId}"
2019-07-03 00:10:17 +00:00
}
2019-07-10 23:10:39 +00:00
function local-build() {
function local-exec() {
local command="${1}" ; shift
CI=true yarn "${command}" "${vscodeVersion}" "${codeServerVersion}"
2019-07-10 23:10:39 +00:00
}
local-exec build
if [[ -n "${package}" ]] ; then
local-exec binary
local-exec package
fi
2019-07-10 23:10:39 +00:00
}
2019-07-03 00:10:17 +00:00
# Build code-server in the CI.
function main() {
cd "$(dirname "${0}")/.."
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 package="${PACKAGE:-}"
2019-07-03 00:10:17 +00:00
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
2019-07-10 23:10:39 +00:00
local-build
2019-07-03 00:10:17 +00:00
else
2019-07-10 23:10:39 +00:00
docker-build
2019-07-03 00:10:17 +00:00
fi
}
main "$@"