Skip to content

Commit 6aba304

Browse files
committed
Add manual release_tag input and validation
Add a workflow_dispatch input (release_tag) to allow manual builds/publishes for a specific tag. Validate the provided tag format in a new bash step when triggered manually, and adjust the checkout step to use the provided tag ref for workflow_dispatch events. Also remove an obsolete comment in the Python setup step.
1 parent bd3cd2f commit 6aba304

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

.github/workflows/python-package.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
tags:
66
- 'v*.*.*'
7+
78
pull_request:
89
branches:
910
- main
@@ -15,21 +16,43 @@ on:
1516
- synchronize
1617
- reopened
1718

19+
workflow_dispatch:
20+
inputs:
21+
release_tag:
22+
description: 'Tag to build/publish (e.g. v1.2.3 or v2.0.0rc1)'
23+
required: true
24+
type: string
25+
1826
jobs:
1927
release:
2028
runs-on: ubuntu-latest
2129

2230
steps:
31+
- name: Validate manual tag input
32+
if: ${{ github.event_name == 'workflow_dispatch' }}
33+
shell: bash
34+
run: |
35+
case "${{ inputs.release_tag }}" in
36+
v*.*.*)
37+
echo "Manual release tag accepted: ${{ inputs.release_tag }}"
38+
;;
39+
*)
40+
echo "release_tag must look like v1.2.3 (or similar, e.g. v2.0.0rc1)"
41+
exit 1
42+
;;
43+
esac
44+
2345
- name: Checkout code
2446
uses: actions/checkout@v6
47+
with:
48+
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.release_tag) || github.ref }}
2549

2650
- name: Setup Python
2751
id: setup-python
2852
uses: actions/setup-python@v6
2953
with:
3054
python-version: '3.x'
3155
cache: 'pip'
32-
# we only use pyproject.toml for dependencies
3356
cache-dependency-path: |
3457
pyproject.toml
3558

0 commit comments

Comments
 (0)