name: Publish Release

permissions:
  contents: write

on:
  push:
    branches:
      - main

jobs:

  # Release unpublished packages.
  release-plz-release:
    name: Release-plz release
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      # Generating a GitHub token, so that PRs and tags created by
      # the release-plz-action can trigger actions workflows.
      - name: Generate GitHub token
        uses: actions/create-github-app-token@dff4b11d10ecc84d937fdd0653d8343a88c5b9c4 # v1.11.6
        id: generate-token
        with:
          # GitHub App ID secret name
          app-id: ${{ secrets.APP_ID }}
          # GitHub App private key secret name
          private-key: ${{ secrets.APP_PRIVATE_KEY }}
      - name: Checkout repository
        uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # v4.2.1
        with:
          fetch-depth: 0
          token: ${{ steps.generate-token.outputs.token }}
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Run release-plz
        uses: release-plz/action@ccf6dd998441f26020f4315f1ebe95d9e2e42600 # v0.5.110
        with:
          command: release
        env:
          GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
