Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

requirements.integration.release

Requirements index · View definition

evidence Valid

Requirement

A dedicated GitHub Actions workflow MUST run release-plz on pushes to main to create release pull requests and publish approved versions. Both jobs MUST run only when the repository owner is nikomatsakis, so forks do not attempt releases. Release pull request runs for the same ref MUST NOT run concurrently; a later run MUST wait for an earlier one rather than cancel it. Publishing MUST require a merged release-plz pull request. The release job MUST request an OIDC token for crates.io trusted publishing, and both jobs MUST use a GitHub token from a repository secret so release pull requests can trigger the normal pull request checks.

Rationale

I found no gaps. The workflow and config carry out every obligation, and one test checks each of them.

Each obligation maps to code and to the test release_workflow_runs_release_plz_with_secret_token_and_trusted_publishing in tests/repository.rs. That test carries the {test} reference to the subject.

  • Dedicated workflow runs release-plz on pushes to main: .github/workflows/release-plz.yml is a standalone workflow. Its on: block triggers only on push to main, and both jobs use release-plz/action@v0.5. The test asserts the exact on block and that pull_request is absent.
  • Release PRs and publishing, as two jobs: release-plz-pr runs command: release-pr and release-plz-release runs command: release. The test checks both commands.
  • Both jobs run only for owner nikomatsakis: each job has if: ${{ github.repository_owner == 'nikomatsakis' }}. The test loops over both jobs and asserts this.
  • Release PR runs for the same ref don’t run concurrently, and a later run waits rather than cancels: release-plz-pr sets concurrency.group: release-plz-${{ github.ref }} and cancel-in-progress: false. The test asserts this block.
  • Publishing requires a merged release-plz PR: release-plz.toml sets [workspace] release_always = false. The test parses the TOML and asserts it is false.
  • The release job requests an OIDC token for trusted publishing: release-plz-release has permissions: id-token: write. The test asserts it.
  • Both jobs use a GitHub token from a repository secret: both jobs set GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} on the release-plz step. The shared checkout step also uses token: ${{ secrets.RELEASE_PLZ_TOKEN }}. The test asserts the env token for both jobs and the checkout token for the release job. release-plz-pr reuses the same checkout step through the *checkout YAML alias, and the test asserts that alias is present.

I found no unspecified extra behavior beyond ordinary job permissions and setup steps.

Inputs

Implementation

Input 2: outline .github/workflows/release-plz.yml pair[on]
# {impl}`requirements.integration.release`
on:
  push:
    branches:
      - main
Input 3: outline .github/workflows/release-plz.yml pair[jobs]/pair[release-plz-release]
  # {impl}`requirements.integration.release`
  release-plz-release:
    name: Release-plz release
    runs-on: ubuntu-latest
    if: ${{ github.repository_owner == 'nikomatsakis' }}
    permissions:
      contents: write
      id-token: write
    steps:
      - &checkout
        name: Checkout repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
          persist-credentials: true
          token: ${{ secrets.RELEASE_PLZ_TOKEN }}
      - &install-rust
        name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Run release-plz
        uses: release-plz/action@v0.5
        with:
          command: release
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}

  # {impl}`requirements.integration.release`
