verctl 0.4.5

Stack-agnostic version PRs from Changesets-format fragments
name: Publish

on:
  pull_request:
    types: [closed]
  workflow_dispatch:

permissions:
  contents: write

env:
  GIT_CONFIG_COUNT: "1"
  GIT_CONFIG_KEY_0: init.defaultBranch
  GIT_CONFIG_VALUE_0: main
  MISE_ENV: ci
  # A cache written off the default branch is scoped to that ref, so no
  # other run can read it back.
  CACHE_WRITE: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}

concurrency:
  group: publish-${{ github.ref }}
  cancel-in-progress: false

jobs:
  crate:
    if: >-
      github.event_name == 'workflow_dispatch' ||
      (github.event.pull_request.merged &&
       github.event.pull_request.head.ref == 'version-packages')
    runs-on: ubuntu-latest
    outputs:
      has_assets: ${{ steps.plan.outputs.has_assets }}
      tag: ${{ steps.plan.outputs.tag }}
      matrix: ${{ steps.plan.outputs.matrix }}
    steps:
      - name: Check out repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
          ref: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
          fetch-depth: 0
      - name: Set up mise
        uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
        with:
          version: 2026.10.9
          cache: true
          cache_save: ${{ env.CACHE_WRITE }}
      - run: mise install --locked
      - name: Plan native assets
        id: plan
        run: mise run ver assets --github-output "$GITHUB_OUTPUT"
      - name: Publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
          GITHUB_TOKEN: ${{ github.token }}
          VERCTL_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
        run: mise run ver publish

  assets:
    name: ${{ matrix.id }}
    needs: crate
    if: needs.crate.outputs.has_assets == 'true'
    strategy:
      fail-fast: false
      matrix: ${{ fromJson(needs.crate.outputs.matrix) }}
    runs-on: ${{ matrix.labels }}
    steps:
      - name: Check out repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
          ref: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
          fetch-depth: 0
      - name: Set up mise
        uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
        with:
          version: 2026.10.9
          cache: true
          cache_save: ${{ env.CACHE_WRITE }}
      - run: mise install --locked
      - name: Build and upload
        env:
          GITHUB_TOKEN: ${{ github.token }}
        run: >-
          mise run ver assets
          --build "${{ matrix.id }}"
          --upload
          --tag "${{ needs.crate.outputs.tag }}"