Skip to content

ci(ci): fix release chaining via PR-merge, simplify token usage, add … #1

ci(ci): fix release chaining via PR-merge, simplify token usage, add …

ci(ci): fix release chaining via PR-merge, simplify token usage, add … #1

Workflow file for this run

name: Release Automation
on:
push:
branches: [main]
pull_request:
types: [closed]
workflow_dispatch: # Allow manual triggering
permissions:
contents: write
pull-requests: write
issues: write # allow labeling the release PR
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
release-plz:
name: Release Please
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ github.token }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Install release-plz
uses: taiki-e/install-action@v2
with:
tool: release-plz
- name: Run release-plz
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
release-plz release-pr --git-token "$GITHUB_TOKEN"
# Auto-release when the Release PR is merged into main
release:
name: Create Release
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Ensure we operate against the main branch after merge
ref: main
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install release-plz
uses: taiki-e/install-action@v2
with:
tool: release-plz
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
release-plz release --git-token "$GITHUB_TOKEN"