Bump version to 0.1.4 #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release (crates.io + Docker) | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g., 0.1.0) used when manually dispatching' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: Lint & Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry + build | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Test | |
| run: cargo test --all --all-features --no-fail-fast | |
| publish-crates: | |
| name: Publish to crates.io | |
| runs-on: ubuntu-latest | |
| needs: test | |
| # Only run if token is configured; GitHub does not allow referencing secrets in 'if' for top-level jobs with older expression context. | |
| # Instead, check within steps and skip when missing. | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry + build | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Extract version | |
| id: version | |
| shell: bash | |
| run: | | |
| ver="${GITHUB_REF_NAME#v}" | |
| if [ -z "$ver" ] || [ "$ver" = "$GITHUB_REF_NAME" ]; then | |
| ver="${{ github.event.inputs.version }}" | |
| fi | |
| ver="${ver#v}" | |
| echo "version=$ver" >> "$GITHUB_OUTPUT" | |
| echo "Release version: $ver" | |
| - name: Verify workspace/crate versions match tag | |
| shell: bash | |
| run: | | |
| TAG="${{ steps.version.outputs.version }}" | |
| echo "Expected tag version: $TAG" | |
| echo "Checking root workspace version..." | |
| if ! grep -qE '^version\s*=\s*"'"$TAG"'"' Cargo.toml; then | |
| echo "Error: root Cargo.toml workspace version does not match tag $TAG" >&2; exit 1; fi | |
| echo "Checking crate manifests..." | |
| for f in ultrafast-models-sdk/Cargo.toml ultrafast-gateway/Cargo.toml; do | |
| echo "- $f" | |
| if grep -qE '^version\s*=\s*"' "$f"; then | |
| grep -qE '^version\s*=\s*"'"$TAG"'"' "$f" || { echo "Error: $f version does not match tag $TAG" >&2; exit 1; } | |
| else | |
| grep -qE '^version\.workspace\s*=\s*true' "$f" || { echo "Error: $f missing version or workspace version flag" >&2; exit 1; } | |
| fi | |
| done | |
| - name: Check for crates.io token | |
| id: tokencheck | |
| env: | |
| TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN || secrets.CRATES_IO_TOKEN }} | |
| shell: bash | |
| run: | | |
| if [ -z "$TOKEN" ]; then | |
| echo "has_token=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_token=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish ultrafast-models-sdk | |
| if: steps.tokencheck.outputs.has_token == 'true' | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN || secrets.CRATES_IO_TOKEN }} | |
| run: | | |
| cargo publish -p ultrafast-models-sdk | |
| - name: Wait for crates.io index update | |
| if: steps.tokencheck.outputs.has_token == 'true' | |
| run: | | |
| echo "Sleeping to allow crates.io index to update..." | |
| sleep 90 | |
| - name: Rewrite gateway dependency to published version | |
| if: steps.tokencheck.outputs.has_token == 'true' | |
| run: | | |
| ver="${{ steps.version.outputs.version }}" | |
| sed -i "s#ultrafast-models-sdk = { path = \"../ultrafast-models-sdk\" }#ultrafast-models-sdk = \"$ver\"#" ultrafast-gateway/Cargo.toml | |
| echo "Updated dependency in ultrafast-gateway/Cargo.toml to version $ver" | |
| - name: Commit dependency update | |
| if: steps.tokencheck.outputs.has_token == 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add ultrafast-gateway/Cargo.toml | |
| git commit -m "Update ultrafast-models-sdk dependency to published version ${{ steps.version.outputs.version }}" | |
| - name: Publish ultrafast-gateway | |
| if: steps.tokencheck.outputs.has_token == 'true' | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN || secrets.CRATES_IO_TOKEN }} | |
| run: | | |
| cargo publish -p ultrafast-gateway --allow-dirty | |
| docker: | |
| name: Build & Push Docker image (GHCR + Docker Hub) | |
| runs-on: ubuntu-latest | |
| needs: test | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history for better layer caching | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: | | |
| image=moby/buildkit:v0.13.0 | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Extract version | |
| id: version | |
| shell: bash | |
| run: | | |
| ver="${GITHUB_REF_NAME#v}" | |
| if [ -z "$ver" ] || [ "$ver" = "$GITHUB_REF_NAME" ]; then | |
| ver="${{ github.event.inputs.version }}" | |
| fi | |
| ver="${ver#v}" | |
| echo "version=$ver" >> "$GITHUB_OUTPUT" | |
| echo "Building version: $ver" | |
| - name: Get timestamp | |
| id: timestamp | |
| run: echo "iso8601=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push to both registries | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/ultrafast-ai-gateway:${{ steps.version.outputs.version }} | |
| ghcr.io/${{ github.repository_owner }}/ultrafast-ai-gateway:latest | |
| ${{ secrets.DOCKERHUB_USERNAME }}/ultrafast-ai-gateway:${{ steps.version.outputs.version }} | |
| ${{ secrets.DOCKERHUB_USERNAME }}/ultrafast-ai-gateway:latest | |
| build-args: | | |
| RUSTFLAGS=-C target-cpu=native | |
| BUILDKIT_INLINE_CACHE=1 | |
| cache-from: | | |
| type=gha,scope=docker-cache | |
| type=registry,ref=ghcr.io/${{ github.repository_owner }}/ultrafast-ai-gateway:buildcache | |
| type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/ultrafast-ai-gateway:buildcache | |
| cache-to: | | |
| type=gha,mode=max,scope=docker-cache | |
| type=registry,ref=ghcr.io/${{ github.repository_owner }}/ultrafast-ai-gateway:buildcache,mode=max | |
| type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/ultrafast-ai-gateway:buildcache,mode=max | |
| provenance: false # Disable for faster builds | |
| sbom: false # Disable for faster builds | |
| labels: | | |
| org.opencontainers.image.title=Ultrafast Gateway | |
| org.opencontainers.image.description=High-performance LLM gateway with advanced routing and caching | |
| org.opencontainers.image.version=${{ steps.version.outputs.version }} | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| org.opencontainers.image.vendor=Ultrafast AI | |
| org.opencontainers.image.licenses=MIT | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.created=${{ steps.timestamp.outputs.iso8601 }} | |
| maintainer=techgopal <techgopal2@gmail.com> | |
| - name: Verify images | |
| run: | | |
| echo "Verifying built images..." | |
| echo "GHCR Images:" | |
| docker images | grep ghcr.io || echo "No local GHCR images found" | |
| echo "Docker Hub Images:" | |
| docker images | grep ultrafast-ai-gateway || echo "No local Docker Hub images found" | |
| echo "Image verification complete" | |
| - name: Cleanup | |
| run: | | |
| echo "Cleaning up Docker system..." | |
| docker system prune -f | |