Skip to content

Commit 85aec74

Browse files
Merge pull request #140 from DeepLcom/bump-version-action
ci: add bumpversion workflow
2 parents 65fc7e2 + ef2bb9b commit 85aec74

File tree

2 files changed

+145
-1
lines changed

2 files changed

+145
-1
lines changed

.bumpversion.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ replace = "\"{new_version}\" == deepl.__version__"
2323
[[tool.bumpversion.files]]
2424
filename = "pyproject.toml"
2525
search = "name = \"deepl\"\nversion = \"{current_version}\""
26-
replace = "name = \"deepl\"\nversion = \"{new_version}\""
26+
replace = "name = \"deepl\"\nversion = \"{new_version}\""

.github/workflows/bumpversion.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# GitHub action to bump version, update changelog, and create pull request for review.
2+
3+
name: Bump Version
4+
run-name: Bump version (${{ inputs.bump-type }}) by @${{ github.actor }}
5+
6+
# Note: Enable GitHub Actions to create pull requests in repository settings:
7+
# Settings -> Actions -> General -> Workflow permissions -> Allow GitHub Actions to create and approve pull requests
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: bumpversion
13+
cancel-in-progress: false
14+
15+
on:
16+
workflow_dispatch:
17+
inputs:
18+
bump-type:
19+
description: 'Version bump type'
20+
required: true
21+
default: 'patch'
22+
type: choice
23+
options:
24+
- major
25+
- minor
26+
- patch
27+
fail-on-empty-changelog:
28+
description: 'Fail if changelog is empty'
29+
required: false
30+
default: true
31+
type: boolean
32+
33+
jobs:
34+
bump_version:
35+
runs-on: ubuntu-latest
36+
permissions:
37+
contents: write
38+
pull-requests: write
39+
40+
outputs:
41+
version: ${{ steps.bump.outputs.current-version }}
42+
pr-number: ${{ steps.create_pr.outputs.pull-request-number }}
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 https://github.com/actions/checkout/releases/tag/v6.0.2
47+
with:
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Setup Python environment
51+
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 https://github.com/astral-sh/setup-uv/releases/tag/v7.6.0
52+
53+
- name: Install bump-my-version
54+
run: uv tool install bump-my-version
55+
56+
- name: Bump version
57+
id: bump
58+
shell: bash
59+
run: |
60+
echo "::notice::Bumping version with type: ${{ inputs.bump-type }}"
61+
bump-my-version bump ${{ inputs.bump-type }}
62+
63+
CURRENT_VERSION=$(bump-my-version show current_version)
64+
echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
65+
echo "::notice::Current version: $CURRENT_VERSION"
66+
67+
- name: Update changelog
68+
id: changelog
69+
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
70+
with:
71+
command: bump
72+
version: ${{ inputs.bump-type }}
73+
keep-unreleased-section: true
74+
fail-on-empty-release-notes: ${{ inputs.fail-on-empty-changelog }}
75+
76+
- name: Query changelog for release notes
77+
id: query_changelog
78+
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
79+
with:
80+
command: query
81+
version: latest
82+
83+
- name: Create Pull Request
84+
id: create_pr
85+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 https://github.com/peter-evans/create-pull-request/releases/tag/v8.1.0
86+
with:
87+
commit-message: "chore: bump version to ${{ steps.bump.outputs.current-version }} (${{ inputs.bump-type }} bump)"
88+
title: "Bump version to ${{ steps.bump.outputs.current-version }} (${{ inputs.bump-type }} bump)"
89+
body: |
90+
This PR **${{ inputs.bump-type }}** bumps the version to `${{ steps.bump.outputs.current-version }}` and updates the changelog.
91+
92+
### Reviewer Checklist
93+
Please verify the following before merging:
94+
95+
- [ ] **Version bump type is appropriate**: Confirm that the `${{ inputs.bump-type }}` bump matches the nature of changes since the last version:
96+
- **Major**: Breaking changes or significant API modifications
97+
- **Minor**: New features or functionality additions (backward compatible)
98+
- **Patch**: Bug fixes, documentation updates, or minor improvements
99+
- **no bump necessary**: Changes only to tests, CI, documentation, or examples.
100+
101+
If the bump type is not appropriate, close the PR and re-run the workflow with the correct bump type.
102+
103+
- [ ] **Changelog accuracy**: Review that the changelog entries accurately reflect the changes being released, and are understandable to end users.
104+
105+
If not, edit the changelog before merging.
106+
107+
### Next Steps
108+
After merging this PR, **trigger a release** to publish version `${{ steps.bump.outputs.current-version }}`.
109+
110+
### Changelog (automatically extracted from Unreleased section)
111+
${{ steps.query_changelog.outputs.release-notes }}
112+
113+
---
114+
*This PR was automatically created by the Bump Version workflow*
115+
branch: bumpversion-${{ steps.bump.outputs.current-version }}
116+
token: ${{ secrets.GITHUB_TOKEN }}
117+
delete-branch: true
118+
119+
- name: Summary
120+
if: always()
121+
run: |
122+
echo "## Workflow Summary" >> $GITHUB_STEP_SUMMARY
123+
echo "- **Bump Type:** ${{ inputs.bump-type }}" >> $GITHUB_STEP_SUMMARY
124+
echo "- **Version:** ${{ steps.bump.outputs.current-version }}" >> $GITHUB_STEP_SUMMARY
125+
126+
if [[ "${{ steps.create_pr.outputs.pull-request-number }}" != "" ]]; then
127+
PR_NUMBER="${{ steps.create_pr.outputs.pull-request-number }}"
128+
PR_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER"
129+
echo "- **Pull Request:** [#$PR_NUMBER]($PR_URL)" >> $GITHUB_STEP_SUMMARY
130+
echo "" >> $GITHUB_STEP_SUMMARY
131+
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
132+
echo "1. Review and merge [Pull Request #$PR_NUMBER]($PR_URL)" >> $GITHUB_STEP_SUMMARY
133+
echo "2. **Trigger a release** to publish version \`${{ steps.bump.outputs.current-version }}\`" >> $GITHUB_STEP_SUMMARY
134+
else
135+
echo "" >> $GITHUB_STEP_SUMMARY
136+
echo "### ⚠️ Warning" >> $GITHUB_STEP_SUMMARY
137+
echo "Pull request creation failed. Please check the workflow logs." >> $GITHUB_STEP_SUMMARY
138+
fi
139+
140+
echo "" >> $GITHUB_STEP_SUMMARY
141+
echo "### 📋 Workflow Details" >> $GITHUB_STEP_SUMMARY
142+
echo "- **Triggered by:** @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
143+
echo "- **Repository:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
144+
echo "- **Run ID:** [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)