forked from nod-ai/shark-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (182 loc) · 7.64 KB
/
build_packages.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
# Copyright 2024 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Build packages
on:
# Trigger from another workflow (typically to build dev packages and then test them)
workflow_call:
inputs:
build_type:
description: The type of build version to produce ("stable", "rc", or "dev")
type: string
default: "dev"
# Trigger manually (typically to test the workflow or manually build a release [candidate])
workflow_dispatch:
inputs:
build_type:
description: The type of build version to produce ("stable", "rc", or "dev")
type: string
default: "rc"
# Trigger on a schedule to build nightly release candidates.
schedule:
# Runs at 11:00 AM UTC, which is 3:00 AM PST (UTC-8)
- cron: '0 11 * * *'
permissions:
contents: read
jobs:
# Generate metadata on Linux and pass to later jobs.
setup_metadata:
if: ${{ github.repository_owner == 'nod-ai' || github.event_name != 'schedule' }}
runs-on: ubuntu-24.04
outputs:
version_suffix: ${{ steps.version_local.outputs.version_suffix }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3.12
- name: Install Python packages
run: pip install packaging
# Compute version suffix based on inputs (default to 'rc')
- name: Compute stable version suffix
if: ${{ inputs.build_type == 'stable' }}
run: |
version_suffix=""
echo "version_suffix=${version_suffix}" >> $GITHUB_ENV
- name: Compute rc version suffix
if: ${{ inputs.build_type == 'rc' || inputs.build_type == '' }}
run: |
version_suffix="$(printf 'rc%(%Y%m%d)T')"
echo "version_suffix=${version_suffix}" >> $GITHUB_ENV
- name: Compute dev version suffix
if: ${{ inputs.build_type == 'dev' }}
run: |
version_suffix=".dev0+${{ github.sha }}"
echo "version_suffix=${version_suffix}" >> $GITHUB_ENV
- name: Write version local files
id: version_local
run: |
echo "version_suffix=${version_suffix}" >> $GITHUB_OUTPUT
python3 build_tools/python_deploy/compute_local_version.py --version-suffix=${version_suffix} --write-json sharktank
python3 build_tools/python_deploy/compute_local_version.py --version-suffix=${version_suffix} --write-json shortfin
python3 build_tools/python_deploy/compute_common_version.py --version-suffix=${version_suffix} --write-json
- name: Upload version_local.json files
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: version_local_files
path: |
sharktank/version_local.json
shortfin/version_local.json
shark-ai/version_local.json
build_packages:
name: "${{ matrix.package }} :: ${{ matrix.platform }} :: ${{ matrix.python-version }}"
runs-on: ${{ matrix.runs-on }}
permissions:
contents: write
needs: [setup_metadata]
env:
OUTPUT_DIR: "${{ github.workspace }}/bindist"
strategy:
fail-fast: false
matrix:
include:
# Ubuntu packages.
- runs-on: ubuntu-24.04
platform: linux-x86_64
package: shark-ai
python-version: cp311-cp311 # Ignored (generic wheel), set for workflow naming
- runs-on: ubuntu-24.04
platform: linux-x86_64
package: sharktank
python-version: cp311-cp311 # Ignored (generic wheel), set for workflow naming
- runs-on: ubuntu-24.04
platform: linux-x86_64
package: shortfin
python-version: cp310-cp310
- runs-on: ubuntu-24.04
platform: linux-x86_64
package: shortfin
python-version: cp311-cp311
- runs-on: ubuntu-24.04
platform: linux-x86_64
package: shortfin
python-version: cp312-cp312
- runs-on: ubuntu-24.04
platform: linux-x86_64
package: shortfin
python-version: cp313-cp313
- runs-on: ubuntu-24.04
platform: linux-x86_64
package: shortfin
python-version: cp313-cp313t
# TODO(#130): macOS platform
# TODO(#130): Windows platform
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: "c" # Windows can hit path length limits, so use a short path.
submodules: false
- name: Download version_local.json files
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: version_local_files
path: ./c/
merge-multiple: true
# Dev builds can use a cache and disable tracing to halve the build time.
# Other build use no cache for supply chain security and keep tracing enabled.
- name: Apply dev settings
if: ${{ inputs.build_type == 'dev' }}
run: |
echo "CACHE_DIR=${{ github.workspace }}/.shark-ai-cache" >> $GITHUB_ENV
echo "SHORTFIN_ENABLE_TRACING=OFF" >> $GITHUB_ENV
- name: Setup cache
if: ${{ inputs.build_type == 'dev' }}
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ${{ env.CACHE_DIR }}
key: build-packages-${{ matrix.package }}-${{ matrix.platform }}-${{ matrix.python-version }}-v1-${{ github.sha }}
restore-keys: |
build-packages-${{ matrix.package }}-${{ matrix.platform }}-${{ matrix.python-version }}-v1-
# Build packages.
- name: Build shark-ai (Linux x86_64)
if: "matrix.package == 'shark-ai' && matrix.platform == 'linux-x86_64'"
run: |
[ -e ./bindist/* ] && rm ./bindist/*
./c/build_tools/python_deploy/write_requirements.py --version-suffix=${{ needs.setup_metadata.outputs.version_suffix }}
./c/shark-ai/build_tools/build_linux_package.sh
- name: Build sharktank (Linux x86_64)
if: "matrix.package == 'sharktank' && matrix.platform == 'linux-x86_64'"
run: |
[ -e ./bindist/* ] && rm ./bindist/*
./c/sharktank/build_tools/build_linux_package.sh
- name: Build shortfin (Linux x86_64, ${{ matrix.python-version }})
if: "matrix.package == 'shortfin' && matrix.platform == 'linux-x86_64'"
env:
OVERRIDE_PYTHON_VERSIONS: "${{ matrix.python-version }}"
run: |
[ -e ./bindist/* ] && rm ./bindist/*
./c/shortfin/build_tools/build_linux_package.sh
# Always upload to GitHub artifacts.
- name: Upload python wheels
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
if-no-files-found: error
name: snapshot-${{ matrix.package }}-${{ matrix.platform }}-${{ matrix.python-version }}
path: bindist
# Upload release candidate versions to a 'dev-wheels' GitHub release.
- name: Release rc python wheels
if: ${{ inputs.build_type == 'rc' || inputs.build_type == '' }}
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
artifacts: bindist/*.whl
tag: "dev-wheels"
name: "dev-wheels"
body: "Automatic snapshot release of shark-ai python wheels."
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: false