Workflow file for this run
This file contains 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: 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 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- 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 image | |
- name: Build and push proxy_only Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile.proxy_only | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta-proxy.outputs.tags }} | |
labels: ${{ steps.meta-proxy.outputs.labels }} | |
cache-from: type=gha,scope=proxy | |
cache-to: type=gha,scope=proxy,mode=max | |
# Add cleanup steps after proxy build | |
- name: Clean up disk space after proxy build | |
run: | | |
# Remove all unused docker data including stopped containers, unused networks, dangling images, and build cache | |
docker system prune -af | |
# Remove all unused build cache | |
docker builder prune -af | |
# Optional: If you need more aggressive cleanup | |
rm -rf /tmp/* | |
- 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 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |