From 8d1ff4d1f9f83f824979ea46faf39da6e366f0e1 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Fri, 29 Aug 2025 15:57:03 +0200 Subject: [PATCH 1/3] ci: add bumpversion github workflow --- .bumpversion.toml | 2 +- .github/workflows/bumpversion.yml | 152 ++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/bumpversion.yml diff --git a/.bumpversion.toml b/.bumpversion.toml index 7fe678f..b902a65 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -23,4 +23,4 @@ replace = "\"{new_version}\" == deepl.__version__" [[tool.bumpversion.files]] filename = "pyproject.toml" search = "name = \"deepl\"\nversion = \"{current_version}\"" -replace = "name = \"deepl\"\nversion = \"{new_version}\"" \ No newline at end of file +replace = "name = \"deepl\"\nversion = \"{new_version}\"" diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml new file mode 100644 index 0000000..9fa076e --- /dev/null +++ b/.github/workflows/bumpversion.yml @@ -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@v6 + 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 "chore: 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 From a91008a05240f4b0df374f4248b8a6ac2f9058f4 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Wed, 25 Mar 2026 20:46:01 +0100 Subject: [PATCH 2/3] ci: bumpversion action improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Permissions — permissions: {} at workflow level, scoped contents: write + pull-requests: write to the job. 2. Concurrency guard — group: bumpversion, cancel-in-progress: false so a second trigger waits rather than interrupting mid-bump. 3. Pre-commit fix — removed the "Configure Git" and "Create version commit" steps; create-pull-request now owns the commit via commit-message. --- .github/workflows/bumpversion.yml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml index 9fa076e..98a5579 100644 --- a/.github/workflows/bumpversion.yml +++ b/.github/workflows/bumpversion.yml @@ -6,9 +6,11 @@ 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 +permissions: {} + +concurrency: + group: bumpversion + cancel-in-progress: false on: workflow_dispatch: @@ -31,6 +33,9 @@ on: jobs: bump_version: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write outputs: version: ${{ steps.bump.outputs.current-version }} @@ -75,24 +80,11 @@ jobs: 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 "chore: 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: + 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. From ef2bb9babb24af5a7e30ebe5658a089f06fd406e Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Wed, 25 Mar 2026 20:48:40 +0100 Subject: [PATCH 3/3] ci: bumpversion action - pin to specific hashes of 3rd party actions --- .github/workflows/bumpversion.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml index 98a5579..2b35d84 100644 --- a/.github/workflows/bumpversion.yml +++ b/.github/workflows/bumpversion.yml @@ -43,12 +43,12 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + 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@v6 + 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 @@ -66,7 +66,7 @@ jobs: - name: Update changelog id: changelog - uses: release-flow/keep-a-changelog-action@v2 + 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 }} @@ -75,14 +75,14 @@ jobs: - name: Query changelog for release notes id: query_changelog - uses: release-flow/keep-a-changelog-action@v2 + 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@v7 + 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)"