2019-07-03 07:10:17 +07:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
function docker-build() {
|
2019-08-05 23:03:47 +07:00
|
|
|
local target="${TARGET:-}"
|
2019-07-12 05:12:52 +07:00
|
|
|
local image="codercom/nbin-${target}"
|
2019-08-20 05:02:02 +07:00
|
|
|
local token="${GITHUB_TOKEN:-}"
|
2019-08-20 05:17:38 +07:00
|
|
|
local minify="${MINIFY:-}"
|
2019-07-12 05:12:52 +07:00
|
|
|
if [[ "${target}" == "linux" ]] ; then
|
|
|
|
image="codercom/nbin-centos"
|
|
|
|
fi
|
|
|
|
|
2019-07-03 07:10:17 +07:00
|
|
|
local containerId
|
2019-10-19 06:20:02 +07:00
|
|
|
# Use a mount so we can cache the results.
|
|
|
|
containerId=$(docker create --network=host --rm -it -v "$(pwd)":/src "${image}")
|
2019-07-03 07:10:17 +07:00
|
|
|
docker start "${containerId}"
|
|
|
|
|
2019-10-19 06:20:02 +07:00
|
|
|
# TODO: Might be better to move these dependencies to the images or create new
|
|
|
|
# ones on top of these.
|
2019-07-12 05:12:52 +07:00
|
|
|
if [[ "${image}" == "codercom/nbin-alpine" ]] ; then
|
|
|
|
docker exec "${containerId}" apk add libxkbfile-dev libsecret-dev
|
2019-07-16 01:23:29 +07:00
|
|
|
else
|
2019-07-24 23:23:00 +07:00
|
|
|
docker exec "${containerId}" yum install -y libxkbfile-devel libsecret-devel git
|
2019-07-12 05:12:52 +07:00
|
|
|
fi
|
|
|
|
|
2019-07-03 07:10:17 +07:00
|
|
|
function docker-exec() {
|
2019-07-11 06:10:39 +07:00
|
|
|
local command="${1}" ; shift
|
2019-08-21 23:29:28 +07:00
|
|
|
local args="'${vscodeVersion}' '${codeServerVersion}'"
|
2019-07-11 06:10:39 +07:00
|
|
|
docker exec "${containerId}" \
|
2019-08-20 05:17:38 +07:00
|
|
|
bash -c "cd /src && CI=true GITHUB_TOKEN=${token} MINIFY=${minify} yarn ${command} ${args}"
|
2019-07-03 07:10:17 +07:00
|
|
|
}
|
|
|
|
|
2019-07-11 06:10:39 +07:00
|
|
|
docker-exec build
|
2019-08-21 07:44:32 +07:00
|
|
|
if [[ -n "${package}" ]] ; then
|
|
|
|
docker-exec binary
|
|
|
|
docker-exec package
|
|
|
|
fi
|
2019-07-03 07:10:17 +07:00
|
|
|
|
2019-10-19 06:20:02 +07:00
|
|
|
docker kill "${containerId}"
|
2019-07-03 07:10:17 +07:00
|
|
|
}
|
|
|
|
|
2019-07-11 06:10:39 +07:00
|
|
|
function local-build() {
|
|
|
|
function local-exec() {
|
|
|
|
local command="${1}" ; shift
|
2019-08-03 07:26:41 +07:00
|
|
|
CI=true yarn "${command}" "${vscodeVersion}" "${codeServerVersion}"
|
2019-07-11 06:10:39 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
local-exec build
|
2019-08-21 07:44:32 +07:00
|
|
|
if [[ -n "${package}" ]] ; then
|
|
|
|
local-exec binary
|
|
|
|
local-exec package
|
|
|
|
fi
|
2019-07-11 06:10:39 +07:00
|
|
|
}
|
|
|
|
|
2019-07-03 07:10:17 +07:00
|
|
|
# Build code-server in the CI.
|
|
|
|
function main() {
|
2019-09-10 23:29:48 +07:00
|
|
|
cd "$(dirname "${0}")/.."
|
|
|
|
|
2019-07-11 06:10:39 +07:00
|
|
|
local codeServerVersion="${VERSION:-}"
|
2020-01-15 02:12:10 +07:00
|
|
|
local vscodeVersion="${VSCODE_VERSION:-1.41.1}"
|
2019-07-03 07:10:17 +07:00
|
|
|
local ostype="${OSTYPE:-}"
|
2019-08-21 07:44:32 +07:00
|
|
|
local package="${PACKAGE:-}"
|
2019-07-03 07:10:17 +07:00
|
|
|
|
2019-07-11 06:10:39 +07:00
|
|
|
if [[ -z "${codeServerVersion}" ]] ; then
|
2020-01-15 02:12:10 +07:00
|
|
|
codeServerVersion="2.${TRAVIS_TAG:-${DRONE_TAG:-daily}}"
|
2019-07-03 07:10:17 +07:00
|
|
|
fi
|
|
|
|
|
2020-01-15 02:12:10 +07:00
|
|
|
local branch="${TRAVIS_BRANCH:-DRONE_BRANCH}"
|
|
|
|
if [[ $branch == "master" ]] ; then
|
|
|
|
export MINIFY="true"
|
|
|
|
export PACKAGE="true"
|
2019-07-03 07:10:17 +07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${ostype}" == "darwin"* ]]; then
|
2019-07-11 06:10:39 +07:00
|
|
|
local-build
|
2019-07-03 07:10:17 +07:00
|
|
|
else
|
2019-07-11 06:10:39 +07:00
|
|
|
docker-build
|
2019-07-03 07:10:17 +07:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|