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

62 lines
1.7 KiB
Bash
Raw Normal View History

2020-01-15 18:05:27 +00:00
#!/usr/bin/env bash
# ci.bash -- Build code-server in the CI.
2019-07-11 22:12:52 +00:00
set -euo pipefail
2019-07-10 23:10:39 +00:00
# This script assumes that yarn has already ran.
2019-07-03 00:10:17 +00:00
function main() {
2020-02-04 19:27:46 +00:00
cd "$(dirname "${0}")/.."
local code_server_version=${VERSION:-${TRAVIS_TAG:-${DRONE_TAG:-}}}
if [[ -z $code_server_version ]] ; then
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
2020-02-04 19:27:46 +00:00
YARN_CACHE_FOLDER="$(pwd)/yarn-cache"
export YARN_CACHE_FOLDER
2019-07-03 00:10:17 +00:00
2020-02-04 19:27:46 +00:00
# Always minify and package on tags since that's when releases are pushed.
if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then
export MINIFY="true"
export PACKAGE="true"
fi
2019-07-03 00:10:17 +00:00
2020-02-04 19:27:46 +00:00
yarn build
yarn binary
if [[ -n ${PACKAGE:-} ]] ; then
yarn package
fi
2019-07-03 00:10:17 +00:00
2020-02-04 19:27:46 +00:00
cd binaries
2020-02-04 19:27:46 +00:00
if [[ -n ${STRIP_BIN_TARGET:-} ]] ; then
# In this case provide plainly named binaries.
for binary in code-server* ; do
echo "Moving $binary to code-server"
mv "$binary" code-server
done
elif [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then
# Prepare directory for uploading binaries on release.
for binary in code-server* ; do
mkdir -p "../binary-upload"
2020-02-04 19:27:46 +00:00
local prefix="code-server-$code_server_version-"
local target="${binary#$prefix}"
if [[ $target == "linux-x86_64" ]] ; then
echo "Copying $binary to ../binary-upload/latest-linux"
cp "$binary" "../binary-upload/latest-linux"
fi
2020-02-04 19:27:46 +00:00
local gcp_dir
gcp_dir="../binary-upload/releases/$code_server_version/$target"
mkdir -p "$gcp_dir"
2020-02-04 19:27:46 +00:00
echo "Copying $binary to $gcp_dir/code-server"
cp "$binary" "$gcp_dir/code-server"
done
fi
2019-07-03 00:10:17 +00:00
}
main "$@"