forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 11
344 lines (313 loc) · 14.2 KB
/
build_package.yml
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
# Builds release packages on supported platforms:
# * main-dist-linux (CMake 'install')
# * py-compiler-pkg (`iree-compiler` Python package)
# * Linux, macOS, Windows
# * All supported Python versions (e.g. 3.9, 3.10, 3.11)
# * py-runtime-pkg (`iree-runtime` Python package)
# * Linux, macOS, Windows
# * All supported Python versions (e.g. 3.9, 3.10, 3.11)
# * py-tf-compiler-tools-pkg (`iree-tools-[tf, tflite]`, pure Python packages)
name: Build Release Packages
# Note: this workflow is typically invoked by schedule_candidate_release.yml.
on:
workflow_dispatch:
inputs:
package_suffix:
description: "Suffix to append to package names"
required: false
default: ""
package_version:
description: "Version of the package"
required: true
default: "0.1a1"
release_id:
description: "Release id to upload artifacts to"
default: ""
commit:
description: "Commit to check out"
default: ""
jobs:
build_packages:
name: "${{ matrix.build-family }} :: Build ${{ matrix.build-package }} Package"
runs-on: ${{ matrix.runs-on }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
include:
# Ubuntu packages.
- runs-on: icelake
build-family: linux
build-package: py-compiler-pkg
experimental: false
- runs-on: icelake
build-family: linux
build-package: py-runtime-pkg
experimental: false
# Macos packages.
- runs-on: MacStudio
build-family: macos
build-package: py-compiler-pkg
experimental: true
- runs-on: MacStudio
build-family: macos
build-package: py-runtime-pkg
experimental: true
# Windows packages.
- runs-on:
- ${{ github.repository == 'openxla/iree' && 'windows-2022-64core' || '7950X'}}
build-family: windows
build-package: py-compiler-pkg
experimental: true
- runs-on: 7950X
build-family: windows
build-package: py-runtime-pkg
experimental: true
# Linux AArch64 packages.
- runs-on: linux-aarch64
build-family: linux-aarch64
build-package: py-compiler-pkg
experimental: false
- runs-on: linux-aarch64
build-family: linux-aarch64
build-package: py-runtime-pkg
experimental: false
env:
# These are also set in: build_tools/python_deploy/build_linux_packages.sh
MANYLINUX_X86_64_IMAGE: ghcr.io/nod-ai/manylinux_x86_64:main
MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64
steps:
# Docker may leave root owned files
- name: Chown user
if: "matrix.build-family == 'linux-aarch64' || matrix.build-family == 'linux'"
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
path: "c" # Windows can hit path length limits, so use a short path.
submodules: true
ref: ${{ github.event.inputs.commit }}
- uses: actions/setup-python@v4
if: "matrix.build-family == 'windows'"
with:
python-version: '3.11'
##########################################################################
# OS specific setup
##########################################################################
#- name: Install dependencies (Windows)
# if: "matrix.build-family == 'windows'"
# shell: powershell
# run: ./c/build_tools/python_deploy/install_windows_deps.ps1
- name: "Configure MSVC (Windows)"
if: "matrix.build-family == 'windows'"
uses: ilammy/msvc-dev-cmd@7315a94840631165970262a99c72cfb48a65d25d # v1.12.0
with:
arch: x64
##########################################################################
# Write version_info.json
# Various tools will read this in order to embed release information.
##########################################################################
- name: Write version info (release)
if: "matrix.build-family != 'windows'"
shell: bash
run: |
cat << EOF > ./c/version_info.json
{
"package-suffix": "${{ github.event.inputs.package_suffix }}",
"package-version": "${{ github.event.inputs.package_version }}",
"iree-revision": "$(cd ./c && git rev-parse HEAD)"
}
EOF
cat ./c/version_info.json
- name: Write version info Windows (release)
if: "matrix.build-family == 'windows'"
shell: powershell
run: |
cd c
$verinfoprop = @{
'package-suffix'= "${{ github.event.inputs.package_suffix }}"
'package-version'= "${{ github.event.inputs.package_version }}"
'iree-revision'= $(git rev-parse HEAD)
}
$info = New-Object -TypeName PSObject -Prop $verinfoprop
$info = $info | ConvertTo-JSON
$info | Out-File "version_info.json" -Encoding "ASCII"
##########################################################################
# Build the main distribution tarball.
# The main distribution consists of the project being built, installed
# and archived. We have to split it per operating system, and Linux
# is special because we build under a manylinux container which gives
# broad compatibility. We use the Python based manylinux containers
# since they come packaged with all dev tools we need. Note that the
# manylinux containers have a default python 2.x with all supported
# python versions under /opt/python (need to add one to the path). It
# is not enough to just invoke it directly because then pip managed
# console scripts (like cmake, ninja) will not be on the path.
##########################################################################
- name: Main distribution (Linux for x86_64)
if: "matrix.build-package == 'main-dist-linux' && matrix.build-family == 'linux-x86_64'"
shell: bash
run: |
docker run --rm -w=/work \
-v $PWD:/work \
"${MANYLINUX_X86_64_IMAGE}" \
bash -c 'export PATH=/opt/python/cp39-cp39/bin:$PATH; python ./c/build_tools/github_actions/build_dist.py main-dist'
- name: Main distribution (Linux for Arm64)
if: "matrix.build-package == 'main-dist-linux' && matrix.build-family == 'linux-aarch64'"
shell: bash
run: |
docker run --rm -w=/work \
-v $PWD:/work \
"${MANYLINUX_AARCH64_IMAGE}" \
bash -c 'export PATH=/opt/python/cp39-cp39/bin:$PATH; python ./c/build_tools/github_actions/build_dist.py main-dist'
##########################################################################
# py-runtime-pkg
# Builds the iree-runtime wheels.
# One step per OS.
##########################################################################
- name: Build runtime wheels (Linux, x86_64 and Arm64)
if: "matrix.build-package == 'py-runtime-pkg' && contains(matrix.build-family, 'linux')"
shell: bash
env:
package_suffix: ${{ github.event.inputs.package_suffix }}
packages: "iree-runtime"
output_dir: "${{ github.workspace }}/bindist"
run: |
[ -e ./bindist/* ] && rm ./bindist/*
./c/build_tools/python_deploy/build_linux_packages.sh
- name: Build runtime wheels (MacOS)
if: "matrix.build-package == 'py-runtime-pkg' && matrix.build-family == 'macos'"
shell: bash
env:
package_suffix: ${{ github.event.inputs.package_suffix }}
packages: "iree-runtime"
output_dir: "${{ github.workspace }}/bindist"
override_python_versions: "3.11"
run: |
[ -e ./bindist/* ] && rm ./bindist/*
./c/build_tools/python_deploy/build_macos_packages.sh
- name: Build runtime wheels (Windows)
if: "matrix.build-package == 'py-runtime-pkg' && matrix.build-family == 'windows'"
shell: powershell
env:
package_suffix: ${{ github.event.inputs.package_suffix }}
packages: "iree-runtime"
output_dir: "${{ github.workspace }}/bindist"
override_python_versions: "3.11"
run: |
if (Test-Path -Path "${{ github.workspace }}/bindist") {
Remove-Item -Path "${{ github.workspace }}/bindist" -Recurse -Force
}
./c/build_tools/python_deploy/build_windows_packages.ps1
##########################################################################
# py-compiler-pkg
# Builds the iree-compiler wheel.
# One step per OS.
##########################################################################
- name: Build compiler wheels (Linux, x86_64 and Arm64)
if: "matrix.build-package == 'py-compiler-pkg' && contains(matrix.build-family, 'linux')"
shell: bash
env:
package_suffix: ${{ github.event.inputs.package_suffix }}
packages: "iree-compiler"
output_dir: "${{ github.workspace }}/bindist"
run: |
[ -e ./bindist/* ] && rm ./bindist/*
./c/build_tools/python_deploy/build_linux_packages.sh
- name: Build compiler wheels (Linux-AArch64)
if: "matrix.build-package == 'py-compiler-pkg' && matrix.build-family == 'linux-aarch64'"
shell: bash
env:
package_suffix: ${{ github.event.inputs.package_suffix }}
packages: "iree-compiler"
output_dir: "${{ github.workspace }}/bindist"
run: |
./c/build_tools/python_deploy/build_linux_packages.sh
- name: Build compiler wheels (MacOS)
if: "matrix.build-package == 'py-compiler-pkg' && matrix.build-family == 'macos'"
shell: bash
env:
package_suffix: ${{ github.event.inputs.package_suffix }}
packages: "iree-compiler"
output_dir: "${{ github.workspace }}/bindist"
override_python_versions: "3.11"
run: |
[ -e ./bindist/* ] && rm ./bindist/*
./c/build_tools/python_deploy/build_macos_packages.sh
- name: Build compiler wheels (Windows)
if: "matrix.build-package == 'py-compiler-pkg' && matrix.build-family == 'windows'"
shell: powershell
env:
package_suffix: ${{ github.event.inputs.package_suffix }}
packages: "iree-compiler"
output_dir: "${{ github.workspace }}/bindist"
override_python_versions: "3.11"
run: |
if (Test-Path -Path "${{ github.workspace }}/bindist") {
Remove-Item -Path "${{ github.workspace }}/bindist" -Recurse -Force
}
./c/build_tools/python_deploy/build_windows_packages.ps1
##########################################################################
# TF Compiler Tools
# These wheels are not Python version specific and include only Python
# code (no C/C++), so just build for one examplar python version on Linux.
##########################################################################
- name: Build TF Compiler Tools wheels
if: "matrix.build-package == 'py-tf-compiler-tools-pkg'"
shell: bash
run: |
docker run --rm -w=/work \
-v $PWD:/work \
"${MANYLINUX_X86_64_IMAGE}" \
bash -c 'export PATH=/opt/python/cp39-cp39/bin:$PATH; python ./c/build_tools/github_actions/build_dist.py py-tf-compiler-tools-pkg'
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
# We upload all wheels (which includes deps so that subsequent
# steps can run without further fetching).
path: ./bindist/*
retention-days: 5
# TODO: One Window Release builds we build both compiler+runtime
- name: Upload Release Assets (Windows)
if: "github.event.inputs.release_id != '' && matrix.build-family == 'windows'"
id: upload-release-assets-windows
uses: dwenegar/upload-release-assets@5bc3024cf83521df8ebfadf00ad0c4614fd59148 # v1
env:
GITHUB_TOKEN: ${{ secrets.WRITE_ACCESS_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}
# Only upload iree artifacts.
assets_path: ./bindist/iree*.*
# TODO: Upload the tar.bz2 files too when ready
- name: Upload Release Assets (Compiler)
if: "github.event.inputs.release_id != '' && matrix.build-package == 'py-compiler-pkg' && matrix.build-family != 'windows'"
id: upload-release-assets-compiler
uses: dwenegar/upload-release-assets@5bc3024cf83521df8ebfadf00ad0c4614fd59148 # v1
env:
GITHUB_TOKEN: ${{ secrets.WRITE_ACCESS_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}
# Only upload iree artifacts.
assets_path: ./bindist/iree_compiler*.*
- name: Upload Release Assets (Runtime)
if: "github.event.inputs.release_id != '' && matrix.build-package == 'py-runtime-pkg' && matrix.build-family != 'windows'"
id: upload-release-assets-runtime
uses: dwenegar/upload-release-assets@5bc3024cf83521df8ebfadf00ad0c4614fd59148 # v1
env:
GITHUB_TOKEN: ${{ secrets.WRITE_ACCESS_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}
# Only upload iree artifacts.
assets_path: ./bindist/iree_runtime*.*
validate_and_publish:
name: "Trigger validate and publish release"
needs: build_packages
if: github.event.inputs.release_id != ''
runs-on: ubuntu-20.04
steps:
- name: "Invoke workflow :: Validate and Publish Release"
uses: benc-uk/workflow-dispatch@798e70c97009500150087d30d9f11c5444830385 # v1.2.2
with:
workflow: Validate and Publish Release
token: ${{ secrets.WRITE_ACCESS_TOKEN }}
ref: "${{ env.tag_name }}"
inputs: '{"release_id": "${{ github.event.inputs.release_id }}", "package_version": "${{ github.event.inputs.package_version }}", "build_run_id": "${{ github.run_id }}"}'