-
Notifications
You must be signed in to change notification settings - Fork 0
329 lines (272 loc) · 10.6 KB
/
Copy pathcreate_release.yml
File metadata and controls
329 lines (272 loc) · 10.6 KB
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
# Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
name: Create Releases
on:
schedule:
# Run weekly on Monday 00:00 UTC
- cron: '0 0 * * MON'
push:
branches: [main, rel-*]
pull_request:
branches: [main, rel-*]
types:
- labeled
- synchronize
workflow_dispatch:
inputs:
publish_pypi_weekly: # only from main branch it is possible to publish to pypi-weekly (official weekly preview build)
description: 'Publish to pypi-weekly'
required: true
type: choice
options:
- 'yes'
- 'no'
default: 'no'
publish_testpypi_weekly: # only from main branch it is possible to publish to testpypi-weekly
description: 'Publish to testpypi-weekly'
required: true
type: choice
options:
- 'yes'
- 'no'
default: 'no'
publish_testpypi_release: # only from rel branch it is possible to publish to test-pypi (for rc1, rc2, etc.)
description: 'Publish to testpypi-release'
required: true
type: choice
options:
- 'yes'
- 'no'
default: 'no'
publish_pypi_release:
description: 'Caution: Publish to pypi-release'
required: true
type: choice
options:
- 'yes'
- 'no'
default: 'no'
build_mode:
description: 'Specify the build mode (release or preview)'
required: true
type: choice
options:
- 'release'
- 'preview'
default: 'preview'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
cancel-in-progress: true
jobs:
call-linux:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_linux.yml
with:
os: "linux"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
call-win:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_win.yml
with:
os: "win"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
call-mac:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_mac.yml
with:
os: "macos"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
call-sdist:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_sdist.yml
with:
os: "macos"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
check_for_publish_release_build_to_pypi:
name: Check for Publish release build to pypi
runs-on: ubuntu-latest
needs: [call-linux, call-mac, call-win, call-sdist]
if: (!contains(join(needs.*.result, ' '), 'skipped')) && (github.event.inputs.publish_pypi_release == 'yes') && (github.repository_owner == 'onnx') && startsWith(github.ref, 'refs/heads/rel-') && (github.event_name == 'workflow_dispatch')
steps:
- name: Ensure build mode is release
run: |
if [ "$BUILD_MODE" != "release" ]; then
echo "Error: build_mode must be set to 'release' to proceed."
exit 1
fi
env:
BUILD_MODE: ${{ github.event.inputs.build_mode }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
- name: Check if package_version matches branch
run: |
branch_version=${GITHUB_REF#refs/heads/rel-}
package_version=$(cat VERSION_NUMBER)
echo "Branch version: $branch_version"
echo "Package version: $package_version"
if [[ "$package_version" != "$branch_version" && "$package_version" != "$branch_version"rc* ]]; then
echo "Error: Package version ($package_version) does not match branch version ($branch_version) or expected RC format."
exit 1
fi
check_for_publish_preview_build_to_testpypi_weekly:
name: Check for Publish preview build to test.pypi-weekly
runs-on: ubuntu-latest
needs: [call-linux, call-mac, call-win,call-sdist]
if: (!contains(join(needs.*.result, ' '), 'skipped')) && (github.event.inputs.publish_testpypi_weekly == 'yes') && (github.ref == 'refs/heads/main') && (github.repository_owner == 'onnx') && (github.event_name == 'workflow_dispatch')
steps:
- name: print debug vars
run: |
echo "All environment variables:"
printenv
publish_preview_build_to_testpypi_weekly:
name: Publish preview build to test.pypi-weekly
runs-on: ubuntu-latest
needs: [check_for_publish_preview_build_to_testpypi_weekly]
environment:
name: testpypi-weekly
url: https://test.pypi.org/p/onnx-weekly
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
if: (github.event_name == 'workflow_dispatch' )
with:
pattern: wheels*
path: dist
merge-multiple: true
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
if: (github.event_name == 'workflow_dispatch' )
with:
pattern: sdist
path: dist
merge-multiple: true
- name: Upload preview build to test.pypi
if: (github.ref == 'refs/heads/main') && (github.event.inputs.publish_testpypi_weekly == 'yes') && (github.repository_owner == 'onnx')
id: upload_preview_build_to_testpypi_weekly
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
print-hash: true
check_for_publish_release_build_to_testpypi:
name: Check for Publish release build to test.pypi (rc-candidates)
runs-on: ubuntu-latest
needs: [call-linux, call-mac, call-win, call-sdist]
if: (!contains(join(needs.*.result, ' '), 'skipped')) && (github.event.inputs.publish_testpypi_release == 'yes') && startsWith(github.ref, 'refs/heads/rel') && (github.repository_owner == 'onnx') && (github.event_name == 'workflow_dispatch')
steps:
- name: print debug vars
run: |
echo "All environment variables:"
printenv
publish_release_build_to_testpypi:
name: Publish release build to test.pypi
runs-on: ubuntu-latest
needs: [check_for_publish_release_build_to_testpypi]
environment:
name: testpypi-release
url: https://test.pypi.org/p/onnx
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
if: (github.event_name == 'workflow_dispatch' )
with:
pattern: wheels*
path: dist
merge-multiple: true
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
if: (github.event_name == 'workflow_dispatch' )
with:
pattern: sdist
path: dist
merge-multiple: true
- name: Upload release build to test.pypi
id: upload_release_build_to_testpypi
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
print-hash: true
check_for_publish_preview_build_to_pypi_weekly:
name: Check for Publish preview build to pypi-weekly
runs-on: ubuntu-latest
needs: [call-linux, call-mac, call-win, call-sdist]
if: (!contains(join(needs.*.result, ' '), 'skipped')) && (github.event_name == 'schedule' || github.event.inputs.publish_pypi_weekly == 'yes') && (github.repository_owner == 'onnx')
steps:
- name: placeholder for debug vars
run: |
echo "All environment variables:"
printenv
publish_preview_build_to_pypi_weekly:
name: Publish preview build to pypi-weekly
runs-on: ubuntu-latest
needs: [check_for_publish_preview_build_to_pypi_weekly]
environment:
name: pypi-weekly
url: https://pypi.org/p/onnx-weekly
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
with:
pattern: wheels*
path: dist
merge-multiple: true
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
with:
pattern: sdist
path: dist
merge-multiple: true
- name: Upload preview_build to pypi-weekly
id: upload_preview_build_to_pypi_weekly
if: (github.ref == 'refs/heads/main')
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
repository-url: https://upload.pypi.org/legacy/
verbose: true
print-hash: true
publish_release_build_to_pypi:
name: Publish release build to pypi
runs-on: ubuntu-latest
needs: [check_for_publish_release_build_to_pypi]
environment:
name: pypi-release
url: https://pypi.org/p/onnx
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
pattern: wheels*
path: dist
merge-multiple: true
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
pattern: sdist
path: dist
merge-multiple: true
- name: Publish release_build to pypi
if: (github.repository_owner == 'onnx')
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
repository-url: https://upload.pypi.org/legacy/
verbose: true
print-hash: true
test_source_dist:
name: test source distribution
needs: [publish_preview_build_to_pypi_weekly, publish_release_build_to_testpypi]
if: (needs.publish_preview_build_to_pypi_weekly.result == 'success' || needs.publish_release_build_to_testpypi.result == 'success')
uses: ./.github/workflows/preview_source_dist_test.yml
with:
os: "linux"