recursive-agent 0.6.0

A minimal, orthogonal, self-improving coding agent kernel in Rust
Documentation
name: Release

on:
  push:
    tags:
      - 'v*.*.*'

env:
  CARGO_TERM_COLOR: always

jobs:
  # ── 1. Verify version + run tests ─────────────────────────────────────────
  verify:
    name: Verify & test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: Configure git for tests
        run: |
          git config --global user.email "ci@recursive.local"
          git config --global user.name "CI Bot"
          git config --global safe.directory "*"

      - name: Verify tag matches Cargo.toml version
        run: |
          tag_version="${GITHUB_REF_NAME#v}"
          crate_version=$(cargo metadata --no-deps --format-version 1 \
            | python3 -c "import sys, json; pkgs = json.load(sys.stdin)['packages']; print(next(p['version'] for p in pkgs if p['name'] == 'recursive-agent'))")
          echo "tag=$tag_version  cargo=$crate_version"
          if [ "$tag_version" != "$crate_version" ]; then
            echo "::error::Tag '$GITHUB_REF_NAME' does not match Cargo.toml version '$crate_version'"
            exit 1
          fi

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ubuntu-latest-cargo-release-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ubuntu-latest-cargo-

      - name: Format check
        run: cargo fmt --all -- --check

      - name: Clippy
        run: cargo clippy --workspace --all-targets --all-features -- -D warnings

      - name: Test
        run: cargo test --workspace --verbose

  # ── 2. Build binaries for all platforms ───────────────────────────────────
  build:
    name: Build ${{ matrix.target }}
    needs: verify
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          # Linux (static musl builds — no glibc version dependency)
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            cross: true
          - target: aarch64-unknown-linux-musl
            os: ubuntu-latest
            cross: true
          # macOS
          - target: x86_64-apple-darwin
            os: macos-13        # Intel runner
            cross: false
          - target: aarch64-apple-darwin
            os: macos-latest    # Apple Silicon runner
            cross: false
          # Windows
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            cross: false

    steps:
      - uses: actions/checkout@v4

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

      - name: Install cross (Linux cross-compilation)
        if: matrix.cross
        run: cargo install cross --git https://github.com/cross-rs/cross

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ${{ matrix.target }}-cargo-

      - name: Build (cross)
        if: matrix.cross
        run: cross build --release --target ${{ matrix.target }} -p recursive-agent

      - name: Build (native)
        if: "!matrix.cross"
        run: cargo build --release --target ${{ matrix.target }} -p recursive-agent

      # Package into .tar.gz (Unix) or .zip (Windows)
      - name: Package (Unix)
        if: matrix.os != 'windows-latest'
        shell: bash
        run: |
          BIN="target/${{ matrix.target }}/release/recursive"
          ASSET="recursive-${{ matrix.target }}.tar.gz"
          tar -czf "$ASSET" -C "$(dirname $BIN)" "$(basename $BIN)"
          echo "ASSET=$ASSET" >> $GITHUB_ENV

      - name: Package (Windows)
        if: matrix.os == 'windows-latest'
        shell: pwsh
        run: |
          $BIN = "target\${{ matrix.target }}\release\recursive.exe"
          $ASSET = "recursive-${{ matrix.target }}.zip"
          Compress-Archive -Path $BIN -DestinationPath $ASSET
          "ASSET=$ASSET" | Out-File -FilePath $env:GITHUB_ENV -Append

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: recursive-${{ matrix.target }}
          path: ${{ env.ASSET }}
          retention-days: 1

  # ── 3. Create GitHub Release and attach binaries ──────────────────────────
  release:
    name: Create GitHub Release
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: List artifacts
        run: find artifacts -type f | sort

      - name: Compute checksums
        run: |
          cd artifacts
          find . -type f \( -name "*.tar.gz" -o -name "*.zip" \) | sort | while read f; do
            sha256sum "$f"
          done > ../SHA256SUMS.txt
          cat ../SHA256SUMS.txt

      - name: Create / update GitHub Release
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          # Create release if it doesn't exist yet
          if ! gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
            gh release create "$GITHUB_REF_NAME" \
              --repo "$GITHUB_REPOSITORY" \
              --title "$GITHUB_REF_NAME" \
              --generate-notes
          fi

          # Upload all binaries + checksums
          find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) | while read f; do
            gh release upload "$GITHUB_REF_NAME" "$f" \
              --repo "$GITHUB_REPOSITORY" \
              --clobber
          done

          gh release upload "$GITHUB_REF_NAME" SHA256SUMS.txt \
            --repo "$GITHUB_REPOSITORY" \
            --clobber

  # ── 4. Publish to crates.io ────────────────────────────────────────────────
  publish-crate:
    name: Publish to crates.io
    needs: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ubuntu-latest-cargo-publish-${{ hashFiles('**/Cargo.lock') }}

      - name: Publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
        run: cargo publish -p recursive-agent