From 576d624eecc357923b025dea15633497caddcc11 Mon Sep 17 00:00:00 2001 From: Yueming Hao Date: Wed, 17 Dec 2025 15:15:05 -0800 Subject: [PATCH 1/2] PR-13: Add nightly PyPI publish workflow Add GitHub Actions workflow for automated nightly PyPI publishing. Features: - Daily scheduled builds at 07:18 UTC - On-demand publishing via git tags (v* or *.*.*) - Trusted Publishing (OIDC) for secure PyPI uploads - Smart commit detection: only publish when python/ changes - Downloads check_new_commits.sh from tritonparse repo The workflow uses tritonparse's check_new_commits.sh script with PACKAGE_PATH=python/ to filter commits to the Python package only. --- .github/workflows/nightly-pypi.yml | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/nightly-pypi.yml diff --git a/.github/workflows/nightly-pypi.yml b/.github/workflows/nightly-pypi.yml new file mode 100644 index 0000000..0db56de --- /dev/null +++ b/.github/workflows/nightly-pypi.yml @@ -0,0 +1,82 @@ +name: Nightly PyPI Publish +on: + schedule: + - cron: "18 7 * * *" # 07:18 UTC daily + workflow_dispatch: {} # allow manual runs (no publish) + push: + tags: + - "v*" + - "*.*.*" + +permissions: + contents: read + id-token: write # Required for Trusted Publishing (OIDC) + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # setuptools-scm requires full history/tags + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Check for new commits since last nightly + id: check + if: github.ref_type != 'tag' + env: + PACKAGE_NAME: cutracer + PACKAGE_PATH: python/ + run: | + curl -fsSL https://github.com/meta-pytorch/tritonparse/raw/refs/heads/main/.github/scripts/check_new_commits.sh | bash + + - name: Compute nightly version from latest tag (next patch + timestamp) + id: ver + if: github.ref_type != 'tag' && steps.check.outputs.should_publish != 'false' + run: | + # Get latest tag; allow 'v' prefix; fail if none + if ! TAG=$(git describe --tags --abbrev=0 2>/dev/null); then + echo "::error title=No git tag found::Repository has no tags. Add a semver tag like v0.1.0" + exit 1 + fi + BASE=${TAG#v} + # Keep only X.Y.Z form (strip rc/a/b/post/dev suffixes) + BASE=$(printf "%s\n" "$BASE" | sed -E 's/^([0-9]+)\.([0-9]+)\.([0-9]+).*/\1.\2.\3/') + IFS='.' read -r MAJ MIN PAT <> "$GITHUB_OUTPUT" + echo "Computed nightly version: ${NEXT}.dev${DATE}" + + - name: Build sdist/wheel + if: github.ref_type == 'tag' || steps.check.outputs.should_publish != 'false' + run: | + python -m pip install --upgrade pip + pip install build setuptools-scm + if [ "${{ github.ref_type }}" != "tag" ]; then + export SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.ver.outputs.NVER }} + fi + cd python + python -m build + + - name: Check metadata + if: github.ref_type == 'tag' || steps.check.outputs.should_publish != 'false' + run: | + pip install twine + twine check python/dist/* + + - name: Publish to PyPI (Trusted Publishing) + if: (github.event_name == 'schedule' || github.ref_type == 'tag') && steps.check.outputs.should_publish != 'false' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: python/dist/ + attestations: true + skip-existing: true From 4b824c7d6c88985fc21c3ad3d5cf1bd775279272 Mon Sep 17 00:00:00 2001 From: Yueming Hao Date: Thu, 18 Dec 2025 15:01:22 -0800 Subject: [PATCH 2/2] fix: Address review comments on nightly-pypi workflow - Add comments documenting should_publish output variable - Simplify here-document to here-string syntax - Add semantic version format validation (X.Y.Z) --- .github/workflows/nightly-pypi.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly-pypi.yml b/.github/workflows/nightly-pypi.yml index 0db56de..e101bfe 100644 --- a/.github/workflows/nightly-pypi.yml +++ b/.github/workflows/nightly-pypi.yml @@ -25,6 +25,8 @@ jobs: with: python-version: "3.12" + # This step checks if there are new commits since the last nightly publish. + # Output: steps.check.outputs.should_publish - 'true' if new commits exist, 'false' otherwise - name: Check for new commits since last nightly id: check if: github.ref_type != 'tag' @@ -44,11 +46,14 @@ jobs: exit 1 fi BASE=${TAG#v} + # Require a semantic version X.Y.Z (optionally with a suffix) before proceeding + if ! printf "%s\n" "$BASE" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+'; then + echo "::error title=Invalid git tag::Latest tag '$TAG' is not a semantic version like v0.1.0" + exit 1 + fi # Keep only X.Y.Z form (strip rc/a/b/post/dev suffixes) BASE=$(printf "%s\n" "$BASE" | sed -E 's/^([0-9]+)\.([0-9]+)\.([0-9]+).*/\1.\2.\3/') - IFS='.' read -r MAJ MIN PAT <