Skip to content

Workflow file for this run

name: Upload Python Package and Docker Image on Release
on:
release:
types: [created]
jobs:
pypi-publish:
name: Publish release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/optillm
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
docker-publish:
name: Publish Docker image
runs-on: ubuntu-22.04
needs: pypi-publish
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
# Add aggressive cleanup before any Docker operations
- name: Free disk space
run: |
# Clean Docker
docker system prune -af
docker image prune -af
docker builder prune -af
df -h
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
buildkitd-flags: --debug
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata for proxy_only image
- name: Extract metadata for proxy_only Docker
id: meta-proxy
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: |
suffix=-proxy
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
# Build and push proxy AMD64
- name: Build and push proxy_only Docker image AMD64
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.proxy_only
push: true
platforms: linux/amd64
tags: ${{ steps.meta-proxy.outputs.tags }}
labels: ${{ steps.meta-proxy.outputs.labels }}
cache-from: type=gha,scope=proxy-amd64
cache-to: type=gha,scope=proxy-amd64,mode=max
outputs: type=registry,compression=zstd,compression-level=5
# Cleanup after AMD64 build
- name: Cleanup after AMD64 build
run: |
docker system prune -af
docker builder prune -af
df -h
# Build proxy ARM64
- name: Build and push proxy_only Docker image ARM64
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.proxy_only
push: true
platforms: linux/arm64
tags: ${{ steps.meta-proxy.outputs.tags }}
labels: ${{ steps.meta-proxy.outputs.labels }}
cache-from: type=gha,scope=proxy-arm64
cache-to: type=gha,scope=proxy-arm64,mode=max
outputs: type=registry,compression=zstd,compression-level=5
# Cleanup after proxy builds
- name: Cleanup after proxy builds
run: |
docker system prune -af
docker builder prune -af
find /tmp -type f -user $(id -u) -exec rm -f {} + 2>/dev/null || true
df -h
# Extract metadata for full image
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
latest
# Build full image AMD64
- name: Build and push Docker image AMD64
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=full-amd64
cache-to: type=gha,scope=full-amd64,mode=max
outputs: type=registry,compression=zstd,compression-level=5
# Cleanup between architectures
- name: Cleanup between architectures
run: |
docker system prune -af
docker builder prune -af
df -h
# Build full image ARM64
- name: Build and push Docker image ARM64
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=full-arm64
cache-to: type=gha,scope=full-arm64,mode=max
outputs: type=registry,compression=zstd,compression-level=5