diff --git a/.teamcity/build-macos.sh b/.teamcity/build-macos.sh new file mode 100755 index 00000000..43d47195 --- /dev/null +++ b/.teamcity/build-macos.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -euo pipefail + +if ! git describe --tags --exact-match 2>/dev/null ; then + echo "Skipping public release for an untagged commit." + echo "##teamcity[buildStatus status='SUCCESS' text='Skipped due to lack of tag']" + exit 0 +fi + +if [[ "$(uname)" != "Darwin" ]] ; then + echo "This should be run on macOS" + exit 1 +fi + +go version +export GO111MODULE=on + +# build 'cloudflared-darwin-amd64.tgz' +mkdir -p artifacts +FILENAME="$(pwd)/artifacts/cloudflared-darwin-amd64.tgz" +export PATH="$PATH:/usr/local/bin" +mkdir -p ../src/github.com/cloudflare/ +cp -r . ../src/github.com/cloudflare/cloudflared +cd ../src/github.com/cloudflare/cloudflared +GOCACHE="$PWD/../../../../" GOPATH="$PWD/../../../../" CGO_ENABLED=1 make cloudflared +tar czf "$FILENAME" cloudflared diff --git a/.teamcity/update-homebrew.sh b/.teamcity/update-homebrew.sh new file mode 100755 index 00000000..7f898d3d --- /dev/null +++ b/.teamcity/update-homebrew.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +set -euo pipefail + +FILENAME="${PWD}/artifacts/cloudflared-darwin-amd64.tgz" + +if ! VERSION="$(git describe --tags --exact-match 2>/dev/null)" ; then + echo "Skipping public release for an untagged commit." + echo "##teamcity[buildStatus status='SUCCESS' text='Skipped due to lack of tag']" + exit 0 +fi + +if [[ ! -f "$FILENAME" ]] ; then + echo "Missing $FILENAME" + exit 1 +fi + +# upload to s3 bucket for use by Homebrew formula +s3cmd \ + --acl-public --signature-v2 --access_key="$AWS_ACCESS_KEY_ID" --secret_key="$AWS_SECRET_ACCESS_KEY" --host-bucket="%(bucket)s.s3.cfdata.org" \ + put "$FILENAME" "s3://cftunnel-docs/dl/cloudflared-$VERSION-darwin-amd64.tgz" +s3cmd \ + --acl-public --signature-v2 --access_key="$AWS_ACCESS_KEY_ID" --secret_key="$AWS_SECRET_ACCESS_KEY" --host-bucket="%(bucket)s.s3.cfdata.org" \ + cp "s3://cftunnel-docs/dl/cloudflared-$VERSION-darwin-amd64.tgz" "s3://cftunnel-docs/dl/cloudflared-stable-darwin-amd64.tgz" +SHA256=$(sha256sum "$FILENAME" | cut -b1-64) + +# set up git (note that UserKnownHostsFile is an absolute path so we can cd wherever) +mkdir -p tmp +ssh-keyscan -t rsa github.com > tmp/github.txt +export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=$PWD/tmp/github.txt" + +# clone Homebrew repo into tmp/homebrew-cloudflare +git clone git@github.com:cloudflare/homebrew-cloudflare.git tmp/homebrew-cloudflare +cd tmp/homebrew-cloudflare +git checkout -f master +git reset --hard origin/master + +# modify cloudflared.rb +URL="https://developers.cloudflare.com/argo-tunnel/dl/cloudflared-$VERSION-darwin-amd64.tgz" +tee cloudflared.rb <