apexe 0.5.0

Outside-In CLI-to-Agent Bridge
name: Release Binaries

permissions:
  contents: read

on:
  push:
    tags:
      - "rust/v*"
  workflow_dispatch:
    inputs:
      tag:
        description: "Existing tag to build and attach binaries to (e.g. rust/v0.5.0)"
        required: true

jobs:
  build:
    name: Build (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-24.04-arm

    steps:
      - name: Checkout
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          ref: ${{ inputs.tag || github.ref }}

      # dtolnay/rust-toolchain@stable tracks a rolling branch rather than
      # tagged releases; pinned to the branch HEAD at the time this was added.
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
        with:
          targets: ${{ matrix.target }}

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

      - name: Package
        shell: bash
        run: |
          set -euo pipefail
          out="apexe-${{ matrix.target }}"
          mkdir -p "$out"
          cp "target/${{ matrix.target }}/release/apexe" "$out/"
          cp README.md "$out/" 2>/dev/null || true
          tar -czf "${out}.tar.gz" "$out"
          shasum -a 256 "${out}.tar.gz" > "${out}.tar.gz.sha256"

      - name: Upload artifact
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: apexe-${{ matrix.target }}
          path: |
            apexe-${{ matrix.target }}.tar.gz
            apexe-${{ matrix.target }}.tar.gz.sha256
          if-no-files-found: error

  release:
    name: Attach to GitHub Release
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - name: Download artifacts
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          path: dist
          merge-multiple: true

      - name: Publish release assets
        uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
        with:
          tag_name: ${{ inputs.tag || github.ref_name }}
          files: dist/*
          fail_on_unmatched_files: true