Skip to content

Commit c488775

Browse files
committed
chore: create/review own release bump pr
1 parent b46548c commit c488775

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

.github/workflows/release.yml

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ on:
1616
env:
1717
CARGO_TERM_COLOR: always
1818

19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
1923
jobs:
2024
release:
2125
name: Create Release
2226
runs-on: ubuntu-latest
23-
permissions:
24-
contents: write
2527
steps:
2628
- name: Harden the runner (Audit all outbound calls)
2729
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
@@ -34,8 +36,14 @@ jobs:
3436

3537
- uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
3638

39+
- name: Cache cargo-edit
40+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
41+
with:
42+
path: ~/.cargo/bin/cargo-set-version
43+
key: ${{ runner.os }}-cargo-edit-0.12.0
44+
3745
- name: Install cargo-edit
38-
run: cargo install cargo-edit
46+
run: cargo install cargo-edit || true
3947

4048
- name: Bump version
4149
run: |
@@ -44,27 +52,42 @@ jobs:
4452
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
4553
echo "Bumped version to: $NEW_VERSION"
4654
47-
- name: Build project
48-
run: cargo build --all-targets
49-
5055
- name: Configure git
5156
run: |
5257
git config user.name "github-actions[bot]"
5358
git config user.email "github-actions[bot]@users.noreply.github.com"
5459
55-
- name: Commit and push changes
60+
- name: Create release branch and commit
5661
run: |
62+
BRANCH_NAME="release/v${{ env.NEW_VERSION }}"
63+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
64+
git checkout -b "$BRANCH_NAME"
5765
git add Cargo.toml Cargo.lock
5866
git commit -m "chore: bump version to ${{ env.NEW_VERSION }}"
59-
git tag -a "v${{ env.NEW_VERSION }}" -m "Release v${{ env.NEW_VERSION }}"
60-
git push origin main
61-
git push origin "v${{ env.NEW_VERSION }}"
67+
git push origin "$BRANCH_NAME"
68+
69+
- name: Create Pull Request
70+
env:
71+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
PR_URL=$(gh pr create \
74+
--title "chore: release v${{ env.NEW_VERSION }}" \
75+
--body "Automated release PR for version ${{ env.NEW_VERSION }}" \
76+
--base main \
77+
--head "${{ env.BRANCH_NAME }}")
78+
PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]*$')
79+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
80+
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
81+
82+
- name: Wait for CI to pass
83+
env:
84+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
run: |
86+
echo "Waiting for CI checks to complete on PR #${{ env.PR_NUMBER }}..."
87+
gh pr checks "${{ env.PR_NUMBER }}" --watch --interval 30
6288
63-
- name: Create GitHub Release
89+
- name: Approve PR
6490
env:
6591
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6692
run: |
67-
gh release create "v${{ env.NEW_VERSION }}" \
68-
--title "v${{ env.NEW_VERSION }}" \
69-
--generate-notes \
70-
--draft
93+
gh pr review "${{ env.PR_NUMBER }}" --approve

0 commit comments

Comments
 (0)