Set Version of develop to 2.1.0-SNAPSHOT because #21
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
# This sets a new version number in the pom.xml files, and commits the changes. | |
name: Set Version | |
run-name: Set Version of ${{ github.ref_name }} to ${{ inputs.version }} because ${{ inputs.remark }} | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'The new version to set in the pom.xml' | |
required: true | |
remark: | |
description: 'Optional, a remark to add to the commit message' | |
required: false | |
jobs: | |
update-version: | |
runs-on: ubuntu-latest | |
env: | |
SUBDIR: ${{ github.event.inputs.subdir }} | |
MVNCMD: mvn -B -ntp -s ${{ github.workspace }}/.github/settings-public.xml -P allmodules | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
maven-version: 3.8.7 | |
cache: maven | |
- name: Dump event context for debugging | |
continue-on-error: true # Debugging output only, and this annoyingly fails when the commit messge has a ( | |
run: | | |
echo '${{ github.event_name }} for ${{ github.ref_type }} ${{ github.ref_name }} or ${{ github.event.ref }}' | |
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push | |
echo 'github.event:' | |
echo '${{ toJSON(github.event) }}' | |
- name: Dump github context | |
continue-on-error: true # Debugging output only, and this annoyingly fails when the commit message has a ( | |
run: | | |
echo '${{ toJSON(github) }}' | |
- name: Git & Maven Status | |
run: | | |
git status --untracked-files --ignored | |
git log -3 --no-color | |
$MVNCMD -version | |
- name: Mvn Effective POM | |
run: $MVNCMD -N help:effective-pom | |
- name: Mvn Effective Settings | |
run: $MVNCMD -N help:effective-settings | |
- name: Set new version | |
run: | | |
$MVNCMD versions:set -DnewVersion=${{ github.event.inputs.version }} -DgenerateBackupPoms=false -DprocessAllModules=true | |
- name: Print new versions in submodules | |
run: | | |
echo "Parent version is now: " | |
$MVNCMD -N help:evaluate -Dexpression=project.version -q -DforceStdout | |
echo "Version count from the submodules. Everything should be like parent version: " | |
for pom in $(find . -name pom.xml | fgrep -v /target/); do $MVNCMD -f $pom -N help:evaluate -Dexpression=project.version -q -DforceStdout; echo; done | sort | uniq -c | sort -nr | |
- name: Print changes | |
run: | | |
git status -v | |
git diff | |
git diff --cached | |
- name: Commit changes | |
run: | | |
git config user.name "github-actions setversion for ${{ github.event.sender.login }}" | |
git config user.email github-actions@github.com | |
git commit -a -m "Update version to ${{ github.event.inputs.version }} ${{ inputs.remark }}" | |
- name: Git Status after setting the version | |
run: | | |
git status | |
git log -3 --no-color | |
- name: Push changes | |
run: | | |
git push |