-
Notifications
You must be signed in to change notification settings - Fork 89
Add Bump-version action #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
daniel-jones-dev
wants to merge
2
commits into
main
Choose a base branch
from
bump-version-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| # 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: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| 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 | ||
|
|
||
| outputs: | ||
| version: ${{ steps.bump.outputs.current-version }} | ||
| pr-number: ${{ steps.create_pr.outputs.pull-request-number }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup Python environment | ||
| uses: astral-sh/setup-uv@v6 | ||
|
|
||
| - 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@v2 | ||
| 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@v2 | ||
| with: | ||
| command: query | ||
| version: latest | ||
|
|
||
| - name: Configure Git | ||
| id: git_setup | ||
| run: | | ||
| # Configure Git user | ||
| git config --global user.name "${{ github.actor }}" | ||
| git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | ||
|
|
||
| - name: Create version commit | ||
| id: create_commit | ||
| run: | | ||
| git add . | ||
| git commit -m "docs: Increase version to ${{ steps.bump.outputs.current-version }} (${{ inputs.bump-type }} bump)" | ||
| echo "::notice::Commit created, will be pushed via pull request" | ||
|
|
||
| - name: Create Pull Request | ||
| id: create_pr | ||
| uses: peter-evans/create-pull-request@v7 | ||
| with: | ||
| 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 | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.