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-26 06:20:47 +08:00
|
|
|
function package() {
|
|
|
|
local target
|
|
|
|
target=$(uname | tr '[:upper:]' '[:lower:]')
|
|
|
|
if [[ $target == "linux" ]]; then
|
|
|
|
# Alpine's ldd doesn't have a version flag but if you use an invalid flag
|
|
|
|
# (like --version) it outputs the version to stderr and exits with 1.
|
|
|
|
local ldd_output
|
|
|
|
ldd_output=$(ldd --version 2>&1 || true)
|
|
|
|
if echo "$ldd_output" | grep -iq musl; then
|
|
|
|
target="alpine"
|
|
|
|
fi
|
|
|
|
fi
|
2020-02-05 03:27:46 +08:00
|
|
|
|
2020-02-26 06:20:47 +08:00
|
|
|
local arch
|
2020-03-27 04:50:32 +08:00
|
|
|
arch=$(uname -m | sed 's/aarch/arm/')
|
2020-02-26 06:20:47 +08:00
|
|
|
|
|
|
|
echo -n "Creating release..."
|
2019-09-11 00:29:48 +08:00
|
|
|
|
2020-02-26 06:20:47 +08:00
|
|
|
cp "$(command -v node)" ./build
|
|
|
|
cp README.md ./build
|
|
|
|
cp LICENSE.txt ./build
|
|
|
|
cp ./lib/vscode/ThirdPartyNotices.txt ./build
|
|
|
|
cp ./ci/code-server.sh ./build/code-server
|
|
|
|
|
|
|
|
local archive_name="code-server-$VERSION-$target-$arch"
|
|
|
|
mkdir -p ./release
|
|
|
|
|
|
|
|
local ext
|
|
|
|
if [[ $target == "linux" ]]; then
|
|
|
|
ext=".tar.gz"
|
|
|
|
tar -czf "release/$archive_name$ext" --transform "s/^\.\/build/$archive_name/" ./build
|
|
|
|
else
|
|
|
|
mv ./build "./$archive_name"
|
|
|
|
ext=".zip"
|
2020-03-04 05:07:58 +08:00
|
|
|
zip -r "release/$archive_name$ext" "./$archive_name"
|
2020-02-26 06:20:47 +08:00
|
|
|
mv "./$archive_name" ./build
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "done (release/$archive_name)"
|
|
|
|
|
|
|
|
mkdir -p "./release-upload/$VERSION"
|
2020-03-05 06:51:58 +08:00
|
|
|
cp "./release/$archive_name$ext" "./release-upload/$VERSION/$target-$arch$ext"
|
2020-02-26 06:20:47 +08:00
|
|
|
mkdir -p "./release-upload/latest"
|
2020-03-05 06:51:58 +08:00
|
|
|
cp "./release/$archive_name$ext" "./release-upload/latest/$target-$arch$ext"
|
2020-02-26 06:20:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# This script assumes that yarn has already ran.
|
|
|
|
function build() {
|
|
|
|
# Always minify and package on CI.
|
2020-02-18 12:22:12 +08:00
|
|
|
if [[ ${CI:-} ]]; then
|
2020-02-05 03:27:46 +08:00
|
|
|
export MINIFY="true"
|
|
|
|
fi
|
2019-07-03 08:10:17 +08:00
|
|
|
|
2020-02-05 03:27:46 +08:00
|
|
|
yarn build
|
2020-02-26 06:20:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
cd "$(dirname "${0}")/.."
|
|
|
|
source ./ci/lib.sh
|
|
|
|
|
|
|
|
set_version
|
|
|
|
|
|
|
|
build
|
2019-07-03 08:10:17 +08:00
|
|
|
|
2020-02-26 06:20:47 +08:00
|
|
|
if [[ ${CI:-} ]]; then
|
|
|
|
package
|
2020-02-05 03:27:46 +08:00
|
|
|
fi
|
2019-07-03 08:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|