2020-01-15 18:05:27 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-01-14 21:06:49 +00:00
|
|
|
# ci.bash -- Build code-server in the CI.
|
2019-07-11 22:12:52 +00:00
|
|
|
|
2020-01-14 21:06:49 +00:00
|
|
|
set -euo pipefail
|
2019-07-10 23:10:39 +00:00
|
|
|
|
2020-02-04 17:32:45 +00:00
|
|
|
function target() {
|
|
|
|
local os=$(uname | tr '[:upper:]' '[:lower:]')
|
|
|
|
if [[ "$os" == "linux" ]]; then
|
|
|
|
# Using the same strategy to detect Alpine as build.ts.
|
|
|
|
local ldd_output=$(ldd --version 2>&1 || true)
|
|
|
|
if echo "$ldd_output" | grep -iq musl; then
|
|
|
|
os="alpine"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "${os}-$(uname -m)"
|
|
|
|
}
|
|
|
|
|
2019-07-03 00:10:17 +00:00
|
|
|
function main() {
|
2019-09-10 16:29:48 +00:00
|
|
|
cd "$(dirname "${0}")/.."
|
|
|
|
|
2020-01-14 21:06:49 +00:00
|
|
|
# Get the version information. If a specific version wasn't set, generate it
|
|
|
|
# from the tag and VS Code version.
|
|
|
|
local vscode_version=${VSCODE_VERSION:-1.41.1}
|
2020-01-16 23:59:11 +00:00
|
|
|
local code_server_version=${VERSION:-${TRAVIS_TAG:-${DRONE_TAG:-daily}}}
|
2019-07-03 00:10:17 +00:00
|
|
|
|
2020-01-14 21:06:49 +00:00
|
|
|
# Remove everything that isn't the current VS Code source for caching
|
|
|
|
# (otherwise the cache will contain old versions).
|
|
|
|
if [[ -d "source/vscode-$vscode_version-source" ]] ; then
|
|
|
|
mv "source/vscode-$vscode_version-source" "vscode-$vscode_version-source"
|
|
|
|
fi
|
|
|
|
rm -rf source/vscode-*-source
|
|
|
|
if [[ -d "vscode-$vscode_version-source" ]] ; then
|
|
|
|
mv "vscode-$vscode_version-source" "source/vscode-$vscode_version-source"
|
2019-07-03 00:10:17 +00:00
|
|
|
fi
|
|
|
|
|
2020-01-16 21:39:44 +00:00
|
|
|
YARN_CACHE_FOLDER="$(pwd)/yarn-cache"
|
|
|
|
export YARN_CACHE_FOLDER
|
|
|
|
|
2020-01-14 21:11:12 +00:00
|
|
|
# Always minify and package on tags since that's when releases are pushed.
|
2020-01-14 21:06:49 +00:00
|
|
|
if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then
|
2020-01-14 19:12:10 +00:00
|
|
|
export MINIFY="true"
|
|
|
|
export PACKAGE="true"
|
2019-07-03 00:10:17 +00:00
|
|
|
fi
|
|
|
|
|
2020-01-14 21:06:49 +00:00
|
|
|
function run-yarn() {
|
|
|
|
yarn "$1" "$vscode_version" "$code_server_version"
|
|
|
|
}
|
|
|
|
|
|
|
|
run-yarn build
|
2020-01-15 18:05:27 +00:00
|
|
|
run-yarn binary
|
2020-01-14 21:11:12 +00:00
|
|
|
if [[ -n ${PACKAGE:-} ]] ; then
|
|
|
|
run-yarn package
|
|
|
|
fi
|
|
|
|
|
|
|
|
# In this case provide a plainly named "code-server" binary.
|
|
|
|
if [[ -n ${BINARY:-} ]] ; then
|
|
|
|
mv binaries/code-server*-vsc* binaries/code-server
|
|
|
|
fi
|
2020-02-04 17:32:45 +00:00
|
|
|
|
|
|
|
# Prepare GCS bucket directory on release.
|
|
|
|
if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then
|
|
|
|
local gcp_dir="gcs_bucket/releases/$code_server_version/$(target)"
|
|
|
|
|
|
|
|
mkdir -p "$gcp_dir"
|
|
|
|
mv binaries/code-server*-vsc* "$gcp_dir"
|
|
|
|
if [[ "$(target)" == "linux-x86_64" ]] ; then
|
|
|
|
mv binaries/code-server*-vsc* "gcs_bucket/latest-linux"
|
|
|
|
fi
|
|
|
|
fi
|
2019-07-03 00:10:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|