Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ name: Publish
on:
push:
tags:
- "*"
# Trigger this workflow when tag follows the versioning format: v<major>.<minor>.<patch> OR v<major>.<minor>.<patch>-rc.<release_candidate>
# Example valid tags: v0.4.0, v0.4.0-rc.1
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
Comment on lines +25 to +26
Copy link
Contributor

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.

Suggested change
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
- "v\d+.\d+.\d+"
- "v\d+.\d+.\d+-rc.\d+"
image

Copy link
Contributor Author

@kevinjqliu kevinjqliu Jun 23, 2025

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,

The branches, branches-ignore, tags, and tags-ignore keywords accept glob patterns that use characters like *, **, +, ?, ! and others to match more than one branch or tag name. If a name contains any of these characters and you want a literal match, you need to escape each of these special characters with \. For more information about glob patterns, see the [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet).

https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

workflow_dispatch:

env:
Expand Down
72 changes: 66 additions & 6 deletions .github/workflows/release_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

after changing github.ref -> github.event.workflow_run.head_branch in #1444, this was missed.

just a minor improvement

cancel-in-progress: true

permissions:
Expand All @@ -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"
Expand All @@ -60,7 +111,7 @@ jobs:

wheels:
runs-on: "${{ matrix.os }}"
needs: [check-cargo-publish]
needs: [validate-release-tag]
strategy:
matrix:
include:
Expand All @@ -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
Expand All @@ -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
Expand Down