@@ -3,24 +3,92 @@ name: Build binaries & add as release assets
33on :
44 repository_dispatch :
55 types : [trigger_binary_build]
6+ workflow_dispatch :
7+ inputs :
8+ version :
9+ description : ' Version for which to trigger the build (e.g. 0.27.1)'
10+ required : true
611
712jobs :
13+ prepare :
14+ runs-on : ubuntu-latest
15+ outputs :
16+ ref : ${{ steps.resolve-ref.outputs.ref }}
17+ upload_url : ${{ steps.resolve-upload.outputs.upload_url }}
18+ steps :
19+ - name : Resolve ref
20+ id : resolve-ref
21+ shell : bash
22+ env :
23+ EVENT_NAME : ${{ github.event_name }}
24+ INPUT_VERSION : ${{ github.event.inputs.version }}
25+ PAYLOAD_REF : ${{ github.event.client_payload.ref }}
26+ run : |
27+ set -euo pipefail
28+ if [[ "${EVENT_NAME}" == "workflow_dispatch" ]]; then
29+ if [[ -z "${INPUT_VERSION}" ]]; then
30+ echo "Manual runs require the version input." >&2
31+ exit 1
32+ fi
33+ echo "ref=${INPUT_VERSION}" >> "${GITHUB_OUTPUT}"
34+ else
35+ if [[ -z "${PAYLOAD_REF}" ]]; then
36+ echo "Repository dispatch events must include client_payload.ref." >&2
37+ exit 1
38+ fi
39+ echo "ref=${PAYLOAD_REF}" >> "${GITHUB_OUTPUT}"
40+ fi
41+
42+ - name : Resolve release upload URL
43+ id : resolve-upload
44+ shell : bash
45+ env :
46+ EVENT_NAME : ${{ github.event_name }}
47+ CLIENT_UPLOAD_URL : ${{ github.event.client_payload.upload_url }}
48+ REF : ${{ steps.resolve-ref.outputs.ref }}
49+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
50+ REPO : ${{ github.repository }}
51+ run : |
52+ set -euo pipefail
53+ if [[ "${EVENT_NAME}" == "workflow_dispatch" ]]; then
54+ api_url="https://api.github.com/repos/${REPO}/releases/tags/${REF}"
55+ response=$(curl -sS -L \
56+ -H "Accept: application/vnd.github+json" \
57+ -H "Authorization: Bearer ${GH_TOKEN}" \
58+ -H "X-GitHub-Api-Version: 2022-11-28" \
59+ "${api_url}")
60+ upload_url=$(echo "${response}" | jq -r '.upload_url')
61+ if [[ -z "${upload_url}" || "${upload_url}" == "null" ]]; then
62+ echo "Unable to find release upload URL for tag ${REF}." >&2
63+ echo "${response}" >&2
64+ exit 1
65+ fi
66+ echo "upload_url=${upload_url}" >> "${GITHUB_OUTPUT}"
67+ else
68+ if [[ -z "${CLIENT_UPLOAD_URL}" ]]; then
69+ echo "Repository dispatch events must include client_payload.upload_url." >&2
70+ exit 1
71+ fi
72+ echo "upload_url=${CLIENT_UPLOAD_URL}" >> "${GITHUB_OUTPUT}"
73+ fi
74+
875 get-python-versions :
76+ needs : prepare
977 runs-on : ubuntu-latest
1078 outputs :
1179 primary-version : ${{ steps.get-versions.outputs.primary-version }}
1280 steps :
1381 - name : Checkout code
1482 uses : actions/checkout@v5
1583 with :
16- ref : ${{ github.event.client_payload .ref }}
84+ ref : ${{ needs.prepare.outputs .ref }}
1785
1886 - name : Get Python versions
1987 id : get-versions
2088 uses : ./.github/actions/get-python-versions
2189
2290 build :
23- needs : get-python-versions
91+ needs : [prepare, get-python-versions]
2492 runs-on : ${{ matrix.os }}
2593 strategy :
2694 matrix :
40108 - name : Checkout code
41109 uses : actions/checkout@v5
42110 with :
43- ref : ${{ github.event.client_payload .ref }}
111+ ref : ${{ needs.prepare.outputs .ref }}
44112
45113 - name : Set up Python
46114 uses : actions/setup-python@v6
@@ -65,19 +133,19 @@ jobs:
65133 env :
66134 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67135 with :
68- upload_url : ${{ github.event.client_payload .upload_url }}
136+ upload_url : ${{ needs.prepare.outputs .upload_url }}
69137 asset_path : ${{ matrix.executable_path }}
70138 asset_name : ${{ matrix.executable }}
71139 asset_content_type : application/octet-stream
72140
73141 generate-baseline :
74- needs : get-python-versions
142+ needs : [prepare, get-python-versions]
75143 runs-on : ubuntu-latest
76144 steps :
77145 - name : Checkout code
78146 uses : actions/checkout@v5
79147 with :
80- ref : ${{ github.event.client_payload .ref }}
148+ ref : ${{ needs.prepare.outputs .ref }}
81149
82150 - name : Set up Python
83151 uses : actions/setup-python@v6
@@ -100,7 +168,7 @@ jobs:
100168 env :
101169 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
102170 with :
103- upload_url : ${{ github.event.client_payload .upload_url }}
171+ upload_url : ${{ needs.prepare.outputs .upload_url }}
104172 asset_path : ./binary_sizes_baseline.json
105173 asset_name : binary_sizes_baseline.json
106174 asset_content_type : application/json
0 commit comments