2323 types :
2424 - completed
2525 workflow_dispatch :
26-
27- env :
28- rust_msrv : " 1.87"
29-
30- concurrency :
31- group : ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}-${{ github.event_name }}
32- cancel-in-progress : true
26+ inputs :
27+ release_tag :
28+ description : ' Release tag (e.g., v0.4.0 or v0.4.0-rc.1)'
29+ required : true
30+ type : string
3331
3432permissions :
3533 contents : read
@@ -49,12 +47,20 @@ jobs:
4947 cargo-version : ${{ steps.validate.outputs.cargo-version }}
5048 is-rc : ${{ steps.validate.outputs.is-rc }}
5149 steps :
50+ - uses : actions/checkout@v6
51+ if : ${{ github.event_name == 'workflow_dispatch' }}
52+
5253 - name : Validate release tag format
5354 id : validate
55+ # Use input for workflow_dispatch, otherwise use `workflow_run.head_branch`
5456 # 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`
5557 # Valid formats: v<major>.<minor>.<patch> OR v<major>.<minor>.<patch>-rc.<release_candidate>
5658 run : |
57- RELEASE_TAG="${{ github.event.workflow_run.head_branch }}"
59+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
60+ RELEASE_TAG="${{ github.event.inputs.release_tag }}"
61+ else
62+ RELEASE_TAG="${{ github.event.workflow_run.head_branch }}"
63+ fi
5864 echo "Validating release tag: $RELEASE_TAG"
5965 if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
6066 echo "❌ Invalid release tag format: $RELEASE_TAG"
6874 CARGO_VERSION="${RELEASE_TAG#v}"
6975 echo "Cargo version (without v prefix): $CARGO_VERSION"
7076
77+ # For manual triggers, validate that the tag matches the version in Cargo.toml
78+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
79+ # Extract base version (without -rc.X suffix) for comparison with Cargo.toml
80+ BASE_VERSION="${CARGO_VERSION%-rc.*}"
81+ echo "Base version (for Cargo.toml comparison): $BASE_VERSION"
82+
83+ # Read version from Cargo.toml and validate it matches
84+ CARGO_TOML_VERSION=$(grep '^version = ' bindings/python/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
85+ echo "Version in bindings/python/Cargo.toml: $CARGO_TOML_VERSION"
86+
87+ if [ "$BASE_VERSION" != "$CARGO_TOML_VERSION" ]; then
88+ echo "❌ Version mismatch!"
89+ echo " Release tag base version: $BASE_VERSION"
90+ echo " bindings/python/Cargo.toml version: $CARGO_TOML_VERSION"
91+ echo "Please ensure the release tag matches the version in Cargo.toml"
92+ exit 1
93+ fi
94+ echo "✅ Version matches bindings/python/Cargo.toml"
95+ fi
96+
7197 # Check if this is a release candidate
7298 if [[ "$RELEASE_TAG" =~ -rc\.[0-9]+$ ]]; then
7399 IS_RC="true"
@@ -147,10 +173,14 @@ jobs:
147173 - uses : actions/setup-python@v6
148174 with :
149175 python-version : 3.12
176+ - name : Get MSRV
177+ id : get-msrv
178+ uses : ./.github/actions/get-msrv
179+
150180 - name : Setup Rust toolchain
151181 uses : ./.github/actions/setup-builder
152182 with :
153- rust-version : ${{ env.rust_msrv }}
183+ rust-version : ${{ steps.get-msrv.outputs.msrv }}
154184 - uses : PyO3/maturin-action@v1
155185 with :
156186 target : ${{ matrix.target }}
0 commit comments