name: Release
on:
workflow_run:
workflows: ["CI"]
types: [completed]
branches: [main, dev]
workflow_dispatch:
permissions:
contents: write
issues: write
pull-requests: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
semantic-release:
name: Semantic Release
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
RELEASE_BRANCH: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
DRAFT_RELEASE: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'dev') || (github.event_name != 'workflow_run' && github.ref_name == 'dev') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.RELEASE_BRANCH }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: npm install --no-audit --no-fund
- name: Bootstrap v0.0.0 tag (one-time)
run: |
if git ls-remote --tags origin v0.0.0 | grep -q "refs/tags/v0.0.0"; then
echo "Bootstrap tag v0.0.0 already exists"
else
first_commit=$(git rev-list --max-parents=0 HEAD)
git tag v0.0.0 "$first_commit"
git push origin v0.0.0
echo "Created bootstrap tag v0.0.0 at $first_commit"
fi
- name: Run semantic-release
run: npx semantic-release