quotch 0.5.5

Fast cross-platform CLI for AI coding-agent usage limits
name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  build:
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - name: Install musl tools
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: sudo apt-get update && sudo apt-get install -y musl-tools

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

      - name: Build
        run: cargo build --release --target ${{ matrix.target }}

      - name: Package (unix)
        if: matrix.os != 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          tar czf ${{ github.workspace }}/quotch-${{ github.ref_name }}-${{ matrix.target }}.tar.gz quotch

      - name: Package (windows)
        if: matrix.os == 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          Compress-Archive -Path quotch.exe -DestinationPath ${{ github.workspace }}/quotch-${{ github.ref_name }}-${{ matrix.target }}.zip

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: quotch-${{ matrix.target }}
          path: |
            quotch-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
            quotch-${{ github.ref_name }}-${{ matrix.target }}.zip
          if-no-files-found: ignore

  release:
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true

      - name: Generate checksums
        run: |
          cd dist
          sha256sum * > sha256sums.txt

      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          files: dist/*
          generate_release_notes: true

  publish:
    needs: build
    runs-on: ubuntu-latest
    # Requires the CARGO_REGISTRY_TOKEN repo secret (Settings → Secrets).
    # Job-level env lets the step `if` see it, so tagging still builds binaries
    # even before you opt in to crates.io publishing.
    env:
      CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io
        if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
        run: cargo publish