Skip to content
This repository has been archived by the owner on Apr 21, 2019. It is now read-only.

Commit

Permalink
travis: run deploy script on tags
Browse files Browse the repository at this point in the history
Make parts of deploy.sh idempotent in order to support running multiple
times on the same build.

Fixes #2
  • Loading branch information
zombiezen committed Feb 7, 2017
1 parent f84278c commit ea5b882
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ script: ./bazel --bazelrc=travis/bazelrc test //...

deploy:
- provider: script
script: "travis/deploy.sh '' gs://mcm-continuous-builds/mcm- -${TRAVIS_BUILD_NUMBER}.zip"
script: "travis/deploy.sh '' gs://mcm-continuous-builds/mcm-${TRAVIS_BUILD_NUMBER}- .zip"
on:
branch: master
- provider: script
script: "travis/deploy.sh \"$TRAVIS_TAG\" \"gs://mcm-releases/mcm-${TRAVIS_TAG}-\" .zip"
on:
tags: true
27 changes: 17 additions & 10 deletions travis/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,24 @@ echostep() {
}

# Install gcloud & gsutil
echostep curl 'https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-142.0.0-linux-x86_64.tar.gz' > /tmp/google-cloud-sdk.tar.gz || exit 1
echo 'c05f649623b7a8696923f4c003bd95decb591f6e /tmp/google-cloud-sdk.tar.gz' | echostep sha1sum -c || exit 1
echostep tar zxf /tmp/google-cloud-sdk.tar.gz -C "$HOME" || exit 1
if [[ ! -d "$HOME/google-cloud-sdk" ]]; then
echostep curl 'https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-142.0.0-linux-x86_64.tar.gz' > /tmp/google-cloud-sdk.tar.gz || exit 1
echo 'c05f649623b7a8696923f4c003bd95decb591f6e /tmp/google-cloud-sdk.tar.gz' | echostep sha1sum -c || exit 1
echostep tar zxf /tmp/google-cloud-sdk.tar.gz -C "$HOME" || exit 1
fi
echostep $HOME/google-cloud-sdk/bin/gcloud --quiet components install gsutil || exit 1

# gcloud init
echostep $HOME/google-cloud-sdk/bin/gcloud config set disable_prompts True || exit 1
echostep $HOME/google-cloud-sdk/bin/gcloud config set project mcm-releases || exit 1
echo "decrypt travis/service-account.json" 1>&2
openssl aes-256-cbc \
-K $encrypted_0c4c8f78bd1d_key -iv $encrypted_0c4c8f78bd1d_iv \
-in travis/service-account.json.enc \
-out travis/service-account.json \
-d || exit 1
if [[ ! -f travis/service-account.json ]]; then
echo "decrypt travis/service-account.json" 1>&2
openssl aes-256-cbc \
-K $encrypted_0c4c8f78bd1d_key -iv $encrypted_0c4c8f78bd1d_iv \
-in travis/service-account.json.enc \
-out travis/service-account.json \
-d || exit 1
fi
echostep $HOME/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=travis/service-account.json || exit 1

# Build and deploy
Expand All @@ -46,4 +50,7 @@ echostep zip -j travis/build.zip \
bazel-bin/exec/mcm-exec \
bazel-bin/luacat/mcm-luacat \
bazel-bin/shellify/mcm-shellify || exit 1
echostep $HOME/google-cloud-sdk/bin/gsutil cp -n travis/build.zip "$gcs_out" || exit 1
echostep $HOME/google-cloud-sdk/bin/gsutil cp -n travis/build.zip "$gcs_out"
gsutil_result=$?
echostep rm -f travis/build.zip || exit 1
[[ $gsutil_result -eq 0 ]] || exit 1

0 comments on commit ea5b882

Please sign in to comment.