From e2481fb5102a3e84fdace97a0490883a0d2dd862 Mon Sep 17 00:00:00 2001 From: Stefan Benten Date: Tue, 30 Nov 2021 20:50:56 +0100 Subject: [PATCH] scripts,Jenkinsfile,Makefile: upload binaries to drafted github release This change adds a script and the needed build logic to create a draft github release and then upload the created binaries to it in order to make the actual publishing a lot less error prone. The logic is currently that it only does this for all github tags, but not for every main build/push. This is handled by the checks in the script itself. Change-Id: Ie172a8e4a97200de901a26a055aa5a8a54b60a2a --- Jenkinsfile | 8 ++++++++ Makefile | 5 +++++ scripts/draft-release.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100755 scripts/draft-release.sh diff --git a/Jenkinsfile b/Jenkinsfile index 5daa0370f..ced1c6b98 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,6 +135,14 @@ node('node') { echo "Current build result: ${currentBuild.result}" } + stage('Draft Release') { + withCredentials([string(credentialsId: 'GITHUB_RELEASE_TOKEN', variable: 'GITHUB_TOKEN')]) { + lastStage = env.STAGE_NAME + sh 'make draft-release' + + echo "Current build result: ${currentBuild.result}" + } + } } catch (err) { diff --git a/Makefile b/Makefile index 4613f5bcc..5f521766a 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,7 @@ build-dev-deps: ## Install dependencies for builds go get golang.org/x/tools/cover go get github.com/go-bindata/go-bindata/go-bindata go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo + go get github.com/github-release/github-release .PHONY: lint lint: ## Analyze and find programs in source code @@ -370,6 +371,10 @@ binaries-upload: ## Upload binaries to Google Storage (jenkins) ; done cd "release/${TAG}"; gsutil -m cp -r *.zip "gs://storj-v3-alpha-builds/${TAG}/" +.PHONY: draft-release +draft-release: + scripts/draft-release.sh ${BRANCHNAME} "release/${TAG}" + ##@ Clean .PHONY: clean diff --git a/scripts/draft-release.sh b/scripts/draft-release.sh new file mode 100755 index 000000000..5cbc97b2f --- /dev/null +++ b/scripts/draft-release.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# usage: $0 vMAJOR.MINOR.PATCH[-rc[-*]] PATH/TO/BINARIES + +set -euo pipefail + +apps="identity uplink storagenode multinode" + +TAG="${1-}" + +if ! [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc+(-.*)?)?$ ]]; then + echo "No tag detected, skipping release drafting" + exit 0 +fi + +FOLDER="${2-}" + +echo "Drafting release" +github-release release --user storj --repo storj --tag "$TAG" --draft + +echo "Uploading binaries to release draft" +for app in $apps; +do + for file in "$FOLDER/$app"*.zip + do + github-release upload --user storj --repo storj --tag "$TAG" --name $(basename "$file") --file "$file" + done +done +echo "Drafting release done"