44
55# One-click release workflow for cuda-pathfinder.
66#
7- # Provide a version number and commit SHA. The workflow automatically finds
8- # the CI run and creates the git tag , creates a draft GitHub release with the standard
7+ # Provide a release tag. The workflow finds
8+ # the CI run, creates a draft GitHub release with the standard
99# body, builds versioned docs, uploads source archive + wheels to the
1010# release, publishes to TestPyPI, verifies the install, publishes to PyPI,
1111# verifies again, and finally marks the release as published.
@@ -15,12 +15,8 @@ name: "Release: cuda-pathfinder"
1515on :
1616 workflow_dispatch :
1717 inputs :
18- version :
19- description : " Version to release (e.g. 1.3.5)"
20- required : true
21- type : string
22- commit :
23- description : " Commit SHA to release (must be on default branch)"
18+ tag :
19+ description : " Release tag to publish (e.g. cuda-pathfinder-v1.3.5)"
2420 required : true
2521 type : string
2622
@@ -34,7 +30,7 @@ defaults:
3430
3531jobs :
3632 # --------------------------------------------------------------------------
37- # Validate inputs , find the CI run, create the tag + draft release.
33+ # Collect release metadata , find the CI run, create a draft release.
3834 # --------------------------------------------------------------------------
3935 prepare :
4036 runs-on : ubuntu-latest
@@ -53,52 +49,22 @@ jobs:
5349 exit 1
5450 fi
5551
56- - name : Validate version
52+ - name : Set release variables
5753 id : vars
5854 env :
59- VERSION_INPUT : ${{ inputs.version }}
55+ TAG_INPUT : ${{ inputs.tag }}
6056 run : |
61- # Strip leading "v" if present (common typo)
62- version="${VERSION_INPUT#v}"
63- if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
64- echo "::error::Version must be MAJOR.MINOR.PATCH, got: ${version}"
65- exit 1
66- fi
67- tag="cuda-pathfinder-v${version}"
57+ version="${TAG_INPUT#cuda-pathfinder-v}"
6858 {
69- echo "tag=${tag }"
59+ echo "tag=${TAG_INPUT }"
7060 echo "version=${version}"
7161 } >> "$GITHUB_OUTPUT"
7262
73- - name : Validate commit input format
74- env :
75- COMMIT_INPUT : ${{ inputs.commit }}
76- run : |
77- # Require a full SHA to avoid ambiguity and accidental releases.
78- if [[ ! "${COMMIT_INPUT}" =~ ^[0-9a-fA-F]{40}$ ]]; then
79- echo "::error::Commit must be a full 40-character SHA, got: ${COMMIT_INPUT}"
80- exit 1
81- fi
82-
8363 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
8464 with :
8565 fetch-depth : 0
86- ref : ${{ inputs.commit }}
87-
88- - name : Validate and resolve commit
89- id : commit
90- env :
91- DEFAULT_BRANCH : ${{ github.event.repository.default_branch }}
92- run : |
93- git fetch --no-tags origin "${DEFAULT_BRANCH}"
94- commit=$(git rev-parse --verify "HEAD^{commit}")
95-
96- if ! git merge-base --is-ancestor "${commit}" "origin/${DEFAULT_BRANCH}"; then
97- echo "::error::Commit ${commit} is not reachable from origin/${DEFAULT_BRANCH}"
98- exit 1
99- fi
100-
101- echo "commit=${commit}" >> "$GITHUB_OUTPUT"
66+ # Resolve only the exact tag ref; checkout fails if the tag does not exist.
67+ ref : refs/tags/${{ steps.vars.outputs.tag }}
10268
10369 - name : Check release notes exist
10470 env :
@@ -117,22 +83,6 @@ jobs:
11783 ctk_ver=$(yq '.cuda.build.version' ci/versions.yml)
11884 echo "ctk-ver=${ctk_ver}" >> "$GITHUB_OUTPUT"
11985
120- - name : Create tag
121- env :
122- TAG : ${{ steps.vars.outputs.tag }}
123- TARGET_COMMIT : ${{ steps.commit.outputs.commit }}
124- run : |
125- if git rev-parse "${TAG}" >/dev/null 2>&1; then
126- existing_commit=$(git rev-parse "${TAG}^{commit}")
127- if [[ "${existing_commit}" != "${TARGET_COMMIT}" ]]; then
128- echo "::error::Tag ${TAG} already exists at ${existing_commit}, expected ${TARGET_COMMIT}"
129- exit 1
130- fi
131- else
132- git tag "${TAG}" "${TARGET_COMMIT}"
133- git push origin "${TAG}"
134- fi
135-
13686 - name : Detect CI run ID
13787 id : detect-run
13888 env :
@@ -179,6 +129,7 @@ jobs:
179129 --repo "${{ github.repository }}" \
180130 --draft \
181131 --latest=false \
132+ --verify-tag \
182133 --title "cuda-pathfinder v${VERSION}" \
183134 --notes-file /tmp/release-body.md
184135
0 commit comments