From e503c97266f2c7a7e7feeb56be43c78de1a6d992 Mon Sep 17 00:00:00 2001 From: Reguel Wermelinger Date: Mon, 25 Nov 2024 16:37:03 +0100 Subject: [PATCH] automate release-drafter publishing - automatically publish new releases on new tags being created with semantic versions (v0.0.0) - separate release/trains via 'commitish' without actually requiring multiple drafter templates --- .github/release-drafter-lts12.yml | 42 ----------------------- .github/release-drafter.yml | 2 -- .github/workflows/draft-publisher.yml | 49 +++++++++++++++++++++++++++ .github/workflows/release-drafter.yml | 1 + .github/workflows/tag-publisher.yml | 29 ++++++++++++++++ README.md | 29 ++-------------- 6 files changed, 81 insertions(+), 71 deletions(-) delete mode 100644 .github/release-drafter-lts12.yml create mode 100644 .github/workflows/draft-publisher.yml create mode 100644 .github/workflows/tag-publisher.yml diff --git a/.github/release-drafter-lts12.yml b/.github/release-drafter-lts12.yml deleted file mode 100644 index db2bf7bc..00000000 --- a/.github/release-drafter-lts12.yml +++ /dev/null @@ -1,42 +0,0 @@ -name-template: 'v$RESOLVED_VERSION ๐Ÿ‘จโ€๐Ÿ”ง' -tag-template: 'v$RESOLVED_VERSION' -filter-by-commitish: true -commitish: release/12.0 -categories: - - title: '๐Ÿš€ Features' - labels: - - 'feature' - - 'enhancement' - - title: '๐Ÿ› Bug Fixes' - labels: - - 'fix' - - 'bugfix' - - 'bug' - - title: '๐Ÿ“ฆ Dependencies' - label: 'dependencies' - - title: โš ๏ธ Changes - labels: - - deprecated - - title: ๐Ÿ“„ Documentation - labels: - - docs - - documentation -exclude-labels: - - 'skip-changelog' -change-template: '- $TITLE @$AUTHOR (#$NUMBER)' -change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. -version-resolver: - major: - labels: - - 'major' - minor: - labels: - - 'minor' - patch: - labels: - - 'patch' - default: patch -template: | - ## Changes - - $CHANGES diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index dffa06fc..fc270fcd 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,7 +1,5 @@ name-template: 'v$RESOLVED_VERSION ๐Ÿงช' tag-template: 'v$RESOLVED_VERSION' -filter-by-commitish: false -commitish: master categories: - title: '๐Ÿš€ Features' labels: diff --git a/.github/workflows/draft-publisher.yml b/.github/workflows/draft-publisher.yml new file mode 100644 index 00000000..b699cb9f --- /dev/null +++ b/.github/workflows/draft-publisher.yml @@ -0,0 +1,49 @@ +name: Release Publisher + +on: + workflow_call: + inputs: + publish: + required: false + default: true + type: boolean + version: + required: true + type: string + +permissions: + contents: read + +jobs: + publish_release: + permissions: + contents: write + pull-requests: read + runs-on: ubuntu-latest + steps: + - name: Set version env + run: | + RELEASE_VERSION="${{ inputs.version }}"; + if [ -z "$RELEASE_VERSION" ]; then + RELEASE_VERSION="${GITHUB_REF#refs/*/}" + fi; + echo RELEASE_VERSION=$RELEASE_VERSION >> $GITHUB_ENV + + MINOR=${RELEASE_VERSION%.*} + MINOR=${MINOR#v} + TARGET=release/${MINOR} + if [[ "${GITHUB_REF#refs/*/}" -eq "master" ]]; then + TARGET="master" + fi + echo RELEASE_TARGET=$TARGET >> $GITHUB_ENV + - uses: release-drafter/release-drafter@v6 + with: + config-name: release-drafter.yml + disable-autolabeler: true + name: ${{ env.RELEASE_VERSION }} + tag: ${{ env.RELEASE_VERSION }} + version: ${{ env.RELEASE_VERSION }} + commitish: ${{ env.RELEASE_TARGET }} + publish: ${{ inputs.publish }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index a9fb1660..923f5b4d 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -30,5 +30,6 @@ jobs: - uses: release-drafter/release-drafter@v6 with: config-name: release-drafter.yml + commitish: ${{ github.ref }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tag-publisher.yml b/.github/workflows/tag-publisher.yml new file mode 100644 index 00000000..801dba7a --- /dev/null +++ b/.github/workflows/tag-publisher.yml @@ -0,0 +1,29 @@ +name: Tag Publisher + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + inputs: + tag: + type: string + description: the tag-ref to release e.g. 'v12.0.0' + publish: + type: boolean + default: false + description: publish the drafted release as final version? + + +permissions: + contents: write + pull-requests: read + +jobs: + build: + uses: ./.github/workflows/draft-pub.yml + with: + version: ${{ inputs.tag }} + # The 'publish' input parameter is used to control whether the release should be published automatically. + # Uncomment and set to 'false' if you want to prevent the release from being published immediately. + publish: ${{ inputs.publish == null && true || inputs.publish }} diff --git a/README.md b/README.md index 32f12a44..3c653f0d 100644 --- a/README.md +++ b/README.md @@ -43,35 +43,10 @@ Since 9.4: Releasing is only possible on a release branch. Wait until the maven central release is available: this may take several hours until it's fully distributed. -- Publish the latest [draft release](https://github.com/axonivy/project-build-plugin/releases) do preserve the current changelog. - - - Select the tag which was created for this release by the release-pipeline - - Verify that the title is correct - - Set the release as 'latest release' - - Publish it - - Release-Drafter changes, if a new-release train was introduced: - - on `master` branch: - - - add a new release-drafter template for this new release by duplicating the existing and adding a release postfix e.g.`.github/release-drafter-lts14.yml` - - - adjust the content of the duplicated file: - - ```yaml - filter-by-commitish: true - commitish: release/14.0 - ``` - - - on the release branch: - - - change the `.github/workflow/release-drafter.yml` to listen only for changes from ~~master~~ to `release/XYZ` and refer the new template from master by name in the [config-name](.github/workflow/release-drafter.yml#32) part (e.g. `release-drafter-lts14.yml` ) - - - on github UI (PR View): - - - flag the latest PR which was only merged to master with the label `major` - - - ... now release-drafter action runs should create new draft PRs for the new release; without overwriting the existing master drafts. + - on github UI (PR View): flag the latest PR which was only merged to master with the label `major`. + ... now release-drafter action runs should create new draft PRs for the new release; without overwriting the existing master drafts. - Raise project-build-plugin in other repos by triggering this [build](https://jenkins.ivyteam.io/view/jobs/job/github-repo-manager_raise-build-plugin-version/job/master/)