name: Release-plz
on:
push:
branches:
- main
workflow_dispatch:
jobs:
release-plz-release:
name: Release-plz release
runs-on: ubuntu-latest
if: github.repository_owner == 'arcuru' && (github.event_name == 'push' || github.ref == 'refs/heads/main')
environment: publish
permissions:
contents: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5
- name: Authenticate with crates.io
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe id: cratesio-auth
- name: Run release-plz
id: release-plz
uses: release-plz/action@f708778669256143d984cce4b23592637532e040 with:
command: release
config: .config/release-plz.toml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ steps.cratesio-auth.outputs.token }}
- name: Trigger publish workflow
if: steps.release-plz.outputs.releases_created == 'true'
env:
RELEASES: ${{ steps.release-plz.outputs.releases }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG=$(echo "$RELEASES" | jq -r '.[0].tag_name')
gh workflow run publish.yml -f tag_name="$TAG"
release-plz-pr:
name: Release-plz PR
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'arcuru' }}
permissions:
contents: write
pull-requests: write
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5
- name: Check if release PR exists
id: check-pr
if: github.event_name == 'push'
run: |
PR_EXISTS=$(gh pr list --repo "$GITHUB_REPOSITORY" --state open --json number,headRefName --jq '[.[] | select(.headRefName | startswith("release-plz"))] | length')
echo "exists=$PR_EXISTS" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run release-plz
if: github.event_name == 'workflow_dispatch' || steps.check-pr.outputs.exists != '0'
uses: release-plz/action@f708778669256143d984cce4b23592637532e040 with:
command: release-pr
config: .config/release-plz.toml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}