chrome-agent 0.14.0

Browser automation for AI agents. Single binary, zero deps, CDP direct to Chrome.
name: Release

on:
  push:
    tags:
      - 'v*'

permissions:
  contents: write

jobs:
  build:
    strategy:
      matrix:
        include:
          - target: x86_64-apple-darwin
            os: macos-latest
            artifact: chrome-agent-darwin-x64
          - target: aarch64-apple-darwin
            os: macos-latest
            artifact: chrome-agent-darwin-arm64
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            artifact: chrome-agent-linux-x64
          - target: aarch64-unknown-linux-musl
            os: ubuntu-latest
            artifact: chrome-agent-linux-arm64
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            artifact: chrome-agent-windows-x64.exe

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v6

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

      # Linux binaries are built fully static against musl: zero glibc dependency,
      # so they run on every distro regardless of glibc version (fixes #3).
      # cargo-zigbuild uses zig as a hermetic cross-linker — one toolchain for both
      # x86_64 and aarch64. Versions are pinned for reproducibility.
      - name: Install zig + cargo-zigbuild (Linux)
        if: contains(matrix.target, 'linux')
        run: |
          curl -sSL https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz | tar -xJ
          echo "$PWD/zig-linux-x86_64-0.13.0" >> "$GITHUB_PATH"
          cargo install cargo-zigbuild --version 0.22.3 --locked

      - name: Build (Linux — static musl)
        if: contains(matrix.target, 'linux')
        run: cargo zigbuild --release --target ${{ matrix.target }}

      - name: Build (macOS / Windows)
        if: ${{ !contains(matrix.target, 'linux') }}
        run: cargo build --release --target ${{ matrix.target }}

      - name: Rename binary (Unix)
        if: runner.os != 'Windows'
        run: cp target/${{ matrix.target }}/release/chrome-agent ${{ matrix.artifact }}

      - name: Rename binary (Windows)
        if: runner.os == 'Windows'
        run: cp target/${{ matrix.target }}/release/chrome-agent.exe ${{ matrix.artifact }}

      # The npm postinstall downloads this file over the network and chmod +x's it.
      # Without a checksum published beside it there is nothing for the installer to
      # check the bytes against — a truncated download or a re-uploaded asset installs
      # as a trusted native binary.
      #
      # Node rather than shasum/sha256sum: it is preinstalled on all three runner
      # images, spelled identically on each (the Windows job runs under Git bash, where
      # which of the two shell tools exists is a question nobody wants to answer during
      # a release), and it is the same implementation the installer verifies with.
      - name: Checksum the binary
        shell: bash
        run: |
          node -e '
            const fs = require("fs"), crypto = require("crypto");
            const file = process.argv[1];
            const hash = crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
            fs.writeFileSync(file + ".sha256", hash + "\n");
            console.log(file + ": " + hash);
          ' "${{ matrix.artifact }}"

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

  release:
    needs: build
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

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

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

  crates:
    needs: release
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

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

      - name: Publish to crates.io
        run: cargo publish --allow-dirty
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  npm:
    needs: release
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write

    steps:
      - uses: actions/checkout@v6

      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: '24'
          registry-url: 'https://registry.npmjs.org'

      - name: Publish to npm (OIDC Trusted Publishing)
        working-directory: npm
        run: npm publish --access public --provenance