2020-01-16 02:05:27 +08:00
|
|
|
#!/usr/bin/env bash
|
2020-01-15 05:06:49 +08:00
|
|
|
# ci.bash -- Build code-server in the CI.
|
2019-07-12 06:12:52 +08:00
|
|
|
|
2020-01-15 05:06:49 +08:00
|
|
|
set -euo pipefail
|
2019-07-11 07:10:39 +08:00
|
|
|
|
2020-02-05 05:00:44 +08:00
|
|
|
# This script assumes that yarn has already ran.
|
2019-07-03 08:10:17 +08:00
|
|
|
function main() {
|
2020-02-05 03:27:46 +08:00
|
|
|
cd "$(dirname "${0}")/.."
|
|
|
|
|
2020-02-18 12:22:12 +08:00
|
|
|
local code_server_version=${VERSION:-${TRAVIS_TAG:-}}
|
2020-02-15 08:46:00 +08:00
|
|
|
if [[ -z $code_server_version ]]; then
|
2020-02-05 03:27:46 +08:00
|
|
|
code_server_version=$(grep version ./package.json | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[:space:]')
|
|
|
|
fi
|
|
|
|
export VERSION=$code_server_version
|
2019-09-11 00:29:48 +08:00
|
|
|
|
2020-02-18 12:22:12 +08:00
|
|
|
# Always minify and package on CI since that's when releases are pushed.
|
|
|
|
if [[ ${CI:-} ]]; then
|
2020-02-05 03:27:46 +08:00
|
|
|
export MINIFY="true"
|
|
|
|
export PACKAGE="true"
|
|
|
|
fi
|
2019-07-03 08:10:17 +08:00
|
|
|
|
2020-02-05 03:27:46 +08:00
|
|
|
yarn build
|
|
|
|
yarn binary
|
2020-02-15 08:46:00 +08:00
|
|
|
if [[ -n ${PACKAGE:-} ]]; then
|
2020-02-05 03:27:46 +08:00
|
|
|
yarn package
|
|
|
|
fi
|
2019-07-03 08:10:17 +08:00
|
|
|
|
2020-02-05 03:27:46 +08:00
|
|
|
cd binaries
|
2020-01-15 05:06:49 +08:00
|
|
|
|
2020-02-15 08:46:00 +08:00
|
|
|
if [[ -n ${STRIP_BIN_TARGET:-} ]]; then
|
2020-02-05 03:27:46 +08:00
|
|
|
# In this case provide plainly named binaries.
|
2020-02-15 08:46:00 +08:00
|
|
|
for binary in code-server*; do
|
2020-02-05 03:27:46 +08:00
|
|
|
echo "Moving $binary to code-server"
|
|
|
|
mv "$binary" code-server
|
|
|
|
done
|
2020-02-15 08:46:00 +08:00
|
|
|
elif [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]]; then
|
2020-02-05 03:27:46 +08:00
|
|
|
# Prepare directory for uploading binaries on release.
|
2020-02-15 08:46:00 +08:00
|
|
|
for binary in code-server*; do
|
2020-02-05 03:27:46 +08:00
|
|
|
mkdir -p "../binary-upload"
|
2020-01-15 05:11:12 +08:00
|
|
|
|
2020-02-05 03:27:46 +08:00
|
|
|
local prefix="code-server-$code_server_version-"
|
|
|
|
local target="${binary#$prefix}"
|
2020-02-15 08:46:00 +08:00
|
|
|
if [[ $target == "linux-x86_64" ]]; then
|
2020-02-05 03:27:46 +08:00
|
|
|
echo "Copying $binary to ../binary-upload/latest-linux"
|
|
|
|
cp "$binary" "../binary-upload/latest-linux"
|
|
|
|
fi
|
2020-02-05 01:32:45 +08:00
|
|
|
|
2020-02-05 03:27:46 +08:00
|
|
|
local gcp_dir
|
|
|
|
gcp_dir="../binary-upload/releases/$code_server_version/$target"
|
|
|
|
mkdir -p "$gcp_dir"
|
2020-02-05 01:32:45 +08:00
|
|
|
|
2020-02-05 03:27:46 +08:00
|
|
|
echo "Copying $binary to $gcp_dir/code-server"
|
|
|
|
cp "$binary" "$gcp_dir/code-server"
|
|
|
|
done
|
|
|
|
fi
|
2019-07-03 08:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|