waterkit 0.1.3

Kit utilities and helpers
name: Release

on:
  # crates.io trusted publishing rejects OIDC tokens minted under
  # `workflow_run`, so publishing runs on the `main` push itself — which
  # can only come from a merged pull request (conventionally the dev ->
  # main release PR) whose required checks already passed on the same
  # tree. `release-pr` still waits for CI via `workflow_run`.
  push:
    branches: [main]
  workflow_run:
    workflows: ["CI"]
    branches: [main]
    types: [completed]

permissions:
  contents: write
  pull-requests: write
  id-token: write

jobs:
  release:
    name: Release unpublished packages
    runs-on: ubuntu-latest
    if: github.event_name == 'push'
    steps:
      - uses: actions/checkout@v4
        with:
          ref: main
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
      # cargo publish verifies each package by building it; the native
      # libraries the crates link (ALSA for waterkit-audio, ...) must be
      # present here exactly as in the test workflow, or the verify build fails.
      - name: Install Linux dependencies
        if: runner.os == 'Linux'
        uses: ./.github/actions/setup-linux-deps
      # Mint a short-lived crates.io token from the GitHub OIDC identity
      # instead of a stored CARGO_REGISTRY_TOKEN (trusted publishing is
      # configured per crate on crates.io).
      - uses: rust-lang/crates-io-auth-action@v1
        id: crates-io-auth
      - uses: MarcoIeni/release-plz-action@v0.5
        with:
          command: release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}

  release-pr:
    name: Prepare the next release
    runs-on: ubuntu-latest
    if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main'
    concurrency:
      group: release-plz-${{ github.event.workflow_run.head_branch }}
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@v4
        with:
          ref: main
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
      # cargo publish verifies each package by building it; the native
      # libraries the crates link (ALSA for waterkit-audio, ...) must be
      # present here exactly as in the test workflow, or the verify build fails.
      - name: Install Linux dependencies
        if: runner.os == 'Linux'
        uses: ./.github/actions/setup-linux-deps
      - uses: MarcoIeni/release-plz-action@v0.5
        with:
          command: release-pr
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}