-
Notifications
You must be signed in to change notification settings - Fork 319
[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
Merged
kevinjqliu
merged 8 commits into
apache:main
from
kevinjqliu:kevinjqliu/allow-pypi-prerelease
Jun 24, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fa3a7bb
validate tag
kevinjqliu 585b17e
fix regex
kevinjqliu bdba989
validate release tag
kevinjqliu 63cd745
override cargo version for RC
kevinjqliu 546539e
fix tag push
kevinjqliu d405f3a
fix concurrency
kevinjqliu e5bfe9d
use proper working dir
kevinjqliu 57086b8
comment
kevinjqliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ env: | |
rust_msrv: "1.85" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | ||
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}-${{ github.event_name }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after changing just a minor improvement |
||
cancel-in-progress: true | ||
|
||
permissions: | ||
|
@@ -42,11 +42,62 @@ jobs: | |
steps: | ||
- run: echo 'The Publish workflow passed or was manually triggered' | ||
|
||
sdist: | ||
validate-release-tag: | ||
runs-on: ubuntu-latest | ||
needs: [check-cargo-publish] | ||
outputs: | ||
cargo-version: ${{ steps.validate.outputs.cargo-version }} | ||
is-rc: ${{ steps.validate.outputs.is-rc }} | ||
steps: | ||
- name: Validate release tag format | ||
id: validate | ||
# 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` | ||
# Valid formats: v<major>.<minor>.<patch> OR v<major>.<minor>.<patch>-rc.<release_candidate> | ||
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" | ||
echo "Expected format: v<major>.<minor>.<patch> OR v<major>.<minor>.<patch>-rc.<release_candidate>" | ||
echo "Examples: v0.4.0, v1.2.3-rc.1" | ||
exit 1 | ||
fi | ||
echo "✅ Release tag format is valid: $RELEASE_TAG" | ||
|
||
# Strip 'v' prefix for cargo version | ||
CARGO_VERSION="${RELEASE_TAG#v}" | ||
echo "Cargo version (without v prefix): $CARGO_VERSION" | ||
|
||
# Check if this is a release candidate | ||
if [[ "$RELEASE_TAG" =~ -rc\.[0-9]+$ ]]; then | ||
IS_RC="true" | ||
echo "This is a release candidate" | ||
else | ||
IS_RC="false" | ||
echo "This is a stable release" | ||
fi | ||
|
||
# Set outputs for other jobs to use | ||
echo "cargo-version=$CARGO_VERSION" >> $GITHUB_OUTPUT | ||
echo "is-rc=$IS_RC" >> $GITHUB_OUTPUT | ||
|
||
sdist: | ||
runs-on: ubuntu-latest | ||
needs: [validate-release-tag] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install cargo-edit | ||
if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }} | ||
run: cargo install cargo-edit | ||
|
||
- name: Set cargo version for RC | ||
if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }} | ||
working-directory: "bindings/python" | ||
run: | | ||
echo "Setting cargo version to: ${{ needs.validate-release-tag.outputs.cargo-version }}" | ||
cargo set-version ${{ needs.validate-release-tag.outputs.cargo-version }} | ||
|
||
- uses: PyO3/maturin-action@v1 | ||
with: | ||
working-directory: "bindings/python" | ||
|
@@ -60,7 +111,7 @@ jobs: | |
|
||
wheels: | ||
runs-on: "${{ matrix.os }}" | ||
needs: [check-cargo-publish] | ||
needs: [validate-release-tag] | ||
strategy: | ||
matrix: | ||
include: | ||
|
@@ -75,6 +126,18 @@ jobs: | |
- { os: ubuntu-latest, target: "armv7l" } | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install cargo-edit | ||
if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }} | ||
run: cargo install cargo-edit | ||
|
||
- name: Set cargo version for RC | ||
if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }} | ||
working-directory: "bindings/python" | ||
run: | | ||
echo "Setting cargo version to: ${{ needs.validate-release-tag.outputs.cargo-version }}" | ||
cargo set-version ${{ needs.validate-release-tag.outputs.cargo-version }} | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9 | ||
|
@@ -99,9 +162,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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider myself a bit of a regex connoisseur.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun fact! the
on.push.tags
syntax here doesnt support regex, its a "filter pattern"from https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore,
https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet