Prepare new tag & changelog PR #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Authors: Madhavan Sridharan, Ted Willke | |
name: Prepare new tag & changelog PR | |
# runs on | |
# * manually triggered | |
on: | |
workflow_dispatch: | |
inputs: | |
tag_version: | |
description: 'Tag version to create (e.g. X.Y.Z-beta.M)' | |
required: true | |
new_revision: | |
description: 'New revision to update in pom.xml (e.g. X.Y.Z-beta.N-SNAPSHOT)' | |
required: true | |
# global env vars, available in all jobs and steps | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
new_tag_and_changelog: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Git config | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
- name: Update revision in pom.xml for release | |
run: | | |
sed -i 's|<revision>.*</revision>|<revision>${{ github.event.inputs.tag_version }}</revision>|' ./pom.xml | |
git add ./pom.xml | |
git commit -m "chore (release): Set release version to ${{ github.event.inputs.tag_version }}" | |
# Note: the tag version will be pushed right away at this step prior to changelog pr merging | |
- name: Create and push tag | |
run: | | |
git tag -a "${{ github.event.inputs.tag_version }}" -m "Release tag version ${{ github.event.inputs.tag_version }}" | |
git push origin "${{ github.event.inputs.tag_version }}" | |
- name: Generate changelog | |
continue-on-error: true | |
run: ./update_changelog.sh | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v7 | |
env: | |
GITHUB_TOKEN: | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: "release/bump-tag-version-and-update-changelog" | |
branch-suffix: "short-commit-hash" | |
base: "main" | |
title: "chore(release): Bump tag version and update changelog" | |
commit-message: "chore(release): Bump tag version and update changelog" | |
body: | | |
This pull request does the following as part of the release process, | |
- bumps the tag version to ${{ github.event.inputs.tag_version }} | |
- updates changelog to include changes for current release | |
- bumps the revision in pom.xml to ${{ github.event.inputs.tag_version }} | |
Please review and merge. | |
- name: Clean workspace and checkout base branch | |
run: | | |
git checkout main | |
git reset --hard origin/main # Ensure we are clean relative to remote main | |
- name: Create branch for next development version | |
run: | | |
git checkout -b "release/bump-version-to-${{ github.event.inputs.new_revision }}" main | |
- name: Update revision in pom.xml for next development version | |
run: | | |
sed -i 's|<revision>.*</revision>|<revision>${{ github.event.inputs.new_revision }}</revision>|' ./pom.xml | |
git add ./pom.xml | |
git commit -m "chore(release): Bump version to ${{ github.event.inputs.new_revision }} for continued development" | |
- name: Push the new version branch # Ensure remote state matches local commit | |
run: | | |
git push --force-with-lease --set-upstream origin "release/bump-version-to-${{ github.event.inputs.new_revision }}" | |
- name: Create pull request for version bump | |
uses: peter-evans/create-pull-request@v7 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
branch: "release/bump-version-to-${{ github.event.inputs.new_revision }}" | |
base: "main" | |
title: "chore(release): Bump version to ${{ github.event.inputs.new_revision }} for development" | |
body: | | |
This pull request updates the pom.xml version to ${{ | |
github.event.inputs.new_revision }} to start development for the next release. |