From c488775f7317dad441fff3b26fc64ead68684508 Mon Sep 17 00:00:00 2001 From: Danyal Prout Date: Fri, 10 Oct 2025 11:39:11 -0500 Subject: [PATCH] chore: create/review own release bump pr --- .github/workflows/release.yml | 53 +++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf3d77f..3cf5054 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,12 +16,14 @@ on: env: CARGO_TERM_COLOR: always +permissions: + contents: write + pull-requests: write + jobs: release: name: Create Release runs-on: ubuntu-latest - permissions: - contents: write steps: - name: Harden the runner (Audit all outbound calls) uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1 @@ -34,8 +36,14 @@ jobs: - uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable + - name: Cache cargo-edit + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: ~/.cargo/bin/cargo-set-version + key: ${{ runner.os }}-cargo-edit-0.12.0 + - name: Install cargo-edit - run: cargo install cargo-edit + run: cargo install cargo-edit || true - name: Bump version run: | @@ -44,27 +52,42 @@ jobs: echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV echo "Bumped version to: $NEW_VERSION" - - name: Build project - run: cargo build --all-targets - - name: Configure git run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - - name: Commit and push changes + - name: Create release branch and commit run: | + BRANCH_NAME="release/v${{ env.NEW_VERSION }}" + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + git checkout -b "$BRANCH_NAME" git add Cargo.toml Cargo.lock git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" - git tag -a "v${{ env.NEW_VERSION }}" -m "Release v${{ env.NEW_VERSION }}" - git push origin main - git push origin "v${{ env.NEW_VERSION }}" + git push origin "$BRANCH_NAME" + + - name: Create Pull Request + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_URL=$(gh pr create \ + --title "chore: release v${{ env.NEW_VERSION }}" \ + --body "Automated release PR for version ${{ env.NEW_VERSION }}" \ + --base main \ + --head "${{ env.BRANCH_NAME }}") + PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]*$') + echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV + echo "PR_URL=$PR_URL" >> $GITHUB_ENV + + - name: Wait for CI to pass + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "Waiting for CI checks to complete on PR #${{ env.PR_NUMBER }}..." + gh pr checks "${{ env.PR_NUMBER }}" --watch --interval 30 - - name: Create GitHub Release + - name: Approve PR env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release create "v${{ env.NEW_VERSION }}" \ - --title "v${{ env.NEW_VERSION }}" \ - --generate-notes \ - --draft + gh pr review "${{ env.PR_NUMBER }}" --approve \ No newline at end of file