11name : build (manual)
22
33# Manual builds of `pie` for distribution. Each run rewrites the
4- # `latest-build ` rolling pre-release on this repo's GitHub Releases —
4+ # `nightly ` rolling pre-release on this repo's GitHub Releases —
55# every artifact is uploaded with `gh release upload --clobber`, so
66# download URLs stay stable across runs.
77#
8- # One-time setup before the first dispatch:
9- #
10- # gh release create latest-build --prerelease --notes "Rolling build"
11- #
12- # After that, this workflow keeps the assets on that release fresh.
8+ # The prepare-release job creates the release if needed before any
9+ # matrix jobs start uploading assets.
1310
1411on :
1512 workflow_dispatch :
1613 inputs :
1714 tag :
1815 description : " Release tag to update (assets uploaded with --clobber)"
1916 type : string
20- default : " latest-build "
17+ default : " nightly "
2118 portable :
2219 description : " Build portable matrix (manylinux x86_64/aarch64 + macOS arm64 + Windows x86_64 Vulkan/CUDA)"
2320 type : boolean
4239 Workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
4340
4441jobs :
42+ # =========================================================================
43+ # Create/update the rolling release before any matrix job tries to upload.
44+ # This keeps `gh release upload` from racing a missing release, and keeps
45+ # the rolling build out of GitHub's "Latest" release slot.
46+ # =========================================================================
47+ prepare-release :
48+ if : inputs.portable || inputs.cuda || inputs.cuda_manylinux
49+ runs-on : ubuntu-latest
50+ permissions :
51+ contents : write
52+ steps :
53+ - name : Ensure rolling release exists
54+ env :
55+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
56+ TAG : ${{ inputs.tag }}
57+ run : |
58+ set -euxo pipefail
59+ if gh release view "${TAG}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
60+ release_id="$(gh release view "${TAG}" --json databaseId --jq .databaseId --repo "${GITHUB_REPOSITORY}")"
61+ gh api \
62+ -X PATCH \
63+ "repos/${GITHUB_REPOSITORY}/releases/${release_id}" \
64+ -f tag_name="${TAG}" \
65+ -f name="${TAG}" \
66+ -f body="${RELEASE_NOTES}" \
67+ -F draft=false \
68+ -F prerelease=true \
69+ -f make_latest=false
70+ else
71+ gh release create "${TAG}" \
72+ --repo "${GITHUB_REPOSITORY}" \
73+ --target "${GITHUB_SHA}" \
74+ --title "${TAG}" \
75+ --notes "${RELEASE_NOTES}" \
76+ --prerelease \
77+ --latest=false
78+ fi
79+
4580 # =========================================================================
4681 # Portable matrix — CPU/Metal/Vulkan plus Windows portable CUDA.
4782 # =========================================================================
4883 portable :
4984 if : inputs.portable
85+ needs : prepare-release
5086 name : portable / ${{ matrix.target.label }}
5187 strategy :
5288 fail-fast : false
@@ -301,6 +337,7 @@ jobs:
301337 # =========================================================================
302338 cuda :
303339 if : inputs.cuda
340+ needs : prepare-release
304341 name : cuda / linux-x64 / ${{ matrix.flavor.id }}-${{ matrix.cuda.short }}
305342 runs-on : [self-hosted, linux, x64, gpu, cuda]
306343 strategy :
@@ -441,6 +478,7 @@ jobs:
441478 tag_name : ${{ inputs.tag }}
442479 files : dist/${{ env.ARTIFACT_NAME }}
443480 fail_on_unmatched_files : true
481+ make_latest : false
444482
445483 # =========================================================================
446484 # CUDA matrix on GH-hosted runners with manylinux_2_28 base — produces
@@ -454,6 +492,7 @@ jobs:
454492 # =========================================================================
455493 cuda-manylinux :
456494 if : inputs.cuda_manylinux
495+ needs : prepare-release
457496 name : cuda / x86_64-manylinux_2_28 / ${{ matrix.flavor.id }}-${{ matrix.cuda.short }}
458497 runs-on : ubuntu-22.04
459498 timeout-minutes : 120
@@ -548,6 +587,7 @@ jobs:
548587 tag_name : ${{ inputs.tag }}
549588 files : dist/${{ env.ARTIFACT_NAME }}
550589 fail_on_unmatched_files : true
590+ make_latest : false
551591
552592 # =========================================================================
553593 # Refresh the release notes once after all builds finish.
@@ -562,8 +602,16 @@ jobs:
562602 - name : Edit release notes + body
563603 env :
564604 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
605+ TAG : ${{ inputs.tag }}
565606 run : |
566607 set -euxo pipefail
567- gh release edit "${{ inputs.tag }}" \
568- --notes "${RELEASE_NOTES}" \
569- --repo "${{ github.repository }}"
608+ release_id="$(gh release view "${TAG}" --json databaseId --jq .databaseId --repo "${GITHUB_REPOSITORY}")"
609+ gh api \
610+ -X PATCH \
611+ "repos/${GITHUB_REPOSITORY}/releases/${release_id}" \
612+ -f tag_name="${TAG}" \
613+ -f name="${TAG}" \
614+ -f body="${RELEASE_NOTES}" \
615+ -F draft=false \
616+ -F prerelease=true \
617+ -f make_latest=false
0 commit comments