|
7 | 7 | branches: [main] |
8 | 8 |
|
9 | 9 | permissions: |
10 | | - contents: write # needed to commit the bump and push tags |
| 10 | + contents: write # needed to push the release branch and create tags |
| 11 | + pull-requests: write # needed to open the version-bump PR |
11 | 12 |
|
12 | 13 | jobs: |
13 | 14 | version-bump: |
14 | | - name: Bump patch version, update docs, tag & push |
| 15 | + name: Bump patch version, update docs, open PR & tag |
15 | 16 | runs-on: ubuntu-latest |
16 | 17 |
|
17 | 18 | # Skip commits that were already made by this workflow (or any bot) to |
18 | 19 | # avoid triggering an infinite bump loop. |
| 20 | + # Also skip merges of the automated release/vX.Y.Z PRs: a regular merge |
| 21 | + # produces a commit message starting with "Merge pull request" that also |
| 22 | + # references the release/vX.Y.Z branch name. |
19 | 23 | if: >- |
20 | 24 | github.actor != 'github-actions[bot]' && |
21 | | - !contains(github.event.head_commit.message, '[skip ci]') |
| 25 | + !contains(github.event.head_commit.message, '[skip ci]') && |
| 26 | + !(startsWith(github.event.head_commit.message, 'Merge pull request') && |
| 27 | + contains(github.event.head_commit.message, 'release/v')) |
22 | 28 |
|
23 | 29 | steps: |
24 | 30 | - name: Checkout repository (full history for tagging) |
@@ -114,16 +120,42 @@ jobs: |
114 | 120 | "s|version-[0-9]+\.[0-9]+\.[0-9]+-blue|version-${NEW_VERSION}-blue|g" \ |
115 | 121 | hugo-docs/content/_index.md |
116 | 122 |
|
117 | | - # ── 4. Commit, tag, and push ────────────────────────────────────────── |
118 | | - - name: Commit version bump and create git tag |
| 123 | + # ── 4. Open a PR with the version-bump changes ──────────────────────── |
| 124 | + # peter-evans/create-pull-request creates commits via the GitHub API so |
| 125 | + # they are automatically verified (signed), satisfying the branch |
| 126 | + # protection rule that requires signed commits. It also opens a PR |
| 127 | + # instead of pushing directly to main, satisfying the rule that all |
| 128 | + # changes must go through a pull request. |
| 129 | + - name: Create pull request for version bump |
| 130 | + id: cpr |
| 131 | + uses: peter-evans/create-pull-request@v7 |
| 132 | + with: |
| 133 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 134 | + branch: release/v${{ steps.bump.outputs.new_version }} |
| 135 | + commit-message: "chore: bump version to v${{ steps.bump.outputs.new_version }} [skip ci]" |
| 136 | + title: "chore: bump version to v${{ steps.bump.outputs.new_version }}" |
| 137 | + body: | |
| 138 | + Automated patch version bump to `v${{ steps.bump.outputs.new_version }}`. |
| 139 | +
|
| 140 | + - Updates `cli/__version__.py` |
| 141 | + - Prepends entry to `CHANGELOG.md` |
| 142 | + - Updates version badge in `hugo-docs/content/_index.md` |
| 143 | + labels: | |
| 144 | + release |
| 145 | + automated |
| 146 | + add-paths: | |
| 147 | + cli/__version__.py |
| 148 | + CHANGELOG.md |
| 149 | + hugo-docs/content/_index.md |
| 150 | +
|
| 151 | + # ── 5. Tag the PR branch's head commit ────────────────────────────────── |
| 152 | + # Tag the commit on the release branch (not the local main checkout) so |
| 153 | + # the tag always points to the exact commit that carries the version bump. |
| 154 | + - name: Create and push git tag |
| 155 | + if: steps.cpr.outputs.pull-request-number != '' |
119 | 156 | env: |
120 | 157 | NEW_VERSION: ${{ steps.bump.outputs.new_version }} |
| 158 | + TAG_SHA: ${{ steps.cpr.outputs.pull-request-head-sha }} |
121 | 159 | run: | |
122 | | - git config user.name "Saravanan Gnanaguru" |
123 | | - git config user.email "g.gsaravanan@gmail.com" |
124 | | -
|
125 | | - git add cli/__version__.py CHANGELOG.md hugo-docs/content/_index.md |
126 | | - git commit -m "chore: bump version to v${NEW_VERSION} [skip ci]" |
127 | | - git tag "v${NEW_VERSION}" |
128 | | - git push origin main |
| 160 | + git tag "v${NEW_VERSION}" "${TAG_SHA}" |
129 | 161 | git push origin "v${NEW_VERSION}" |
0 commit comments