From a83f0493c5c8c24edf986752910d5c2bf9039616 Mon Sep 17 00:00:00 2001 From: Justin Brooks Date: Sun, 12 Jan 2025 22:19:52 -0500 Subject: [PATCH] Add a workflow to update the changelog --- .github/workflows/publish.yml | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2bdd643 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,68 @@ +name: publish + +on: + release: + types: [released] + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Fetch Sources + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name }} + + - name: Set up a JDK + id: setup-jdk + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: zulu + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + # Set environment variables + - name: Export Properties + id: properties + shell: bash + run: | + CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d' + ${{ github.event.release.body }} + EOM + )" + + echo "changelog<> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + # Update Unreleased section with the current release note + - name: Patch Changelog + if: ${{ steps.properties.outputs.changelog != '' }} + env: + CHANGELOG: ${{ steps.properties.outputs.changelog }} + run: | + ./gradlew patchChangelog --release-note="$CHANGELOG" + + - name: Open PR for Changelog Update + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION="${{ github.event.release.tag_name }}" + BRANCH="changelog-update-$VERSION" + git config user.name github-actions + git config user.email github-actions@github.com + git checkout -b $BRANCH + git commit -am "Changelog update - $VERSION" + git push --set-upstream origin $BRANCH + gh pr create \ + --title "Changelog update - \`$VERSION\`" \ + --body "Current pull request contains patched \`changelog.md\` file for the \`$VERSION\` version." \ + --base master \ + --head $BRANCH