Skip to content

Commit 0191fee

Browse files
committed
fix(ci): give publish.yml the same strict dispatch guard
My description claimed parity between the two workflows and it was not true. In this repo publish.yml never gained a pre-checkout step -- #63 only switched its existing "Verify tag matches pyproject version" check to $TAG, which runs AFTER checkout and is looser (^v[0-9]). So `-f tag=v1.2` or `v1.2.3rc1` was accepted there and rejected in release.yml. Tightening publish.yml rather than loosening release.yml, since release.sh only ever produces X.Y.Z -- it enforces ^[0-9]+\.[0-9]+\.[0-9]+$ on explicit versions, so the strict form is the correct contract. Both workflows now validate the same input the same way, before fetching an arbitrary ref. The post-checkout version match stays: it catches a tag that is well-formed but does not match pyproject.
1 parent 382c6c5 commit 0191fee

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ jobs:
3131
# The tag being released, whether it arrived by push or by dispatch.
3232
TAG: ${{ inputs.tag || github.ref_name }}
3333
steps:
34+
# Before checkout, because checkout resolves the input as an arbitrary ref:
35+
# a branch or SHA is fetched first and only rejected later by the version
36+
# match below, which is also looser (`^v[0-9]`). Strict here so the dispatch
37+
# contract matches release.yml — release.sh only ever produces X.Y.Z.
38+
- name: Validate release tag format
39+
if: github.event_name == 'workflow_dispatch'
40+
env:
41+
INPUT_TAG: ${{ inputs.tag }}
42+
run: |
43+
set -euo pipefail
44+
if [[ ! "$INPUT_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
45+
echo "tag must look like vX.Y.Z, got: $INPUT_TAG" >&2
46+
exit 1
47+
fi
48+
3449
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3550
with:
3651
ref: ${{ inputs.tag || github.ref_name }}

0 commit comments

Comments
 (0)