Skip to content

v0.4.0.11

v0.4.0.11 #24

Workflow file for this run

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@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: adopt
# 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@v3
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@v6
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"