v0.4.0.13 #11
Workflow file for this run
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: | |
release: | |
types: [ released ] | |
workflow_dispatch: | |
inputs: | |
release_tag: | |
description: 'Use release notes of' | |
type: string | |
required: false | |
jobs: | |
bump-version: | |
name: Bump version and update changelog | |
runs-on: ubuntu-latest | |
steps: | |
# Setup environment | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: temurin | |
# Fail if the release was not triggered from the master branch | |
- name: Verify branch | |
if: github.event_name == 'release' | |
run: | | |
if \ | |
git fetch --depth=1 origin refs/heads/master && \ | |
[ "$(git show-ref -s refs/heads/master)" != "$(git show-ref -s HEAD)" ] | |
then | |
msg="The release does not point to the master branch. This means the" | |
msg="$msg branch has been updated after the release, or the release" | |
msg="$msg was created on a different branch. Please trigger this" | |
msg="$msg workflow manually on the correct branch." | |
echo "::error::$msg" | |
exit 1 | |
fi | |
# Setup cache | |
- name: Setup cache for Gradle and dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: "gradle-\ | |
${{runner.os}}-\ | |
${{hashFiles('gradle/wrapper/gradle-wrapper.properties')}}-\ | |
${{hashFiles('gradle.properties', '**/*.gradle.kts')}}" | |
# Update files | |
- name: Obtain release notes | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
await require('.github/scripts/get-release-notes.js')({ | |
github, context, core, | |
outputFile: 'release_note.md', | |
releaseTagInput: 'release_tag', | |
allowFallbackToLatest: true, | |
}); | |
- name: Update files with Gradle | |
run: ./gradlew --stacktrace metadata patchChangelog --release-note="$(<release_note.md)" bumpVersion | |
# Commit and push | |
- name: Commit files | |
run: | | |
version="$(cat build/metadata/version.txt)" | |
git -c user.name='github-actions[bot]' \ | |
-c user.email='41898282+github-actions[bot]@users.noreply.github.com' \ | |
commit -am "Bump version after releasing v$version" | |
- name: Push changes | |
env: | |
BASE_COMMIT: ${{ github.sha }} | |
TARGET_BRANCH: ${{ github.event_name == 'release' && 'refs/heads/master' || github.ref }} | |
run: | | |
git push origin \ | |
--force-with-lease="$TARGET_BRANCH:$BASE_COMMIT" \ | |
"HEAD:$TARGET_BRANCH" |