Input 4: outline .github/workflows/release-plz.yml pair[jobs]/pair[release-plz-pr]
  # {impl}`requirements.integration.release`
  release-plz-pr:
    name: Release-plz PR
    runs-on: ubuntu-latest
    if: ${{ github.repository_owner == 'nikomatsakis' }}
    permissions:
      pull-requests: write
      contents: write
    concurrency:
      group: release-plz-${{ github.ref }}
      cancel-in-progress: false
    steps:
      - *checkout
      - *install-rust
      - name: Run release-plz
        uses: release-plz/action@v0.5
        with:
          command: release-pr
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
Input 5: outline release-plz.toml table[workspace]/pair[release_always]
# {impl}`requirements.integration.release`
release_always = false
Input 7: outline .github/workflows/release-plz.yml pair[jobs]
jobs:
  # {impl}`requirements.integration.release`
  release-plz-release:
    name: Release-plz release
    runs-on: ubuntu-latest
    if: ${{ github.repository_owner == 'nikomatsakis' }}
    permissions:
      contents: write
      id-token: write
    steps:
      - &checkout
        name: Checkout repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
          persist-credentials: true
          token: ${{ secrets.RELEASE_PLZ_TOKEN }}
      - &install-rust
        name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Run release-plz
        uses: release-plz/action@v0.5
        with:
          command: release
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}

  # {impl}`requirements.integration.release`
  release-plz-pr:
    name: Release-plz PR
    runs-on: ubuntu-latest
    if: ${{ github.repository_owner == 'nikomatsakis' }}
    permissions:
      pull-requests: write
      contents: write
    concurrency:
      group: release-plz-${{ github.ref }}
      cancel-in-progress: false
    steps:
      - *checkout
      - *install-rust
      - name: Run release-plz
        uses: release-plz/action@v0.5
        with:
          command: release-pr
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
Input 9: outline release-plz.toml table[workspace]
[workspace]
# {impl}`requirements.integration.release`
release_always = false

Tests

Input 6: outline tests/repository.rs fn[release_workflow_runs_release_plz_with_secret_token_and_trusted_publishing]
  • File: tests/repository.rs
  • Selector: fn[release_workflow_runs_release_plz_with_secret_token_and_trusted_publishing]
  • Kind: fn
  • tests/repository.rs:382–424
// {test}`requirements.integration.release`
#[test]
fn release_workflow_runs_release_plz_with_secret_token_and_trusted_publishing() {
    let workflow = repository_file(".github/workflows/release-plz.yml");
    assert!(
        workflow.contains("\non:\n  push:\n    branches:\n      - main\n\n"),
        "{workflow}"
    );
    assert!(!workflow.contains("pull_request"), "{workflow}");

    let release = workflow_job(&workflow, "release-plz-release");
    assert!(release.contains("id-token: write"), "{release}");
    assert!(release.contains("command: release\n"), "{release}");
    assert!(
        release.contains("GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}"),
        "{release}"
    );

    let pr = workflow_job(&workflow, "release-plz-pr");
    assert!(pr.contains("command: release-pr\n"), "{pr}");
    assert!(
        pr.contains("GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}"),
        "{pr}"
    );
    assert!(pr.contains("- *checkout\n"), "{pr}");
    for job in [&release, &pr] {
        assert!(
            job.contains("if: ${{ github.repository_owner == 'nikomatsakis' }}"),
            "{job}"
        );
    }
    assert!(
        pr.contains("concurrency:\n      group: release-plz-${{ github.ref }}\n      cancel-in-progress: false\n"),
        "{pr}"
    );
    assert!(
        release.contains("token: ${{ secrets.RELEASE_PLZ_TOKEN }}"),
        "the shared checkout step uses the secret token too: {release}"
    );

    let config = repository_toml("release-plz.toml");
    assert_eq!(config["workspace"]["release_always"].as_bool(), Some(false));
}

Other sources

Input 1: requirements selection requirements.integration.release
:::{req} release
A dedicated GitHub Actions workflow MUST run release-plz on pushes to `main` to create release pull requests and publish approved versions. Both jobs MUST run only when the repository owner is `nikomatsakis`, so forks do not attempt releases. Release pull request runs for the same ref MUST NOT run concurrently; a later run MUST wait for an earlier one rather than cancel it. Publishing MUST require a merged release-plz pull request. The release job MUST request an OIDC token for crates.io trusted publishing, and both jobs MUST use a GitHub token from a repository secret so release pull requests can trigger the normal pull request checks.
:::
Input 8: outline .github/workflows/release-plz.yml pair[name]
name: Release-plz