From 8dc35ea0af79917ac88a5138eb12f0850dde2b64 Mon Sep 17 00:00:00 2001 From: shaia Date: Sun, 4 Jan 2026 09:08:37 +0200 Subject: [PATCH] feat: Add ref input to publish workflow for tag-specific builds When using workflow_dispatch, you can now specify a git ref (e.g., v0.1.6) to build from. This ensures setuptools-scm generates the correct version instead of a dev version with local identifier that PyPI rejects. --- .github/workflows/build-wheels.yml | 11 +++++++++++ .github/workflows/publish.yml | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 5e09176..d1e54f0 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -5,7 +5,17 @@ on: branches: [main, master] pull_request: workflow_dispatch: + inputs: + ref: + description: 'Git ref to build from (tag like v0.1.6)' + required: false + type: string workflow_call: + inputs: + ref: + description: 'Git ref to build from' + required: false + type: string env: # CFD C library version to build against @@ -29,6 +39,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ inputs.ref || github.ref }} - name: Checkout CFD C library uses: actions/checkout@v4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4a79886..921b755 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,6 +16,10 @@ on: options: - testpypi - pypi + ref: + description: 'Git ref to build from (tag like v0.1.6, or leave empty for default branch)' + required: false + type: string # Prevent duplicate runs when release creates a tag concurrency: @@ -25,6 +29,8 @@ concurrency: jobs: build: uses: ./.github/workflows/build-wheels.yml + with: + ref: ${{ inputs.ref || github.ref }} build_sdist: name: Build source distribution @@ -34,6 +40,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ inputs.ref || github.ref }} - name: Set up Python uses: actions/setup-python@v5