synapse-gateway 0.2.0

OpenAI-compatible LLM router and gateway with streaming, tool calling, multi-provider fallback, native Vertex AI, and per-tenant cost accounting
Documentation
name: Release

on:
  push:
    tags: ["v*"]
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read

env:
  IMAGE: sustentabilitas/synapse-gateway

jobs:
  publish-crate:
    name: Publish crate (crates.io)
    # Tag push (vX.Y.Z) OR a manual run from the Actions tab / `gh workflow run release.yml`.
    if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: Resolve version (verify tag match on tag pushes)
        run: |
          set -euo pipefail
          CRATE="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')"
          if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
            TAG="${GITHUB_REF_NAME#v}"
            if [ "$TAG" != "$CRATE" ]; then
              echo "::error::git tag v$TAG does not match Cargo.toml version $CRATE"
              exit 1
            fi
            echo "Tag push: publishing v$CRATE"
          else
            echo "Manual dispatch: publishing Cargo.toml version $CRATE (crates.io rejects an already-published version)"
          fi
      - name: cargo publish
        run: cargo publish --locked
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  docker:
    name: Build & push image (Docker Hub)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ env.IMAGE }}
          tags: |
            type=semver,pattern={{version}}
            type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
            type=raw,value=edge,enable=${{ github.ref == 'refs/heads/main' }}
      - uses: docker/build-push-action@v6
        with:
          context: .
          platforms: linux/amd64
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max