Commit automation
If you’re working with a Pull Request-based workflow on GitHub, you can automate the process of creating a release PR which commits all pending bumps. The PR will be kept up to date with any new bumps that are merged to the main branch and only when you are ready to cut a release would you merge this PR.
Here’s what a sample GitHub Actions workflow could look like to achieve this:
name: Release PR
on: workflow_dispatch: push: branches: - main paths: [.bumper/bump-*.md]
jobs: upsert-release-pr: runs-on: ubuntu-latest permissions: contents: write pull-requests: write
steps: - name: Checkout repository uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0
- name: Set up Mise uses: jdx/mise-action@be3be2260bc02bc3fbf94c5e2fed8b7964baf074 # v3.4.0 with: mise_toml: | [tools] "github:disintegrator/bumper" = "latest"
- name: Commit pending bumps id: bumper run: | groups=$(mise bumper commit) if [ -z "$groups" ]; then echo "No pending bumps to commit. Exiting." exit 0 fi
# Build a nice release notes file to use as the PR description notes_file="$(mktemp)" for group in $groups; do latest_version=$(mise bumper current --group "$group") mise bumper cat --group "$group" --version "$latest_version" >> "$notes_file" echo "" >> "$notes_file" done
echo "committed=true" >> $GITHUB_OUTPUT echo "notes_file=$notes_file" >> $GITHUB_OUTPUT
- name: Create Pull Request uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 if: ${{ steps.bumper.outputs.committed == 'true' }} with: token: ${{ secrets.GITHUB_TOKEN }} sign-commits: true commit-message: "chore: bumper commit" branch: gha/bumper-release delete-branch: true title: "chore: release packages" body-path: ${{ steps.bumper.outputs.notes_file }}