Skip to content

Commit a1d7ca1

Browse files
author
Ylang Tsou
committed
[Feature] Add automated PyPI publishing workflow
This commit introduces a complete GitHub Actions workflow for automatically building and publishing the Python package to PyPI. - Adds the `release.yml` workflow, supporting multiple triggers: Tag push and Schedule. - Adds the `determine_release_vars.sh` script, which contains the core versioning logic. Signed-off-by: Ylang Tsou <ylangt@google.com>
1 parent 5f5ca02 commit a1d7ca1

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -eu pipefail
3+
4+
# --- SCHEDULE TRIGGER ---
5+
if [[ "$GH_EVENT_NAME" == "schedule" ]]; then
6+
echo "Trigger: Schedule - Generating nightly build"
7+
8+
# --- Get Base Version from Tag ---
9+
echo "Fetching latest tags..."
10+
git fetch --tags --force
11+
echo "Finding the latest stable version tag (vX.Y.Z)..."
12+
LATEST_STABLE_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
13+
if [[ -z "$LATEST_STABLE_TAG" ]]; then
14+
echo "Warning: No stable tag found."
15+
exit 1
16+
else
17+
BASE_VERSION=${LATEST_STABLE_TAG#v}
18+
fi
19+
echo "Using BASE_VERSION=${BASE_VERSION}"
20+
21+
# --- Generate Nightly Version ---
22+
DATETIME_STR=$(date -u +%Y%m%d%H%M)
23+
VERSION="${BASE_VERSION}.dev${DATETIME_STR}"
24+
25+
# --- PUSH TAG TRIGGER ---
26+
elif [[ "$GH_EVENT_NAME" == "push" && "$GH_REF" == refs/tags/* ]]; then
27+
echo "Trigger: Push Tag - Generating stable build"
28+
TAG_NAME="$GH_REF_NAME"
29+
VERSION=${TAG_NAME#v}
30+
31+
else
32+
echo "Error: Unknown or unsupported trigger."
33+
exit 1
34+
fi
35+
36+
# --- output ---
37+
echo "Final determined values: VERSION=${VERSION}"
38+
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish Package to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
7+
schedule:
8+
- cron: '0 8 * * *'
9+
10+
jobs:
11+
pypi_publish:
12+
name: Build and Publish
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
id-token: write
17+
contents: read
18+
19+
steps:
20+
- name: Checkout Code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.x'
29+
30+
- name: Determine Version
31+
id: vars
32+
env:
33+
GH_EVENT_NAME: ${{ github.event_name }}
34+
GH_REF_NAME: ${{ github.ref_name }}
35+
GH_REF: ${{ github.ref }}
36+
run: bash .github/scripts/determine_release_vars.sh
37+
38+
- name: Install dependencies (build)
39+
run:
40+
python3 -m pip install build
41+
42+
- name: Build package (sdist and wheel)
43+
env:
44+
VLLM_VERSION_OVERRIDE: ${{ steps.vars.outputs.VERSION }}
45+
run: python3 -m build
46+
47+
- name: Publish package distributions to PyPI
48+
uses: pypa/gh-action-pypi-publish@release/v1
49+
50+
- name: Publish completed message
51+
run: echo "---Build and publish completed successfully.---"

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
include requirements.txt
22
include README.md
3-
include version.py
43
include tpu_inference/models/jax/utils/quantization/configs/*.yaml

0 commit comments

Comments
 (0)