diff --git a/.circleci/config.yml b/.circleci/config.yml index 7c601618ddb..59cf706cfbb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -119,6 +119,49 @@ jobs: - deploy-executor: worker-id: "5" + release: + docker: + - image: circleci/golang:1.12.6 + environment: + GO111MODULE: "on" + working_directory: /go/src/github.com/G-Research/k8s-batch + steps: + - checkout + - setup_remote_docker + + - run: + name: Build armadactl release artifacts + command: make build-armadactl-release RELEASE_VERSION=${CIRCLE_TAG} + + - store_artifacts: + path: dist/* + + - run: + name: Upload artifacts to Github release + command: | + for artifact in ./dist/*; do + ./scripts/upload-github-release-asset.sh ${GITHUB_TOKEN} ${CIRCLE_TAG} $artifact + done + + ./scripts/add-checksum-summary.sh ${GITHUB_TOKEN} ${CIRCLE_TAG} + + - run: + name: Publish images + command: | + TAG=${CIRCLE_SHA1} + RELEASE_TAG=${CIRCLE_TAG} + + echo ${DOCKERHUB_PASS} | docker login -u ${DOCKERHUB_USER} --password-stdin + + docker pull gresearchdev/armada-server-dev:${TAG} + docker tag gresearchdev/armada-server-dev:${TAG} gresearchdev/armada-server:${RELEASE_TAG} + docker push gresearchdev/armada-server:${RELEASE_TAG} + + docker pull gresearchdev/armada-executor-dev:${TAG} + docker tag gresearchdev/armada-executor-dev:${TAG} gresearchdev/armada-executor:${RELEASE_TAG} + docker push gresearchdev/armada-executor:${RELEASE_TAG} + + workflows: version: 2 build_and_deploy: @@ -130,3 +173,9 @@ workflows: filters: branches: only: master + - release: + filters: + tags: + only: /.*/ + branches: + ignore: /.*/ diff --git a/go.mod b/go.mod index a2f437dc8b6..9f142ea15d9 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/magiconair/properties v1.8.1 // indirect github.com/mitchellh/go-homedir v1.1.0 + github.com/mitchellh/gox v1.0.1 // indirect github.com/oklog/ulid v1.3.1 github.com/pelletier/go-toml v1.4.0 // indirect github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect diff --git a/go.sum b/go.sum index beaec37c7a9..755d196320b 100644 --- a/go.sum +++ b/go.sum @@ -96,6 +96,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xC github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= @@ -135,6 +137,10 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= +github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/makefile b/makefile index c88bce83225..2b7de672e3e 100644 --- a/makefile +++ b/makefile @@ -14,6 +14,19 @@ build-executor: build-armadactl: $(gobuild) -o ./bin/armadactl cmd/armadactl/main.go +build-armadactl-multiplatform: + go run github.com/mitchellh/gox -output="./bin/{{.OS}}-{{.Arch}}/armadactl" -arch="amd64" -os="windows linux darwin" ./cmd/armadactl/ + +ifndef RELEASE_VERSION +override RELEASE_VERSION = UNKNOWN_VERSION +endif + +build-armadactl-release: build-armadactl-multiplatform + mkdir ./dist || true + tar -czvf ./dist/armadactl-$(RELEASE_VERSION)-linux-amd64.tar.gz -C ./bin/linux-amd64/ armadactl + tar -czvf ./dist/armadactl-$(RELEASE_VERSION)-darwin-amd64.tar.gz -C ./bin/darwin-amd64/ armadactl + zip -j ./dist/armadactl-$(RELEASE_VERSION)-windows-amd64.zip ./bin/windows-amd64/armadactl.exe + build-load-tester: $(gobuild) -o ./bin/armada-load-tester cmd/armada-load-tester/main.go diff --git a/scripts/add-checksum-summary.sh b/scripts/add-checksum-summary.sh new file mode 100755 index 00000000000..804bc55b36b --- /dev/null +++ b/scripts/add-checksum-summary.sh @@ -0,0 +1,42 @@ +API_TOKEN=$1 +RELEASE_TAG=$2 + +RELEASE_INFO_REPLY=$(curl --fail -H "Authorization: token $API_TOKEN" https://api.github.com/repos/G-Research/armada/releases/tags/$RELEASE_TAG) + +if [ $? -ne 0 ]; then + echo "Failed to get release information from Github" + exit -1 +fi + +RELEASE_ID=$(echo $RELEASE_INFO_REPLY | jq -r '.id') + +if [ $RELEASE_ID = null ]; then + echo "Failed to get id of release with tag $RELEASE_TAG" + exit -1 +fi + +BODY=$(echo $RELEASE_INFO_REPLY | jq '.body') + +if [ "$BODY" = null ]; then + echo "Failed to get body of release with tag $RELEASE_TAG" + exit -1 +fi + +BODY="${BODY:1:${#BODY}-2}" +echo $BODY + +DETAILS="$BODY" +DETAILS="${DETAILS}\n# Checksums" + +for artifact in ./dist/*; do + SHA=$(sha256sum "${artifact}" | cut -d " " -f 1) + DETAILS="${DETAILS}\n" + DETAILS="${DETAILS}* $(basename $artifact) SHA256 \`$SHA\`" +done + +JSON_STRING="{\"body\" : \"$DETAILS\"}" + +echo "$JSON_STRING" + + +curl -H "Authorization: token $API_TOKEN" -X PATCH https://api.github.com/repos/G-Research/armada/releases/$RELEASE_ID --data "$JSON_STRING" diff --git a/scripts/upload-github-release-asset.sh b/scripts/upload-github-release-asset.sh new file mode 100755 index 00000000000..82f141accf6 --- /dev/null +++ b/scripts/upload-github-release-asset.sh @@ -0,0 +1,29 @@ +API_TOKEN=$1 +RELEASE_TAG=$2 +FILE=$3 + +if [ ! -f $FILE ]; then + echo "Could not find file to upload, $FILE is not a valid file path" + exit -1 +fi + +RELEASE_INFO_REPLY=$(curl --fail -H "Authorization: token $API_TOKEN" https://api.github.com/repos/G-Research/armada/releases/tags/$RELEASE_TAG) + +if [ $? -ne 0 ]; then + echo "Failed to get release information from Github" + exit -1 +fi + +RELEASE_ID=$(echo $RELEASE_INFO_REPLY | jq -r '.id') + +if [ $RELEASE_ID = null ]; then + echo "Failed to get id of release with tag $RELEASE_TAG" + exit -1 +fi + +curl --fail -H "Authorization: token $API_TOKEN" -H "Content-Type: application/octet-stream" --data-binary @$FILE "https://uploads.github.com/repos/G-Research/armada/releases/$RELEASE_ID/assets?name=$(basename $FILE)" + +if [ $? -ne 0 ]; then + echo "Failed to upload file to Github" + exit -1 +fi