name: release
on:
push:
branches: ["main"]
paths:
- "Cargo.toml"
workflow_dispatch:
inputs:
mode:
description: "dryrun: cargo publish --dry-run, no official tag"
required: true
default: "dryrun"
type: choice
options: ["dryrun", "real"]
tag_dryrun:
description: "If true, create vX.Y.Z-dryrun.<run_id> tag in dryrun mode"
required: false
default: "false"
type: choice
options: ["false", "true"]
concurrency:
group: crates-release-main
cancel-in-progress: false
jobs:
detect:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.v.outputs.changed }}
version: ${{ steps.v.outputs.version }}
prev_version: ${{ steps.v.outputs.prev_version }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- id: v
name: Detect version
run: python3 .github/scripts/release/detect_version.py
publish_and_tag:
needs: [detect]
if: |
(github.event_name == 'push' && needs.detect.outputs.changed == 'true') ||
(github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: true
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Compile Python scripts
run: python3 -m compileall .github/scripts
- name: Test
run: cargo test --locked
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
RELEASE_MODE: ${{ inputs.mode }}
run: python3 .github/scripts/release/publish.py
- name: Create and push tag
env:
RELEASE_VERSION: ${{ needs.detect.outputs.version }}
RELEASE_MODE: ${{ inputs.mode }}
TAG_DRYRUN: ${{ inputs.tag_dryrun }}
run: python3 .github/scripts/release/tag_release.py