From fa3a7bbeb9a1dcc43db498326d129410808c0bb6 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Tue, 17 Jun 2025 08:29:06 -0700 Subject: [PATCH 1/8] validate tag --- .github/workflows/publish.yml | 4 +++- .github/workflows/release_python.yml | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1faaf14be3..49756645d1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,7 +20,9 @@ name: Publish on: push: tags: - - "*" + # Trigger this workflow when tag follows the versioning format: v..-rc. + # Example valid tags: v0.4.0, v0.4.0-rc.1 + - "v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?" workflow_dispatch: env: diff --git a/.github/workflows/release_python.yml b/.github/workflows/release_python.yml index 5e83868988..372bf9a47f 100644 --- a/.github/workflows/release_python.yml +++ b/.github/workflows/release_python.yml @@ -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 @@ -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: From 585b17eb0b38019bc2bd984f33d65e7bd156a578 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Tue, 17 Jun 2025 21:31:09 -0700 Subject: [PATCH 2/8] fix regex --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 49756645d1..452f8535f3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,7 +22,7 @@ on: tags: # Trigger this workflow when tag follows the versioning format: v..-rc. # Example valid tags: v0.4.0, v0.4.0-rc.1 - - "v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?" + - "v[0-9]+.[0-9]+.[0-9]+(-rc.[0-9]+)?" workflow_dispatch: env: From bdba989094f8c07f479e110688bf16c7ae0f366a Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sun, 22 Jun 2025 21:28:46 -0700 Subject: [PATCH 3/8] validate release tag --- .github/workflows/release_python.yml | 33 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release_python.yml b/.github/workflows/release_python.yml index 372bf9a47f..e2033a3301 100644 --- a/.github/workflows/release_python.yml +++ b/.github/workflows/release_python.yml @@ -42,9 +42,27 @@ jobs: steps: - run: echo 'The Publish workflow passed or was manually triggered' - sdist: + validate-release-tag: runs-on: ubuntu-latest needs: [check-cargo-publish] + 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` + # Valid formats: v.. OR v..-rc. + 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.. OR v..-rc." + echo "Examples: v0.4.0, v1.2.3-rc.1" + exit 1 + fi + echo "✅ Release tag format is valid: $RELEASE_TAG" + + sdist: + runs-on: ubuntu-latest + needs: [validate-release-tag] steps: - uses: actions/checkout@v4 - uses: PyO3/maturin-action@v1 @@ -60,7 +78,7 @@ jobs: wheels: runs-on: "${{ matrix.os }}" - needs: [check-cargo-publish] + needs: [validate-release-tag] strategy: matrix: include: @@ -108,17 +126,6 @@ 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: From 63cd745e171636ad3b72828724ef3528a33029ba Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sun, 22 Jun 2025 21:29:12 -0700 Subject: [PATCH 4/8] override cargo version for RC --- .github/workflows/release_python.yml | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/release_python.yml b/.github/workflows/release_python.yml index e2033a3301..5e6b9d9ecf 100644 --- a/.github/workflows/release_python.yml +++ b/.github/workflows/release_python.yml @@ -45,8 +45,12 @@ jobs: 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.. OR v..-rc. run: | @@ -59,12 +63,40 @@ jobs: 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' }} + 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" @@ -93,6 +125,17 @@ 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' }} + 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 From 546539e604439224ad8fcc6e8e777b7cb5800cad Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sun, 22 Jun 2025 21:38:27 -0700 Subject: [PATCH 5/8] fix tag push --- .github/workflows/publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 452f8535f3..912385e6f5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,7 +22,8 @@ on: tags: # Trigger this workflow when tag follows the versioning format: v..-rc. # Example valid tags: v0.4.0, v0.4.0-rc.1 - - "v[0-9]+.[0-9]+.[0-9]+(-rc.[0-9]+)?" + - "v[0-9]+.[0-9]+.[0-9]+" + - "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+" workflow_dispatch: env: From d405f3ad6408a5470bd3f359a3865fb36b1656f4 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sun, 22 Jun 2025 22:10:31 -0700 Subject: [PATCH 6/8] fix concurrency --- .github/workflows/release_python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_python.yml b/.github/workflows/release_python.yml index 5e6b9d9ecf..2e54b0272b 100644 --- a/.github/workflows/release_python.yml +++ b/.github/workflows/release_python.yml @@ -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 }} cancel-in-progress: true permissions: From e5bfe9d566fb1c8736d281123cdae59d18e8cae0 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sun, 22 Jun 2025 22:12:40 -0700 Subject: [PATCH 7/8] use proper working dir --- .github/workflows/release_python.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release_python.yml b/.github/workflows/release_python.yml index 2e54b0272b..170869419d 100644 --- a/.github/workflows/release_python.yml +++ b/.github/workflows/release_python.yml @@ -93,6 +93,7 @@ jobs: - 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 }} @@ -132,6 +133,7 @@ jobs: - 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 }} From 57086b8c861c5777cfafaa4bb1cfde57c82d20f2 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Mon, 23 Jun 2025 08:36:23 -0700 Subject: [PATCH 8/8] comment --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 912385e6f5..50a180c5ec 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,7 +20,7 @@ name: Publish on: push: tags: - # Trigger this workflow when tag follows the versioning format: v..-rc. + # Trigger this workflow when tag follows the versioning format: v.. OR v..-rc. # 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]+"