forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
398 lines (371 loc) · 15.2 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# GENERATED, DO NOT EDIT!
# To change, edit `src/python/pants_release/generate_github_workflows.py` and run:
# ./pants run src/python/pants_release/generate_github_workflows.py
jobs:
build_wheels_linux_arm64:
container:
image: ghcr.io/pantsbuild/wheel_build_aarch64:v3-8384c5cf
env:
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
if: github.repository_owner == 'pantsbuild'
name: Build wheels (Linux-ARM64)
needs:
- release_info
runs-on:
- self-hosted
- Linux
- ARM64
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 10
ref: ${{ needs.release_info.outputs.build-ref }}
- name: Configure Git
run: git config --global safe.directory "$GITHUB_WORKSPACE"
- name: Install rustup
run: 'curl --proto ''=https'' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s --
-v -y --default-toolchain none
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
'
- name: Expose Pythons
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
echo "/opt/python/cp38-cp38/bin" >> $GITHUB_PATH
echo "/opt/python/cp39-cp39/bin" >> $GITHUB_PATH
'
- env:
PANTS_CONFIG_FILES: +['pants.ci.toml','pants.ci.aarch64.toml']
name: Build wheels
run: ./pants run src/python/pants_release/release.py -- build-wheels
- env:
PANTS_CONFIG_FILES: +['pants.ci.toml','pants.ci.aarch64.toml']
name: Build Pants PEX
run: ./pants package src/python/pants:pants-pex
- continue-on-error: true
if: always()
name: Upload pants.log
uses: actions/upload-artifact@v3
with:
name: logs-wheels-and-pex-Linux-ARM64
path: .pants.d/*.log
- env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: Deploy wheels to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py
- if: needs.release_info.outputs.is-release == 'true'
name: Upload Pants PEX
run: "LOCAL_TAG=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"\
import sys;major, minor = sys.version_info[:2];import os;uname = os.uname();print(f'cp{major}{minor}-{uname.sysname.lower()}_{uname.machine.lower()}')\"\
)\nmv dist/src.python.pants/pants-pex.pex dist/src.python.pants/pants.$LOCAL_TAG.pex\n\
\ncurl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{ github.token\
\ }}\" \\\n -H \"Content-Type: application/octet-stream\" \\\n ${{ needs.release_info.outputs.release-asset-upload-url\
\ }}?name=pants.$LOCAL_TAG.pex \\\n --data-binary \"@dist/src.python.pants/pants.$LOCAL_TAG.pex\"\
\n"
timeout-minutes: 90
build_wheels_linux_x86_64:
container:
image: quay.io/pypa/manylinux2014_x86_64:latest
env:
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
if: github.repository_owner == 'pantsbuild'
name: Build wheels (Linux-x86_64)
needs:
- release_info
runs-on:
- ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 10
ref: ${{ needs.release_info.outputs.build-ref }}
- name: Configure Git
run: git config --global safe.directory "$GITHUB_WORKSPACE"
- name: Install rustup
run: 'curl --proto ''=https'' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s --
-v -y --default-toolchain none
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
'
- name: Expose Pythons
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
echo "/opt/python/cp38-cp38/bin" >> $GITHUB_PATH
echo "/opt/python/cp39-cp39/bin" >> $GITHUB_PATH
'
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.5
- env: {}
name: Build wheels
run: ./pants run src/python/pants_release/release.py -- build-wheels
- env: {}
name: Build Pants PEX
run: ./pants package src/python/pants:pants-pex
- continue-on-error: true
if: always()
name: Upload pants.log
uses: actions/upload-artifact@v3
with:
name: logs-wheels-and-pex-Linux-x86_64
path: .pants.d/*.log
- env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: Deploy wheels to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py
- if: needs.release_info.outputs.is-release == 'true'
name: Upload Pants PEX
run: "LOCAL_TAG=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"\
import sys;major, minor = sys.version_info[:2];import os;uname = os.uname();print(f'cp{major}{minor}-{uname.sysname.lower()}_{uname.machine.lower()}')\"\
)\nmv dist/src.python.pants/pants-pex.pex dist/src.python.pants/pants.$LOCAL_TAG.pex\n\
\ncurl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{ github.token\
\ }}\" \\\n -H \"Content-Type: application/octet-stream\" \\\n ${{ needs.release_info.outputs.release-asset-upload-url\
\ }}?name=pants.$LOCAL_TAG.pex \\\n --data-binary \"@dist/src.python.pants/pants.$LOCAL_TAG.pex\"\
\n"
timeout-minutes: 90
build_wheels_macos10_15_x86_64:
env:
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
if: github.repository_owner == 'pantsbuild'
name: Build wheels (macOS10-15-x86_64)
needs:
- release_info
runs-on:
- self-hosted
- macOS-10.15-X64
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 10
ref: ${{ needs.release_info.outputs.build-ref }}
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
key: macOS10-15-x86_64-rustup-${{ hashFiles('rust-toolchain') }}-v2
path: '~/.rustup/toolchains/1.71.0-*
~/.rustup/update-hashes
~/.rustup/settings.toml
'
- name: Cache Cargo
uses: benjyw/rust-cache@461b9f8eee66b575bce78977bf649b8b7a8d53f1
with:
cache-bin: 'false'
shared-key: engine
workspaces: src/rust/engine
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.5
- env:
ARCHFLAGS: -arch x86_64
name: Build wheels
run: ./pants run src/python/pants_release/release.py -- build-wheels
- env:
ARCHFLAGS: -arch x86_64
name: Build Pants PEX
run: ./pants package src/python/pants:pants-pex
- continue-on-error: true
if: always()
name: Upload pants.log
uses: actions/upload-artifact@v3
with:
name: logs-wheels-and-pex-macOS10-15-x86_64
path: .pants.d/*.log
- env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: Deploy wheels to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py
- if: needs.release_info.outputs.is-release == 'true'
name: Upload Pants PEX
run: "LOCAL_TAG=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"\
import sys;major, minor = sys.version_info[:2];import os;uname = os.uname();print(f'cp{major}{minor}-{uname.sysname.lower()}_{uname.machine.lower()}')\"\
)\nmv dist/src.python.pants/pants-pex.pex dist/src.python.pants/pants.$LOCAL_TAG.pex\n\
\ncurl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{ github.token\
\ }}\" \\\n -H \"Content-Type: application/octet-stream\" \\\n ${{ needs.release_info.outputs.release-asset-upload-url\
\ }}?name=pants.$LOCAL_TAG.pex \\\n --data-binary \"@dist/src.python.pants/pants.$LOCAL_TAG.pex\"\
\n"
timeout-minutes: 90
build_wheels_macos11_arm64:
env:
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
if: github.repository_owner == 'pantsbuild'
name: Build wheels (macOS11-ARM64)
needs:
- release_info
runs-on:
- self-hosted
- macOS-11-ARM64
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 10
ref: ${{ needs.release_info.outputs.build-ref }}
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
key: macOS11-ARM64-rustup-${{ hashFiles('rust-toolchain') }}-v2
path: '~/.rustup/toolchains/1.71.0-*
~/.rustup/update-hashes
~/.rustup/settings.toml
'
- name: Cache Cargo
uses: benjyw/rust-cache@461b9f8eee66b575bce78977bf649b8b7a8d53f1
with:
cache-bin: 'false'
shared-key: engine
workspaces: src/rust/engine
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.5
- env:
ARCHFLAGS: -arch arm64
name: Build wheels
run: ./pants run src/python/pants_release/release.py -- build-wheels
- env:
ARCHFLAGS: -arch arm64
name: Build Pants PEX
run: ./pants package src/python/pants:pants-pex
- continue-on-error: true
if: always()
name: Upload pants.log
uses: actions/upload-artifact@v3
with:
name: logs-wheels-and-pex-macOS11-ARM64
path: .pants.d/*.log
- env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: Deploy wheels to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py
- if: needs.release_info.outputs.is-release == 'true'
name: Upload Pants PEX
run: "LOCAL_TAG=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"\
import sys;major, minor = sys.version_info[:2];import os;uname = os.uname();print(f'cp{major}{minor}-{uname.sysname.lower()}_{uname.machine.lower()}')\"\
)\nmv dist/src.python.pants/pants-pex.pex dist/src.python.pants/pants.$LOCAL_TAG.pex\n\
\ncurl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{ github.token\
\ }}\" \\\n -H \"Content-Type: application/octet-stream\" \\\n ${{ needs.release_info.outputs.release-asset-upload-url\
\ }}?name=pants.$LOCAL_TAG.pex \\\n --data-binary \"@dist/src.python.pants/pants.$LOCAL_TAG.pex\"\
\n"
timeout-minutes: 90
publish:
if: github.repository_owner == 'pantsbuild' && needs.release_info.outputs.is-release
== 'true'
needs:
- build_wheels_linux_x86_64
- build_wheels_linux_arm64
- build_wheels_macos10_15_x86_64
- build_wheels_macos11_arm64
- release_info
runs-on: ubuntu-latest
steps:
- name: Checkout Pants at Release Tag
uses: actions/checkout@v3
with:
fetch-depth: '0'
ref: ${{ needs.release_info.outputs.build-ref }}
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@627a8ce25d972afa03da1641be9261bbbe0e3ffe
- env:
MODE: debug
name: Fetch and stabilize wheels
run: ./pants run src/python/pants_release/release.py -- fetch-and-stabilize
--dest=dest/pypi_release
- name: Create Release -> Commit Mapping
run: 'tag="${{ needs.release_info.outputs.build-ref }}"
commit="$(git rev-parse ${tag}^{commit})"
echo "Recording tag ${tag} is of commit ${commit}"
mkdir -p dist/deploy/tags/pantsbuild.pants
echo "${commit}" > "dist/deploy/tags/pantsbuild.pants/${tag}"
'
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dest/pypi_release
password: ${{ secrets.PANTSBUILD_PYPI_API_TOKEN }}
skip-existing: true
- name: Generate announcement
run: './pants run src/python/pants_release/generate_release_announcement.py --
--channel=slack >> ${{ runner.temp }}/slack_announcement.json
'
- env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
name: Announce to Slack
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: C18RRR4JK
payload-file-path: ${{ runner.temp }}/slack_announcement.json
- env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: Deploy commit mapping to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py -- --scope tags/pantsbuild.pants
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
name: Publish GitHub Release
run: 'gh release upload ${{ needs.release_info.outputs.build-ref }} dest/pypi_release/*
gh release edit ${{ needs.release_info.outputs.build-ref }} --draft=false
'
release_info:
if: github.repository_owner == 'pantsbuild'
name: Create draft release and output info
outputs:
build-ref: ${{ steps.get_info.outputs.build-ref }}
is-release: ${{ steps.get_info.outputs.is-release }}
release-asset-upload-url: ${{ steps.make_draft_release.outputs.release-asset-upload-url
}}
runs-on: ubuntu-latest
steps:
- env:
REF: ${{ github.event.inputs.ref }}
id: get_info
name: Determine ref to build
run: "if [[ -n \"$REF\" ]]; then\n ref=\"$REF\"\nelse\n ref=\"${GITHUB_REF#refs/tags/}\"\
\nfi\necho \"build-ref=${ref}\" >> $GITHUB_OUTPUT\nif [[ \"${ref}\" =~ ^release_.+$\
\ ]]; then\n echo \"is-release=true\" >> $GITHUB_OUTPUT\nfi\n"
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
id: make_draft_release
if: github.repository_owner == 'pantsbuild' && steps.get_info.outputs.is-release
== 'true'
name: Make GitHub Release
run: "RELEASE_TAG=${{ steps.get_info.outputs.build-ref }}\nRELEASE_VERSION=\"\
${RELEASE_TAG#release_}\"\n\n# NB: This could be a re-run of a release, in\
\ the event a job/step failed.\nif ! gh release view $RELEASE_TAG ; then\n\
\ GH_RELEASE_ARGS=(\"--notes\" \"\")\n GH_RELEASE_ARGS+=(\"--title\"\
\ \"$RELEASE_TAG\")\n if [[ $RELEASE_VERSION =~ [[:alpha:]] ]]; then\n\
\ GH_RELEASE_ARGS+=(\"--prerelease\")\n GH_RELEASE_ARGS+=(\"\
--latest=false\")\n else\n STABLE_RELEASE_TAGS=$(gh api -X GET -F\
\ per_page=100 /repos/{owner}/{repo}/releases --jq '.[].tag_name | sub(\"\
^release_\"; \"\") | select(test(\"^[0-9.]+$\"))')\n LATEST_TAG=$(echo\
\ \"$STABLE_RELEASE_TAGS $RELEASE_TAG\" | tr ' ' '\\n' | sort --version-sort\
\ | tail -n 1)\n if [[ $RELEASE_TAG == $LATEST_TAG ]]; then\n \
\ GH_RELEASE_ARGS+=(\"--latest=true\")\n else\n GH_RELEASE_ARGS+=(\"\
--latest=false\")\n fi\n fi\n\n gh release create \"$RELEASE_TAG\"\
\ \"${GH_RELEASE_ARGS[@]}\" --draft\nfi\n\nASSET_UPLOAD_URL=$(gh release view\
\ \"$RELEASE_TAG\" --json uploadUrl --jq '.uploadUrl | sub(\"\\\\{\\\\?.*$\"\
; \"\")')\necho \"release-asset-upload-url=$ASSET_UPLOAD_URL\" >> $GITHUB_OUTPUT\n"
name: Release
'on':
push:
tags:
- release_*
workflow_dispatch:
inputs:
ref:
required: true
type: string