2020-02-19 00:06:35 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-04-30 11:52:54 +00:00
|
|
|
pushd() {
|
|
|
|
builtin pushd "$@" > /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
popd() {
|
|
|
|
builtin popd > /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg_json_version() {
|
|
|
|
jq -r .version package.json
|
|
|
|
}
|
|
|
|
|
2020-05-11 21:08:22 +00:00
|
|
|
vscode_version() {
|
|
|
|
jq -r .version lib/vscode/package.json
|
|
|
|
}
|
|
|
|
|
2020-04-30 11:52:54 +00:00
|
|
|
os() {
|
|
|
|
local os
|
|
|
|
os=$(uname | tr '[:upper:]' '[:lower:]')
|
|
|
|
if [[ $os == "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
|
|
|
|
os="alpine"
|
|
|
|
fi
|
2020-05-14 09:47:11 +00:00
|
|
|
elif [[ $os == "darwin" ]]; then
|
|
|
|
os="macos"
|
2020-02-19 00:06:35 +00:00
|
|
|
fi
|
2020-04-30 11:52:54 +00:00
|
|
|
echo "$os"
|
|
|
|
}
|
|
|
|
|
|
|
|
arch() {
|
|
|
|
case "$(uname -m)" in
|
|
|
|
aarch64)
|
|
|
|
echo arm64
|
|
|
|
;;
|
|
|
|
x86_64)
|
|
|
|
echo amd64
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unknown architecture $(uname -a)"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2020-02-19 00:06:35 +00:00
|
|
|
}
|
2020-05-11 21:08:22 +00:00
|
|
|
|
|
|
|
curl() {
|
|
|
|
command curl -H "Authorization: token $GITHUB_TOKEN" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Grabs the most recent ci.yaml github workflow run that was successful and triggered from the same commit being pushd.
|
|
|
|
# This will contain the artifacts we want.
|
|
|
|
# https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
|
|
|
|
get_artifacts_url() {
|
|
|
|
curl -sSL 'https://api.github.com/repos/cdr/code-server/actions/workflows/ci.yaml/runs?status=success&event=push' | jq -r ".workflow_runs[] | select(.head_sha == \"$(git rev-parse HEAD)\") | .artifacts_url" | head -n 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Grabs the artifact's download url.
|
|
|
|
# https://developer.github.com/v3/actions/artifacts/#list-workflow-run-artifacts
|
|
|
|
get_artifact_url() {
|
|
|
|
local artifact_name="$1"
|
|
|
|
curl -sSL "$(get_artifacts_url)" | jq -r ".artifacts[] | select(.name == \"$artifact_name\") | .archive_download_url" | head -n 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Uses the above two functions to download a artifact into a directory.
|
|
|
|
download_artifact() {
|
|
|
|
local artifact_name="$1"
|
|
|
|
local dst="$2"
|
|
|
|
|
|
|
|
local tmp_file
|
|
|
|
tmp_file="$(mktemp)"
|
|
|
|
|
|
|
|
curl -sSL "$(get_artifact_url "$artifact_name")" > "$tmp_file"
|
2020-05-16 14:55:46 +00:00
|
|
|
unzip -q -o "$tmp_file" -d "$dst"
|
2020-05-11 21:08:22 +00:00
|
|
|
rm "$tmp_file"
|
|
|
|
}
|
2020-05-16 14:55:46 +00:00
|
|
|
|
|
|
|
rsync() {
|
|
|
|
command rsync -a --del "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
VERSION="$(pkg_json_version)"
|
|
|
|
export VERSION
|
|
|
|
ARCH="$(arch)"
|
|
|
|
export ARCH
|
|
|
|
OS=$(os)
|
|
|
|
export OS
|
|
|
|
|
|
|
|
# RELEASE_PATH is the destination directory for the release from the root.
|
|
|
|
# Defaults to release
|
|
|
|
RELEASE_PATH="${RELEASE_PATH-release}"
|