Skip to content

Bump version

Bump version #2

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
echo "CONNECT_OLD_RELEASE_VERSION=$(./mvnw -f connect help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
sed -i "s/<revision>.*<\/revision>/<revision>$(${{ env.CONNECT_OLD_RELEASE_VERSION }} | awk -F'.' '{print $1"."$2+1"."$3}' | 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>/" connect/pom.xml
- name: BUMP PLATFORM VERSION / Raise mvn version
if: inputs.platform-new-maven-version == '' && inputs.platform-bump-version == true
run: |
# increment minor version
echo "PLATFORM_OLD_RELEASE_VERSION=$(./mvnw -f platform help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
sed -i "s/<revision>.*<\/revision>/<revision>$(${{ env.PLATFORM_OLD_RELEASE_VERSION }} | awk -F'.' '{print $1"."$2+1"."$3}' | 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}`);