cxpak 1.1.0

Spends CPU cycles so you don't spend tokens. The LLM gets a briefing packet instead of a flashlight in a dark room.
Documentation
name: Release

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            archive: tar.gz
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            archive: tar.gz
          - target: x86_64-apple-darwin
            os: macos-latest
            archive: tar.gz
          - target: aarch64-apple-darwin
            os: macos-latest
            archive: tar.gz
          # Windows: cargo install cxpak (vendored libgit2 linking issue)

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6.0.2

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

      - name: Install cross-compilation tools
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
          echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV

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

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

      - name: Package
        run: |
          cd target/${{ matrix.target }}/release
          tar czf ../../../cxpak-${{ matrix.target }}.tar.gz cxpak
          cd ../../..

      - name: Upload artifact
        uses: actions/upload-artifact@v7.0.0
        with:
          name: cxpak-${{ matrix.target }}
          path: cxpak-${{ matrix.target }}.*

  release:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6.0.2

      - name: Download all artifacts
        uses: actions/download-artifact@v8.0.1
        with:
          path: artifacts
          merge-multiple: true

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

  publish:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo publish --allow-dirty
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  update-homebrew:
    needs: release
    runs-on: ubuntu-latest
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v8.0.1
        with:
          path: artifacts
          merge-multiple: true

      - name: Update Homebrew formula
        env:
          TAP_TOKEN: ${{ secrets.TAP_TOKEN }}
        run: |
          VERSION="${GITHUB_REF_NAME#v}"

          SHA_LINUX_X86=$(sha256sum artifacts/cxpak-x86_64-unknown-linux-gnu.tar.gz | cut -d' ' -f1)
          SHA_LINUX_ARM=$(sha256sum artifacts/cxpak-aarch64-unknown-linux-gnu.tar.gz | cut -d' ' -f1)
          SHA_MAC_X86=$(sha256sum artifacts/cxpak-x86_64-apple-darwin.tar.gz | cut -d' ' -f1)
          SHA_MAC_ARM=$(sha256sum artifacts/cxpak-aarch64-apple-darwin.tar.gz | cut -d' ' -f1)

          git clone https://x-access-token:${TAP_TOKEN}@github.com/Barnett-Studios/homebrew-tap.git tap
          cd tap
          mkdir -p Formula

          cat > Formula/cxpak.rb << 'RUBY'
          class Cxpak < Formula
            desc "Token-budgeted codebase context for LLMs"
            homepage "https://github.com/Barnett-Studios/cxpak"
          RUBY

          cat >> Formula/cxpak.rb << EOF
            version "${VERSION}"

            on_macos do
              if Hardware::CPU.arm?
                url "https://github.com/Barnett-Studios/cxpak/releases/download/v${VERSION}/cxpak-aarch64-apple-darwin.tar.gz"
                sha256 "${SHA_MAC_ARM}"
              else
                url "https://github.com/Barnett-Studios/cxpak/releases/download/v${VERSION}/cxpak-x86_64-apple-darwin.tar.gz"
                sha256 "${SHA_MAC_X86}"
              end
            end

            on_linux do
              if Hardware::CPU.arm?
                url "https://github.com/Barnett-Studios/cxpak/releases/download/v${VERSION}/cxpak-aarch64-unknown-linux-gnu.tar.gz"
                sha256 "${SHA_LINUX_ARM}"
              else
                url "https://github.com/Barnett-Studios/cxpak/releases/download/v${VERSION}/cxpak-x86_64-unknown-linux-gnu.tar.gz"
                sha256 "${SHA_LINUX_X86}"
              end
            end

            def install
              bin.install "cxpak"
            end

            test do
              system "#{bin}/cxpak", "--help"
            end
          end
          EOF

          git config user.name "GitHub Actions"
          git config user.email "actions@github.com"
          git add Formula/cxpak.rb
          git diff --cached --quiet || git commit -m "Update cxpak to ${VERSION}"
          git push