apiforge 0.4.0

Production-grade API release automation CLI. From merged code to healthy pods in production — one command.
Documentation
name: Release

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

env:
  CARGO_TERM_COLOR: always
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
  # First, run tests to ensure quality
  test:
    name: Pre-release Tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v6

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

      - name: Run tests
        run: cargo test --all-features --locked

      - name: Run clippy
        run: cargo clippy --locked --all-targets --all-features -- -D warnings

  # Build binaries for all platforms
  build:
    name: Build (${{ matrix.target }})
    needs: test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: apiforge-linux-amd64
            binary: apiforge
          - os: ubuntu-24.04-arm
            target: aarch64-unknown-linux-gnu
            artifact: apiforge-linux-arm64
            binary: apiforge
          - os: macos-15-intel
            target: x86_64-apple-darwin
            artifact: apiforge-darwin-amd64
            binary: apiforge
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: apiforge-darwin-arm64
            binary: apiforge
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: apiforge-windows-amd64
            binary: apiforge.exe
    steps:
      - name: Checkout code
        uses: actions/checkout@v6

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

      - name: Install Linux build dependencies
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends pkg-config libssl-dev
          sudo rm -rf /var/lib/apt/lists/*

      - name: Install macOS build dependencies
        if: runner.os == 'macOS'
        run: |
          brew install openssl@3 pkg-config
          echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> "$GITHUB_ENV"
          echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> "$GITHUB_ENV"

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

      - name: Create archive (Unix)
        if: runner.os != 'Windows'
        run: |
          cd target/${{ matrix.target }}/release
          tar -czvf ../../../${{ matrix.artifact }}.tar.gz ${{ matrix.binary }}

      - name: Create archive (Windows)
        if: runner.os == 'Windows'
        run: |
          cd target/${{ matrix.target }}/release
          7z a ../../../${{ matrix.artifact }}.zip ${{ matrix.binary }}

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

  # Publish to crates.io
  publish-crates:
    name: Publish to crates.io
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v6

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

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

  # Create GitHub Release with binaries
  github-release:
    name: GitHub Release
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v6

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

      - name: Display artifacts
        run: ls -R artifacts/

      - name: Extract version from tag
        id: version
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

      - name: Generate changelog
        id: changelog
        run: |
          # Extract changelog for this version
          VERSION=${{ steps.version.outputs.VERSION }}
          if [ -f CHANGELOG.md ]; then
            # Extract section between this version and next
            sed -n "/## \[${VERSION}\]/,/## \[/p" CHANGELOG.md | head -n -1 > release_notes.md
          else
            echo "Release ${VERSION}" > release_notes.md
          fi

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          name: Apiforge v${{ steps.version.outputs.VERSION }}
          body_path: release_notes.md
          draft: false
          prerelease: false
          files: |
            artifacts/**/*.tar.gz
            artifacts/**/*.zip
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}