From 3ee6b0ff0b01eb501c543415a844b1889d6b6414 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Wed, 5 Feb 2020 03:32:45 +1000 Subject: [PATCH] Automatically push releases to GCS (#1318) --- .drone.yml | 40 ++++++++++++++++++++++++++++++++++++++++ scripts/ci.bash | 24 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/.drone.yml b/.drone.yml index 42208c9..2d302c8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -66,6 +66,16 @@ steps: when: event: tag +- name: publish:gcs + image: plugins/gcs + settings: + source: gcs_bucket + target: codesrv-ci.cdr.sh/ + token: + from_secret: gcs-token + when: + event: tag + --- kind: pipeline type: docker @@ -120,6 +130,16 @@ steps: when: event: tag +- name: publish:gcs + image: plugins/gcs + settings: + source: gcs_bucket + target: codesrv-ci.cdr.sh/ + token: + from_secret: gcs-token + when: + event: tag + --- kind: pipeline type: docker @@ -188,6 +208,16 @@ steps: when: event: tag +- name: publish:gcs + image: plugins/gcs + settings: + source: gcs_bucket + target: codesrv-ci.cdr.sh/ + token: + from_secret: gcs-token + when: + event: tag + --- kind: pipeline type: docker @@ -242,6 +272,16 @@ steps: when: event: tag +- name: publish:gcs + image: plugins/gcs + settings: + source: gcs_bucket + target: codesrv-ci.cdr.sh/ + token: + from_secret: gcs-token + when: + event: tag + --- kind: pipeline type: docker diff --git a/scripts/ci.bash b/scripts/ci.bash index 11d2be7..e33a22c 100755 --- a/scripts/ci.bash +++ b/scripts/ci.bash @@ -3,6 +3,19 @@ set -euo pipefail +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)" +} + function main() { cd "$(dirname "${0}")/.." @@ -44,6 +57,17 @@ function main() { if [[ -n ${BINARY:-} ]] ; then mv binaries/code-server*-vsc* binaries/code-server fi + + # 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 } main "$@"