symforge 7.4.5

SymForge — in-memory code intelligence MCP server for Claude Code, Codex, and Gemini CLI
Documentation
name: Release

on:
  push:
    branches:
      - main
  workflow_dispatch:
    inputs:
      tag:
        description: Existing release tag to rebuild or republish, for example v0.3.12
        required: false
        type: string

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

permissions:
  actions: write
  contents: write
  issues: write
  pull-requests: write

jobs:
  verify-main-push:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Validate commit subjects for this push
        if: github.event_name == 'push'
        run: python execution/conventional_commits.py check-push-range "${{ github.event.before }}" "$GITHUB_SHA"

      - name: Validate manual run HEAD commit subject
        if: github.event_name == 'workflow_dispatch'
        run: python execution/conventional_commits.py check-range "HEAD^!"

      - name: Run version sync tests
        run: python -m unittest discover -s execution -p 'test_*.py'

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: "1.94.0"

      - name: Run cargo check
        run: cargo check

      - name: Run Rust tests
        run: cargo test --all-targets -- --test-threads=1

      - name: Build release binary on main pushes
        run: cargo build --release

      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Test npm package
        working-directory: npm
        run: npm test

  prepare-release:
    needs: verify-main-push
    runs-on: ubuntu-latest
    outputs:
      release_created: ${{ steps.context.outputs.release_created }}
      tag_name: ${{ steps.context.outputs.tag_name }}
      version: ${{ steps.context.outputs.version }}
      release_ref: ${{ steps.context.outputs.release_ref }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Run version sync tests
        run: python -m unittest discover -s execution -p 'test_*.py'

      - id: release
        if: ${{ github.event_name != 'workflow_dispatch' || inputs.tag == '' }}
        uses: googleapis/release-please-action@v4
        with:
          token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
          include-component-in-tag: false
          config-file: .github/release-please-config.json
          manifest-file: .github/.release-please-manifest.json

      - name: Auto-merge release PR
        if: ${{ steps.release.outputs.prs_created == 'true' }}
        env:
          GH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
          GH_REPO: ${{ github.repository }}
        run: |
          # Wait for PR label to propagate, then find the release PR
          for attempt in 1 2 3 4 5 6; do
            sleep 10
            PR=$(gh pr list --label "autorelease: pending" --json number --jq '.[0].number // empty')
            if [[ -n "$PR" ]]; then
              break
            fi
            echo "Attempt $attempt: no pending release PR found yet, retrying..."
          done
          if [[ -z "$PR" ]]; then
            echo "::warning::No pending release PR found after 60s — skipping auto-merge"
            exit 0
          fi
          echo "Auto-merging release PR #$PR"
          gh pr merge "$PR" --merge --delete-branch
          # The PAT-powered merge triggers a new workflow run where
          # release-please creates the release + tag, then build proceeds.

      - id: context
        shell: bash
        env:
          MANUAL_TAG: ${{ inputs.tag }}
          RELEASE_CREATED: ${{ steps.release.outputs.release_created }}
          RELEASE_TAG: ${{ steps.release.outputs.tag_name }}
          RELEASE_VERSION: ${{ steps.release.outputs.version }}
        run: |
          git fetch --tags --force

          CANONICAL_TAG_RE='^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'
          TAG_NAME=""
          VERSION=""

          if [[ -n "$MANUAL_TAG" ]]; then
            if [[ ! "$MANUAL_TAG" =~ $CANONICAL_TAG_RE ]]; then
              echo "::error::Manual rebuild tags must use canonical vX.Y.Z format. Received '$MANUAL_TAG'."
              exit 1
            fi
            TAG_NAME="$MANUAL_TAG"
          elif [[ "$RELEASE_CREATED" == "true" ]]; then
            if [[ -z "$RELEASE_VERSION" ]]; then
              echo "::error::release-please did not return a version for the created release."
              exit 1
            fi
            TAG_NAME="$RELEASE_TAG"
            VERSION="$RELEASE_VERSION"
            EXPECTED_TAG="v$RELEASE_VERSION"
            if [[ "$TAG_NAME" != "$EXPECTED_TAG" ]]; then
              echo "::error::release-please returned tag '$TAG_NAME' but the canonical tag for this repository is '$EXPECTED_TAG'."
              exit 1
            fi
          else
            TAG_NAME="$(git tag --points-at "$GITHUB_SHA" 'v*' | sort -V | tail -n1)"
          fi

          if [[ -n "$TAG_NAME" ]]; then
            if [[ ! "$TAG_NAME" =~ $CANONICAL_TAG_RE ]]; then
              echo "::error::Resolved release tag '$TAG_NAME' does not match canonical vX.Y.Z format."
              exit 1
            fi

            if ! git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
              echo "::error::Tag '$TAG_NAME' does not exist in this repository."
              exit 1
            fi

            if [[ -z "$VERSION" ]]; then
              VERSION="${TAG_NAME#v}"
            fi

            echo "release_created=true" >> "$GITHUB_OUTPUT"
            echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
            echo "version=$VERSION" >> "$GITHUB_OUTPUT"
            echo "release_ref=$TAG_NAME" >> "$GITHUB_OUTPUT"
          else
            echo "release_created=false" >> "$GITHUB_OUTPUT"
            echo "release_ref=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
          fi

  build:
    needs: prepare-release
    if: needs.prepare-release.outputs.release_created == 'true'
    strategy:
      matrix:
        include:
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: symforge-windows-x64.exe
            binary: target/x86_64-pc-windows-msvc/release/symforge.exe
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: symforge-linux-x64
            binary: target/x86_64-unknown-linux-gnu/release/symforge
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: symforge-macos-arm64
            binary: target/aarch64-apple-darwin/release/symforge
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact: symforge-macos-x64
            binary: target/x86_64-apple-darwin/release/symforge

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.prepare-release.outputs.release_ref }}

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Verify release versions
        run: python execution/version_sync.py check --tag "${{ needs.prepare-release.outputs.tag_name }}"

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

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

      - name: Rename artifact
        shell: bash
        run: cp "${{ matrix.binary }}" "${{ matrix.artifact }}"

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.artifact }}
          path: ${{ matrix.artifact }}
          if-no-files-found: error

  build-npm-package:
    needs: prepare-release
    if: needs.prepare-release.outputs.release_created == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.prepare-release.outputs.release_ref }}

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Verify release versions
        run: python execution/version_sync.py check --tag "${{ needs.prepare-release.outputs.tag_name }}"

      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Test npm installer
        working-directory: npm
        run: npm test

      - name: Build npm tarball
        working-directory: npm
        run: npm pack

      - name: Upload npm package artifact
        uses: actions/upload-artifact@v4
        with:
          name: npm-package
          path: npm/symforge-${{ needs.prepare-release.outputs.version }}.tgz
          if-no-files-found: error

  upload-release-assets:
    needs:
      - prepare-release
      - build
      - build-npm-package
    if: needs.prepare-release.outputs.release_created == 'true'
    runs-on: ubuntu-latest
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts
          merge-multiple: true

      - name: Upload assets to GitHub release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_REPO: ${{ github.repository }}
        run: gh release upload "${{ needs.prepare-release.outputs.tag_name }}" artifacts/* --clobber

  cargo-publish:
    needs: [prepare-release]
    if: needs.prepare-release.outputs.release_created == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  npm-publish:
    needs:
      - prepare-release
      - build-npm-package
      - upload-release-assets
    if: needs.prepare-release.outputs.release_created == 'true'
    runs-on: ubuntu-latest
    environment: npm-publish
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.prepare-release.outputs.release_ref }}

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - uses: actions/setup-node@v4
        with:
          node-version: 20
          registry-url: https://registry.npmjs.org

      - name: Download npm package artifact
        uses: actions/download-artifact@v4
        with:
          name: npm-package
          path: dist

      - name: Verify npm package artifact
        shell: bash
        run: |
          TAR_PATH="./dist/symforge-${{ needs.prepare-release.outputs.version }}.tgz"
          test -f "$TAR_PATH"
          ls -l "$TAR_PATH"

      - name: Publish to npm
        run: >
          python execution/release_ops.py publish-npm
          --tarball "./dist/symforge-${{ needs.prepare-release.outputs.version }}.tgz"
          --package-name symforge
          --version "${{ needs.prepare-release.outputs.version }}"
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}