2222 runs-on : ubuntu-latest
2323 permissions :
2424 contents : write
25+ pull-requests : write
2526 steps :
2627 - name : Harden the runner (Audit all outbound calls)
2728 uses : step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
3435
3536 - uses : dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
3637
38+ - name : Cache cargo-edit
39+ uses : actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
40+ with :
41+ path : ~/.cargo/bin/cargo-set-version
42+ key : ${{ runner.os }}-cargo-edit-0.12.0
43+
3744 - name : Install cargo-edit
38- run : cargo install cargo-edit
45+ run : cargo install cargo-edit || true
3946
4047 - name : Bump version
4148 run : |
@@ -44,27 +51,42 @@ jobs:
4451 echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
4552 echo "Bumped version to: $NEW_VERSION"
4653
47- - name : Build project
48- run : cargo build --all-targets
49-
5054 - name : Configure git
5155 run : |
5256 git config user.name "github-actions[bot]"
5357 git config user.email "github-actions[bot]@users.noreply.github.com"
5458
55- - name : Commit and push changes
59+ - name : Create release branch and commit
5660 run : |
61+ BRANCH_NAME="release/v${{ env.NEW_VERSION }}"
62+ echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
63+ git checkout -b "$BRANCH_NAME"
5764 git add Cargo.toml Cargo.lock
5865 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 }}"
66+ git push origin "$BRANCH_NAME"
67+
68+ - name : Create Pull Request
69+ env :
70+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
71+ run : |
72+ PR_URL=$(gh pr create \
73+ --title "chore: release v${{ env.NEW_VERSION }}" \
74+ --body "Automated release PR for version ${{ env.NEW_VERSION }}" \
75+ --base main \
76+ --head "${{ env.BRANCH_NAME }}")
77+ PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]*$')
78+ echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
79+ echo "PR_URL=$PR_URL" >> $GITHUB_ENV
80+
81+ - name : Wait for CI to pass
82+ env :
83+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
84+ run : |
85+ echo "Waiting for CI checks to complete on PR #${{ env.PR_NUMBER }}..."
86+ gh pr checks "${{ env.PR_NUMBER }}" --watch --interval 30
6287
63- - name : Create GitHub Release
88+ - name : Approve PR
6489 env :
6590 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6691 run : |
67- gh release create "v${{ env.NEW_VERSION }}" \
68- --title "v${{ env.NEW_VERSION }}" \
69- --generate-notes \
70- --draft
92+ gh pr review "${{ env.PR_NUMBER }}" --approve
0 commit comments