agentic-codebase 0.3.0

Semantic code compiler for AI agents - transforms codebases into navigable concept graphs
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

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

    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install cross-compilation tools
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu

      - name: Build
        run: cargo build --workspace --release --target ${{ matrix.target }}
        env:
          CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc

      - name: Strip binary
        run: |
          strip target/${{ matrix.target }}/release/acb || true
          strip target/${{ matrix.target }}/release/agentic-codebase-mcp || true

      - name: Package
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          ASSET="agentic-codebase-${VERSION}-${{ matrix.triple }}"
          mkdir -p "${ASSET}"
          cp target/${{ matrix.target }}/release/acb "${ASSET}/"
          cp target/${{ matrix.target }}/release/agentic-codebase-mcp "${ASSET}/"
          tar czf "${ASSET}.tar.gz" "${ASSET}"

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: agentic-codebase-${{ matrix.triple }}
          path: "*.tar.gz"

  release:
    name: Create Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/download-artifact@v4
        with:
          path: artifacts
      - name: Validate release note file
        id: note
        shell: bash
        run: |
          set -euo pipefail
          VERSION="${GITHUB_REF_NAME#v}"
          NOTE_FILE="release-notes/v${VERSION}.md"
          if [ ! -f "${NOTE_FILE}" ]; then
            echo "Missing required release note: ${NOTE_FILE}"
            exit 1
          fi
          python3 - <<'PY' "${NOTE_FILE}"
          import re
          import sys
          from pathlib import Path
          path = Path(sys.argv[1])
          text = path.read_text(encoding="utf-8")
          required = [
              "## Executive Summary",
              "## Business Impact",
              "## Rollout Guidance",
              "## Source Links",
          ]
          for heading in required:
              if heading not in text:
                  raise SystemExit(f"Missing required heading: {heading}")
          if "template_draft" in text.lower():
              raise SystemExit("Template marker still present in release notes.")
          if "as an ai" in text.lower():
              raise SystemExit("Release notes contain forbidden phrasing: as an ai")
          paragraphs = []
          for block in re.split(r"\n\s*\n", text):
              b = block.strip()
              if not b or b.startswith("##") or b.startswith("- "):
                  continue
              paragraphs.append(b)
          if len(paragraphs) < 3:
              raise SystemExit("Release note must contain at least 3 narrative paragraphs.")
          for idx, p in enumerate(paragraphs[:3], start=1):
              if len(p) < 120:
                  raise SystemExit(f"Paragraph {idx} too short ({len(p)} chars).")
          PY
          echo "file=${NOTE_FILE}" >> "$GITHUB_OUTPUT"

      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          files: artifacts/**/*.tar.gz
          body_path: ${{ steps.note.outputs.file }}
          generate_release_notes: false
          draft: false
          prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') }}

  publish-crate:
    name: Publish to crates.io (core + ffi + mcp + cli)
    needs: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish crates in canonical order
        shell: bash
        run: |
          set -euo pipefail

          publish_crate() {
            local pkg="$1"
            local retries="${2:-12}"
            local attempt
            local output

            for attempt in $(seq 1 "$retries"); do
              echo "Publish attempt ${attempt}/${retries} for ${pkg}..."
              if output="$(cargo publish -p "${pkg}" --token "${{ secrets.CARGO_REGISTRY_TOKEN }}" 2>&1)"; then
                echo "$output"
                return 0
              fi

              echo "$output"
              if echo "$output" | grep -Eqi "already uploaded|already exists on crates\\.io index"; then
                echo "${pkg} already published for this version; continuing."
                return 0
              fi
              if echo "$output" | grep -Eqi "failed to select a version for the requirement|no matching package named|could not find .* in registry"; then
                echo "Dependency index propagation not ready yet; waiting before retry..."
                sleep 20
                continue
              fi
              return 1
            done

            echo "Timed out waiting for crates.io index propagation for ${pkg}."
            return 1
          }

          publish_crate "agentic-codebase"
          publish_crate "agentic-codebase-ffi"
          publish_crate "agentic-codebase-mcp"
          publish_crate "agentic-codebase-cli"