Skip to content

[infra] publish rc to pypi as part of release process #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ name: Publish
on:
push:
tags:
- "*"
# Trigger this workflow when tag follows the versioning format: v<major>.<minor>.<patch>-rc.<release_candidate>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

# Example valid tags: v0.4.0, v0.4.0-rc.1
- "v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?"
workflow_dispatch:

env:
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/release_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ jobs:
name: Publish Python 🐍 distribution 📦 to Pypi
needs: [sdist, wheels]
runs-on: ubuntu-latest
# Only publish to PyPi if the tag is not a pre-release OR if manually triggered
# Note, `workflow_run.head_branch` does not contain `refs/tags/` prefix, just the tag name, i.e. `v0.4.0` or `v0.4.0-rc.1`
if: ${{ !contains(github.event.workflow_run.head_branch, '-') || github.event_name == 'workflow_dispatch' }}

environment:
name: pypi
Expand All @@ -111,6 +108,17 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Validate release tag format
# Note, `workflow_run.head_branch` does not contain `refs/tags/` prefix, just the tag name, i.e. `v0.4.0` or `v0.4.0-rc.1`
run: |
RELEASE_TAG="${{ github.event.workflow_run.head_branch }}"
echo "Validating release tag: $RELEASE_TAG"
if [[ ! "$RELEASE_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? ]]; then
echo "❌ Invalid release tag format: $RELEASE_TAG"
exit 1
fi
echo "✅ Release tag format is valid"

- name: Download all the dists
uses: actions/download-artifact@v4
with:
Expand Down