name: Release SGLang Model Gateway Docker Image
on:
  push:
    branches:
      - main
    paths:
      - sgl-model-gateway/bindings/python/pyproject.toml
  workflow_dispatch:

jobs:
  publish:
    if: github.repository == 'sgl-project/sglang'
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build and Push
        run: |
          version=$(cat sgl-model-gateway/bindings/python/src/sglang_router/version.py | cut -d'"' -f2)
          tag=v${version}

          docker buildx build . -f docker/gateway.Dockerfile \
            --platform linux/amd64,linux/arm64 \
            -t lmsysorg/sgl-model-gateway:${tag} \
            -t lmsysorg/sgl-model-gateway:latest \
            --push
