From 655097e2a2f6c8615a37643afe0a5b853cf5ec62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 15 Apr 2021 11:20:31 +0200 Subject: [PATCH] ci: add ability to create draft GitHub releases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a `Publish` stage to the combined `Jenkinsfile` which when the `PUBLISH` parameters is true pushes a __draft__ release to GitHub. The job remembers the last value of `PUBLISH` parameter selected. The release uses the contents of the `VERSION` file at the root of the repo as the name for the release, and leaves the contents to be filled in by whoever will approve the release. The automation overwrites - or to be exact, deletes and recreates - the release, so releated builds for the same release will simply re-create it. All the built artifacts are included in the release. Signed-off-by: Jakub SokoĊ‚owski --- VERSION | 2 +- ci/Jenkinsfile.combined | 26 +++++++++++++++++++++++++- ci/Jenkinsfile.linux | 2 +- ci/Jenkinsfile.macos | 2 +- ci/Jenkinsfile.windows | 2 +- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 49b07884e1..984c3f31ee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -beta.8 +0.1.0-beta.9 diff --git a/ci/Jenkinsfile.combined b/ci/Jenkinsfile.combined index 51300599da..ef006b2790 100644 --- a/ci/Jenkinsfile.combined +++ b/ci/Jenkinsfile.combined @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.11' +library 'status-jenkins-lib@v1.2.12' pipeline { agent { label 'linux' } @@ -16,6 +16,14 @@ pipeline { )) } + parameters { + booleanParam( + name: 'PUBLISH', + description: 'Trigger publishing of build results to GitHub.', + defaultValue: getPublishDefault(params.PUBLISH), + ) + } + stages { stage('Build') { parallel { @@ -59,5 +67,21 @@ pipeline { jenkins.setBuildDesc(urls) } } } + stage('Publish') { + when { expression { params.PUBLISH } } + steps { script { + github.publishReleaseFiles(repo: 'status-desktop'); + } } + } } } + +/* Helper that makes PUBLISH default to 'false' unless: + * - The build is for a release branch + * - A user explicitly specified a value + * Since release builds create and re-create GitHub drafts every time. */ +def Boolean getPublishDefault(Boolean previousValue) { + if (env.JOB_NAME.startsWith('status-desktop/release')) { return true } + if (previousValue != null) { return previousValue } + return false +} diff --git a/ci/Jenkinsfile.linux b/ci/Jenkinsfile.linux index bc2f4c9f35..ad2b7b756c 100644 --- a/ci/Jenkinsfile.linux +++ b/ci/Jenkinsfile.linux @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.11' +library 'status-jenkins-lib@v1.2.12' pipeline { agent { diff --git a/ci/Jenkinsfile.macos b/ci/Jenkinsfile.macos index 4ef7e78ebf..990f715760 100644 --- a/ci/Jenkinsfile.macos +++ b/ci/Jenkinsfile.macos @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.11' +library 'status-jenkins-lib@v1.2.12' pipeline { agent { diff --git a/ci/Jenkinsfile.windows b/ci/Jenkinsfile.windows index c8eda2ba1a..1ef8617fef 100644 --- a/ci/Jenkinsfile.windows +++ b/ci/Jenkinsfile.windows @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.11' +library 'status-jenkins-lib@v1.2.12' pipeline { agent { label 'windows' }