Skip to content

Bump Version

Bump Version #2

Workflow file for this run

# GitHub action to bump version, update changelog, and create pull request for review.
name: Bump Version
run-name: Bump version (${{ inputs.bump-type }}) by @${{ github.actor }}
# Note: Enable GitHub Actions to create pull requests in repository settings:
# Settings -> Actions -> General -> Workflow permissions -> Allow GitHub Actions to create and approve pull requests
permissions: {}
concurrency:
group: bumpversion
cancel-in-progress: false
on:
workflow_dispatch:
inputs:
bump-type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
fail-on-empty-changelog:
description: 'Fail if changelog is empty'
required: false
default: true
type: boolean
jobs:
bump_version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
version: ${{ steps.bump.outputs.current-version }}
pr-number: ${{ steps.create_pr.outputs.pull-request-number }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 https://github.com/actions/checkout/releases/tag/v6.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python environment
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 https://github.com/astral-sh/setup-uv/releases/tag/v7.6.0
- name: Install bump-my-version
run: uv tool install bump-my-version
- name: Bump version
id: bump
shell: bash
run: |
echo "::notice::Bumping version with type: ${{ inputs.bump-type }}"
bump-my-version bump ${{ inputs.bump-type }}
CURRENT_VERSION=$(bump-my-version show current_version)
echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "::notice::Current version: $CURRENT_VERSION"
- name: Update changelog
id: changelog
uses: release-flow/keep-a-changelog-action@74931dec7ecdbfc8e38ac9ae7e8dd84c08db2f32 # v3.0.0 https://github.com/release-flow/keep-a-changelog-action/releases/tag/v3.0.0
with:
command: bump
version: ${{ inputs.bump-type }}
keep-unreleased-section: true
fail-on-empty-release-notes: ${{ inputs.fail-on-empty-changelog }}
- name: Query changelog for release notes
id: query_changelog
uses: release-flow/keep-a-changelog-action@74931dec7ecdbfc8e38ac9ae7e8dd84c08db2f32 # v3.0.0 https://github.com/release-flow/keep-a-changelog-action/releases/tag/v3.0.0
with:
command: query
version: latest
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 https://github.com/peter-evans/create-pull-request/releases/tag/v8.1.0
with:
commit-message: "chore: bump version to ${{ steps.bump.outputs.current-version }} (${{ inputs.bump-type }} bump)"
title: "Bump version to ${{ steps.bump.outputs.current-version }} (${{ inputs.bump-type }} bump)"
body: |
This PR **${{ inputs.bump-type }}** bumps the version to `${{ steps.bump.outputs.current-version }}` and updates the changelog.
### Reviewer Checklist
Please verify the following before merging:
- [ ] **Version bump type is appropriate**: Confirm that the `${{ inputs.bump-type }}` bump matches the nature of changes since the last version:
- **Major**: Breaking changes or significant API modifications
- **Minor**: New features or functionality additions (backward compatible)
- **Patch**: Bug fixes, documentation updates, or minor improvements
- **no bump necessary**: Changes only to tests, CI, documentation, or examples.
If the bump type is not appropriate, close the PR and re-run the workflow with the correct bump type.
- [ ] **Changelog accuracy**: Review that the changelog entries accurately reflect the changes being released, and are understandable to end users.
If not, edit the changelog before merging.
### Next Steps
After merging this PR, **trigger a release** to publish version `${{ steps.bump.outputs.current-version }}`.
### Changelog (automatically extracted from Unreleased section)
${{ steps.query_changelog.outputs.release-notes }}
---
*This PR was automatically created by the Bump Version workflow*
branch: bumpversion-${{ steps.bump.outputs.current-version }}
token: ${{ secrets.GITHUB_TOKEN }}
delete-branch: true
- name: Summary
if: always()
run: |
echo "## Workflow Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Bump Type:** ${{ inputs.bump-type }}" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ steps.bump.outputs.current-version }}" >> $GITHUB_STEP_SUMMARY
if [[ "${{ steps.create_pr.outputs.pull-request-number }}" != "" ]]; then
PR_NUMBER="${{ steps.create_pr.outputs.pull-request-number }}"
PR_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER"
echo "- **Pull Request:** [#$PR_NUMBER]($PR_URL)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
echo "1. Review and merge [Pull Request #$PR_NUMBER]($PR_URL)" >> $GITHUB_STEP_SUMMARY
echo "2. **Trigger a release** to publish version \`${{ steps.bump.outputs.current-version }}\`" >> $GITHUB_STEP_SUMMARY
else
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ⚠️ Warning" >> $GITHUB_STEP_SUMMARY
echo "Pull request creation failed. Please check the workflow logs." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📋 Workflow Details" >> $GITHUB_STEP_SUMMARY
echo "- **Triggered by:** @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
echo "- **Repository:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
echo "- **Run ID:** [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY