Skip to content
Merged
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
39 changes: 34 additions & 5 deletions .github/workflows/release_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ on:
types:
- completed
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}-${{ github.event_name }}
cancel-in-progress: true
inputs:
release_tag:
description: 'Release tag (e.g., v0.4.0 or v0.4.0-rc.1)'
required: true
type: string

permissions:
contents: read
Expand All @@ -46,12 +47,20 @@ jobs:
cargo-version: ${{ steps.validate.outputs.cargo-version }}
is-rc: ${{ steps.validate.outputs.is-rc }}
steps:
- uses: actions/checkout@v6
if: ${{ github.event_name == 'workflow_dispatch' }}

- name: Validate release tag format
id: validate
# Use input for workflow_dispatch, otherwise use `workflow_run.head_branch`
# 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 }}"
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
RELEASE_TAG="${{ github.event.inputs.release_tag }}"
else
RELEASE_TAG="${{ github.event.workflow_run.head_branch }}"
fi
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"
Expand All @@ -65,6 +74,26 @@ jobs:
CARGO_VERSION="${RELEASE_TAG#v}"
echo "Cargo version (without v prefix): $CARGO_VERSION"

# For manual triggers, validate that the tag matches the version in Cargo.toml
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
# Extract base version (without -rc.X suffix) for comparison with Cargo.toml
BASE_VERSION="${CARGO_VERSION%-rc.*}"
echo "Base version (for Cargo.toml comparison): $BASE_VERSION"

# Read version from Cargo.toml and validate it matches
CARGO_TOML_VERSION=$(grep '^version = ' bindings/python/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "Version in bindings/python/Cargo.toml: $CARGO_TOML_VERSION"

if [ "$BASE_VERSION" != "$CARGO_TOML_VERSION" ]; then
echo "❌ Version mismatch!"
echo " Release tag base version: $BASE_VERSION"
echo " bindings/python/Cargo.toml version: $CARGO_TOML_VERSION"
echo "Please ensure the release tag matches the version in Cargo.toml"
exit 1
fi
echo "✅ Version matches bindings/python/Cargo.toml"
fi

# Check if this is a release candidate
if [[ "$RELEASE_TAG" =~ -rc\.[0-9]+$ ]]; then
IS_RC="true"
Expand Down
Loading