sparrow-cli 0.5.1

A local-first Rust agent cockpit — route, run, replay, rewind
Documentation
name: Release

on:
  push:
    tags: ['v*']

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: sparrow-linux-x86_64
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: sparrow-macos-arm64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: sparrow-windows-x86_64.exe
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with: { targets: "${{ matrix.target }}" }
      - uses: Swatinem/rust-cache@v2
      - name: Build
        run: cargo build --release --target ${{ matrix.target }}
      - name: Rename binary (prevent cross-platform name collision)
        shell: bash
        run: |
          cd target/${{ matrix.target }}/release
          if [ -f sparrow.exe ]; then
            mv sparrow.exe "${{ matrix.artifact }}"
          elif [ -f sparrow ]; then
            mv sparrow "${{ matrix.artifact }}"
          else
            echo "sparrow binary not found" >&2
            exit 1
          fi
      - name: Generate checksums
        shell: bash
        run: |
          cd target/${{ matrix.target }}/release
          sha256sum "${{ matrix.artifact }}" > "${{ matrix.artifact }}.sha256"
          cat "${{ matrix.artifact }}.sha256"
      - uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.artifact }}
          path: |
            target/${{ matrix.target }}/release/${{ matrix.artifact }}
            target/${{ matrix.target }}/release/${{ matrix.artifact }}.sha256

  publish:
    name: Publish Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with: { path: artifacts }
      - name: Clean stale release assets
        env:
          GH_TOKEN: ${{ github.token }}
        shell: bash
        run: |
          if ! gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
            exit 0
          fi
          gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name' |
            while IFS= read -r asset; do
              [ -n "$asset" ] && gh release delete-asset "$GITHUB_REF_NAME" "$asset" --repo "$GITHUB_REPOSITORY" -y
            done
      - name: Create release
        uses: softprops/action-gh-release@v1
        with:
          files: artifacts/**/*
          generate_release_notes: true