Bump version #6
This file contains 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
name: Bump version | |
on: | |
workflow_call: | |
inputs: | |
connect-bump-version: | |
description: 'Bump connect version?' | |
type: boolean | |
default: true | |
connect-new-maven-version: | |
description: 'Connect new maven version' | |
type: string | |
required: false | |
platform-bump-version: | |
description: 'Bump platform version?' | |
type: boolean | |
default: true | |
platform-new-maven-version: | |
description: 'Platform new maven version' | |
type: string | |
required: false | |
workflow_dispatch: | |
inputs: | |
connect-bump-version: | |
description: 'Bump connect version?' | |
type: boolean | |
default: true | |
connect-new-maven-version: | |
description: 'Connect new maven version' | |
type: string | |
required: false | |
platform-bump-version: | |
description: 'Bump platform version?' | |
type: boolean | |
default: true | |
platform-new-maven-version: | |
description: 'Platform new maven version' | |
type: string | |
required: false | |
jobs: | |
bump-versions: | |
name: Bumps versions | |
runs-on: ubuntu-latest | |
steps: | |
- name: PREP / Checkout code | |
uses: actions/checkout@v4 | |
- name: PREP / Setup git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Miranum Github Bot" | |
- name: PREP / Prepare mvnw | |
run: chmod +x ./mvnw | |
- name: PREP / Install Java and Maven | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
- name: BUMP CONNECT VERSION / Raise mvn version | |
if: inputs.connect-new-maven-version != '' && inputs.connect-bump-version == true | |
run: | | |
sed -i "s/<revision>.*<\/revision>/<revision>${{ inputs.connect-new-maven-version }}-SNAPSHOT<\/revision>/" connect/pom.xml | |
- name: BUMP CONNECT VERSION / Raise mvn version | |
if: inputs.connect-new-maven-version == '' && inputs.connect-bump-version == true | |
run: | | |
# increment minor version | |
sed -i "s/<revision>.*<\/revision>/<revision>$(./mvnw -f connect help:evaluate -Dexpression=project.version -q -DforceStdout | awk -F'.' '{print $1"."$2+1".0-SNAPSHOT"}' | sed s/[.]$//)<\/revision>/" connect/pom.xml | |
- name: GIT / Git commit | |
if: inputs.connect-bump-version == true | |
run: | | |
git add . | |
git commit -m "chore: mvn auto version bump connect to $(./mvnw -f connect help:evaluate -Dexpression=project.version -q -DforceStdout)" | |
- name: BUMP PLATFORM VERSION / Raise mvn version | |
if: inputs.platform-new-maven-version != '' && inputs.platform-bump-version == true | |
run: | | |
sed -i "s/<revision>.*<\/revision>/<revision>${{ inputs.platform-new-maven-version }}-SNAPSHOT<\/revision>/" platform/pom.xml | |
- name: BUMP PLATFORM VERSION / Raise mvn version | |
if: inputs.platform-new-maven-version == '' && inputs.platform-bump-version == true | |
run: | | |
# increment minor version | |
sed -i "s/<revision>.*<\/revision>/<revision>$(./mvnw -f platform help:evaluate -Dexpression=project.version -q -DforceStdout | awk -F'.' '{print $1"."$2+1".0-SNAPSHOT"}' | sed s/[.]$//)<\/revision>/" platform/pom.xml | |
- name: GIT / Git commit | |
if: inputs.platform-bump-version == true | |
run: | | |
git add . | |
git commit -m "chore: mvn auto version bump platform to $(./mvnw -f platform help:evaluate -Dexpression=project.version -q -DforceStdout)" | |
- name: GIT / Push changes to new branch | |
if: inputs.platform-bump-version == true || inputs.connect-bump-version == true | |
run: | | |
git checkout -b ${{ github.ref_name }}-version-bump | |
git push --force origin ${{ github.ref_name }}-version-bump | |
- name: GIT / Create pull request | |
uses: actions/github-script@v7 | |
if: inputs.platform-bump-version == true || inputs.connect-bump-version == true | |
with: | |
script: | | |
const { repo, owner } = context.repo; | |
const pullResult = await github.rest.pulls.create({ | |
title: 'chore: bump release version ${{ github.ref_name }}', | |
owner, | |
repo, | |
head: '${{ github.ref_name }}-version-bump', | |
base: '${{ github.ref_name }}', | |
body: [ | |
'This PR is auto-generated' | |
].join('\n') | |
}); | |
await github.rest.issues.addAssignees({ | |
owner, | |
repo, | |
issue_number: pullResult.data.number, | |
assignees: ['${{ github.actor }}'], | |
}); | |
console.log(`Pull Request created: ${pullResult.data.html_url}`); |