stverify 0.2.2

Zero-bloat parallel cryptographic signer and verifier for safetensors model shards
Documentation
name: Release Static Binaries & Scratch Container

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write
  packages: write

jobs:
  build-binaries:
    name: Build (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    continue-on-error: ${{ matrix.allow_failure }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            artifact: stverify-linux-x86_64
            allow_failure: false
          - os: ubuntu-latest
            target: aarch64-unknown-linux-musl
            artifact: stverify-linux-aarch64
            allow_failure: false
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: stverify-macos-arm64
            allow_failure: true
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: stverify-windows-x86_64.exe
            allow_failure: false

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

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

      - name: Install musl cross-compilers (Linux)
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y musl-tools gcc-aarch64-linux-gnu

      - name: Build static release binary
        shell: bash
        env:
          CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
        run: |
          cargo build --release --target ${{ matrix.target }}
          if [ -f "target/${{ matrix.target }}/release/stverify.exe" ]; then
            cp "target/${{ matrix.target }}/release/stverify.exe" "${{ matrix.artifact }}"
          else
            strip "target/${{ matrix.target }}/release/stverify" || true
            cp "target/${{ matrix.target }}/release/stverify" "${{ matrix.artifact }}"
          fi
          if command -v sha256sum >/dev/null 2>&1; then
            sha256sum "${{ matrix.artifact }}" > "${{ matrix.artifact }}.sha256"
          else
            shasum -a 256 "${{ matrix.artifact }}" > "${{ matrix.artifact }}.sha256"
          fi

      - name: Upload release artifacts
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.artifact }}
          path: |
            ${{ matrix.artifact }}
            ${{ matrix.artifact }}.sha256

  publish-release:
    needs: build-binaries
    runs-on: ubuntu-latest
    if: always() && !cancelled()
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true

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

  publish-container:
    needs: build-binaries
    runs-on: ubuntu-latest
    if: always() && !cancelled()
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Log in to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=semver,pattern={{version}}
            type=raw,value=latest

      - name: Build and push scratch image
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max