Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/scripts/determine_release_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -eu pipefail

# --- SCHEDULE TRIGGER ---
if [[ "$GH_EVENT_NAME" == "schedule" ]]; then
echo "Trigger: Schedule - Generating nightly build"

# --- Get Base Version from Tag ---
echo "Fetching latest tags..."
git fetch --tags --force
echo "Finding the latest stable version tag (vX.Y.Z)..."
LATEST_STABLE_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [[ -z "$LATEST_STABLE_TAG" ]]; then
echo "Warning: No stable tag found."
exit 1
else
BASE_VERSION=${LATEST_STABLE_TAG#v}
fi
echo "Using BASE_VERSION=${BASE_VERSION}"

# --- Generate Nightly Version ---
DATETIME_STR=$(date -u +%Y%m%d%H%M)
VERSION="${BASE_VERSION}.dev${DATETIME_STR}"

# --- PUSH TAG TRIGGER ---
elif [[ "$GH_EVENT_NAME" == "push" && "$GH_REF" == refs/tags/* ]]; then
echo "Trigger: Push Tag - Generating stable build"
TAG_NAME="$GH_REF_NAME"
VERSION=${TAG_NAME#v}

else
echo "Error: Unknown or unsupported trigger."
exit 1
fi

# --- output ---
echo "Final determined values: VERSION=${VERSION}"
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish Package to PyPI
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your current setup will lead to triggering the release workflow even if the tag is created on a non-main branch.

We only want the release tag to go off if it's created on the protected (main) branch. This is required to ensure only admins or selected people can trigger a stable release via release tag


on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
schedule:
- cron: '0 8 * * *'

jobs:
pypi_publish:
name: Build and Publish
runs-on: ubuntu-latest

permissions:
id-token: write
contents: read

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if tag is on main branch
if: github.event_name == 'push'
run: |
echo "Checking if tag ${{ github.ref_name }} is on main branch..."
if git branch -r --contains ${{ github.ref_name }} | grep -q "origin/main"; then
echo "Tag is on origin/main. Proceeding with release."
else
echo "ERROR Tag ${{ github.ref_name }} is not on origin/main."
echo "This release will be aborted to prevent publishing from a non-main branch."
exit 1
fi

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Determine Version
id: vars
env:
GH_EVENT_NAME: ${{ github.event_name }}
GH_REF_NAME: ${{ github.ref_name }}
GH_REF: ${{ github.ref }}
run: bash .github/scripts/determine_release_vars.sh

- name: Install dependencies (build)
run:
python3 -m pip install build

- name: Build package (sdist and wheel)
env:
VLLM_VERSION_OVERRIDE: ${{ steps.vars.outputs.VERSION }}
run: python3 -m build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Publish completed message
run: echo "---Build and publish completed successfully.---"
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include requirements.txt
include README.md
include version.py
include tpu_inference/models/jax/utils/quantization/configs/*.yaml