Skip to content

Prepare release branch #6

Prepare release branch

Prepare release branch #6

name: Prepare release branch
on:
workflow_dispatch:
inputs:
version_part:
description: The part of the version to update (Patch, Minor or Major)
required: true
type: choice
options:
- Patch
- Minor
- Major
default: 'Minor'
jobs:
prepare-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Validate inputs
run: |
echo "INPUT_VERSION_PART: ${{ github.event.inputs.version_part }}"
python -c "if '${{ github.event.inputs.version_part }}' not in ['Patch', 'Minor', 'Major']: raise ValueError(\"'${{ github.event.inputs.version_part }}' must be one of ['Patch', 'Minor', 'Major'])\")"
- name: Save current version
id: save_current_version
run: |
mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
echo "::set-output name=current_version::$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)"
- name: Update the CHANGELOG according to 'Keep a Changelog' guidelines
uses: thomaseizinger/keep-a-changelog-new-release@v1
with:
version: ${{ steps.save_current_version.outputs.current_version }}
- name: Create a new release branch
run: |
git config user.name github-actions
git config user.email [email protected]
git commit -am "Bump CHANGELOG for release ${{ steps.save_current_version.outputs.current_version }}"
git checkout -b release/${{ steps.save_current_version.outputs.current_version }}
git push -u origin release/${{ steps.save_current_version.outputs.current_version }}
- name: Bump development version
run: |
git checkout -b bump-version-after-${{ steps.save_current_version.outputs.current_version }}
mvn validate -D 'bump${{ github.event.inputs.version_part }}' -DgenerateBackupPoms=false
git commit -am "Bump development version to $(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)"
git push -u origin bump-version-after-${{ steps.save_current_version.outputs.current_version }}
- name: Open a PR to bump development version to main
id: open_pr
uses: vsoch/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_BRANCH: main
PULL_REQUEST_FROM_BRANCH: bump-version-after-${{ steps.save_current_version.outputs.current_version }}
PULL_REQUEST_TITLE: "Bump development version after release of ${{ steps.save_current_version.outputs.current_version }}"
PULL_REQUEST_BODY: "Bump SNAPSHOT version and CHANGELOG for subsequent development."