Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 38 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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
Loading