texio-cli 0.1.2

Reliable Markdown operations for shell scripts and AI agents
name: Publish crate

on:
  workflow_dispatch:
    inputs:
      tag:
        description: Existing release tag to publish
        required: true
        type: string
      confirmation:
        description: Type "publish" to authorize the irreversible upload
        required: true
        type: string

permissions:
  contents: read

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Require explicit confirmation
        env:
          CONFIRMATION: ${{ inputs.confirmation }}
        run: test "$CONFIRMATION" = publish

      - uses: actions/checkout@v7
        with:
          ref: ${{ inputs.tag }}
          persist-credentials: false

      - uses: dtolnay/rust-toolchain@stable

      - name: Verify tag matches the package version
        env:
          RELEASE_TAG: ${{ inputs.tag }}
        run: |
          package_version=$(cargo metadata --no-deps --format-version 1 |
            jq -r '.packages[] | select(.name == "texio-cli") | .version')
          test "$RELEASE_TAG" = "v$package_version"
          test "$(git tag --points-at HEAD)" = "$RELEASE_TAG"

      - name: Verify package contents
        run: |
          cargo test --locked
          cargo package --locked
          cargo publish --dry-run --locked

      - name: Publish texio-cli
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish --locked