Skip to content

Commit 63cd745

Browse files
committed
override cargo version for RC
1 parent bdba989 commit 63cd745

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/release_python.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ jobs:
4545
validate-release-tag:
4646
runs-on: ubuntu-latest
4747
needs: [check-cargo-publish]
48+
outputs:
49+
cargo-version: ${{ steps.validate.outputs.cargo-version }}
50+
is-rc: ${{ steps.validate.outputs.is-rc }}
4851
steps:
4952
- name: Validate release tag format
53+
id: validate
5054
# 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`
5155
# Valid formats: v<major>.<minor>.<patch> OR v<major>.<minor>.<patch>-rc.<release_candidate>
5256
run: |
@@ -59,12 +63,40 @@ jobs:
5963
exit 1
6064
fi
6165
echo "✅ Release tag format is valid: $RELEASE_TAG"
66+
67+
# Strip 'v' prefix for cargo version
68+
CARGO_VERSION="${RELEASE_TAG#v}"
69+
echo "Cargo version (without v prefix): $CARGO_VERSION"
70+
71+
# Check if this is a release candidate
72+
if [[ "$RELEASE_TAG" =~ -rc\.[0-9]+$ ]]; then
73+
IS_RC="true"
74+
echo "This is a release candidate"
75+
else
76+
IS_RC="false"
77+
echo "This is a stable release"
78+
fi
79+
80+
# Set outputs for other jobs to use
81+
echo "cargo-version=$CARGO_VERSION" >> $GITHUB_OUTPUT
82+
echo "is-rc=$IS_RC" >> $GITHUB_OUTPUT
6283
6384
sdist:
6485
runs-on: ubuntu-latest
6586
needs: [validate-release-tag]
6687
steps:
6788
- uses: actions/checkout@v4
89+
90+
- name: Install cargo-edit
91+
if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }}
92+
run: cargo install cargo-edit
93+
94+
- name: Set cargo version for RC
95+
if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }}
96+
run: |
97+
echo "Setting cargo version to: ${{ needs.validate-release-tag.outputs.cargo-version }}"
98+
cargo set-version ${{ needs.validate-release-tag.outputs.cargo-version }}
99+
68100
- uses: PyO3/maturin-action@v1
69101
with:
70102
working-directory: "bindings/python"
@@ -93,6 +125,17 @@ jobs:
93125
- { os: ubuntu-latest, target: "armv7l" }
94126
steps:
95127
- uses: actions/checkout@v4
128+
129+
- name: Install cargo-edit
130+
if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }}
131+
run: cargo install cargo-edit
132+
133+
- name: Set cargo version for RC
134+
if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }}
135+
run: |
136+
echo "Setting cargo version to: ${{ needs.validate-release-tag.outputs.cargo-version }}"
137+
cargo set-version ${{ needs.validate-release-tag.outputs.cargo-version }}
138+
96139
- uses: actions/setup-python@v5
97140
with:
98141
python-version: 3.9

0 commit comments

Comments
 (0)