autom8-cli 0.3.0

CLI automation tool for orchestrating Claude-powered development
Documentation
name: Release

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            artifact_name: autom8
            asset_name: autom8-linux-x86_64
          - target: x86_64-apple-darwin
            os: macos-latest
            artifact_name: autom8
            asset_name: autom8-macos-x86_64
          - target: aarch64-apple-darwin
            os: macos-latest
            artifact_name: autom8
            asset_name: autom8-macos-aarch64
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            artifact_name: autom8.exe
            asset_name: autom8-windows-x86_64.exe

    steps:
      - uses: actions/checkout@v6

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

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

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

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

      - name: Rename binary
        shell: bash
        run: mv target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}

      - name: Upload artifact
        uses: actions/upload-artifact@v6
        with:
          name: ${{ matrix.asset_name }}
          path: ${{ matrix.asset_name }}

  release:
    name: Create Release
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - uses: actions/checkout@v6

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

      - name: Extract release notes from CHANGELOG
        id: changelog
        run: |
          # Extract version from tag (e.g., v0.2.0 -> 0.2.0)
          VERSION=${GITHUB_REF_NAME#v}

          # Extract the section for this version from CHANGELOG.md
          # Looks for ## [VERSION] and extracts until the next ## or end of file
          NOTES=$(awk -v ver="$VERSION" '
            /^## \[/ {
              if (found) exit
              if (index($0, "[" ver "]")) found=1
              next
            }
            found { print }
          ' CHANGELOG.md)

          # If no notes found, use a default message
          if [ -z "$NOTES" ]; then
            NOTES="Release $GITHUB_REF_NAME"
          fi

          # Write to file for multiline support
          echo "$NOTES" > release_notes.txt

      - name: Prepare release assets
        run: |
          mkdir -p release_assets
          for dir in artifacts/*/; do
            asset_name=$(basename "$dir")
            mv "$dir$asset_name" "release_assets/$asset_name"
          done

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          body_path: release_notes.txt
          files: release_assets/*
          fail_on_unmatched_files: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  publish:
    name: Publish to crates.io
    needs: release
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

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

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