Skip to content

Commit ae1fecb

Browse files
authored
Merge pull request #45 from cloudengine-labs/copilot/fix-release-yml-failure
fix(release): use create-pull-request to satisfy main branch protection
2 parents ca8abf7 + 8ae3f6c commit ae1fecb

1 file changed

Lines changed: 44 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ on:
77
branches: [main]
88

99
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
1112

1213
jobs:
1314
version-bump:
14-
name: Bump patch version, update docs, tag & push
15+
name: Bump patch version, update docs, open PR & tag
1516
runs-on: ubuntu-latest
1617

1718
# Skip commits that were already made by this workflow (or any bot) to
1819
# 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.
1923
if: >-
2024
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'))
2228
2329
steps:
2430
- name: Checkout repository (full history for tagging)
@@ -114,16 +120,42 @@ jobs:
114120
"s|version-[0-9]+\.[0-9]+\.[0-9]+-blue|version-${NEW_VERSION}-blue|g" \
115121
hugo-docs/content/_index.md
116122
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 != ''
119156
env:
120157
NEW_VERSION: ${{ steps.bump.outputs.new_version }}
158+
TAG_SHA: ${{ steps.cpr.outputs.pull-request-head-sha }}
121159
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}"
129161
git push origin "v${NEW_VERSION}"

0 commit comments

Comments
 (0)