forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
306 lines (265 loc) · 9.47 KB
/
release-binaries.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
name: Release Binaries
on:
workflow_dispatch:
inputs:
release-version:
description: 'Release Version'
required: true
type: string
upload:
description: 'Upload binaries to the release page'
required: true
default: false
type: boolean
workflow_call:
inputs:
release-version:
description: 'Release Version'
required: true
type: string
upload:
description: 'Upload binaries to the release page'
required: true
default: false
type: boolean
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 8 1 * *'
permissions:
contents: read # Default everything to read-only
jobs:
prepare:
name: Prepare to build binaries
runs-on: ubuntu-22.04
if: github.repository == 'llvm/llvm-project'
outputs:
release-version: ${{ steps.vars.outputs.release-version }}
ref: ${{ steps.vars.outputs.ref }}
upload: ${{ steps.vars.outputs.upload }}
steps:
- name: Checkout LLVM
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Dependencies
run: |
pip install -r ./llvm/utils/git/requirements.txt
- name: Check Permissions
env:
GITHUB_TOKEN: ${{ github.token }}
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
run: |
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user ${{ github.actor }} --user-token "$USER_TOKEN" check-permissions
- name: Collect Variables
id: vars
# In order for the test-release.sh script to run correctly, the LLVM
# source needs to be at the following location relative to the build dir:
# | X.Y.Z-rcN | ./rcN/llvm-project
# | X.Y.Z | ./final/llvm-project
#
# We also need to set divergent flags based on the release version:
# | X.Y.Z-rcN | -rc N -test-asserts
# | X.Y.Z | -final
run: |
tag="${{ github.ref_name }}"
trimmed=$(echo ${{ inputs.release-version }} | xargs)
[[ "$trimmed" != "" ]] && tag="llvmorg-$trimmed"
if [ "$tag" = "main" ]; then
# If tag is main, then we've been triggered by a scheduled so pass so
# use the head commit as the tag.
tag=`git rev-parse HEAD`
fi
if [ -n "${{ inputs.upload }}" ]; then
upload="${{ inputs.upload }}"
else
upload="false"
fi
bash .github/workflows/set-release-binary-outputs.sh "$tag" "$upload"
build-stage1-linux:
name: "Build Stage 1 Linux"
needs: prepare
runs-on: ubuntu-22.04
if: github.repository == 'llvm/llvm-project'
steps:
- name: Checkout LLVM
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ needs.prepare.outputs.ref }}
- name: Install Ninja
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main
- name: Setup sccache
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9
with:
max-size: 250M
key: sccache-${{ runner.os }}-release
variant: sccache
- name: Build Stage 1 Clang
run: |
sudo chown $USER:$USER /mnt/
cmake -G Ninja -C clang/cmake/caches/Release.cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -S llvm -B /mnt/build
ninja -v -C /mnt/build
# We need to create an archive of the build directory, because it has too
# many files to upload.
- name: Package Build and Source Directories
run: |
tar -c . | zstd -T0 -c > llvm-project.tar.zst
tar -C /mnt/ -c build/ | zstd -T0 -c > build.tar.zst
- name: Upload Stage 1 Source
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
with:
name: stage1-source
path: llvm-project.tar.zst
retention-days: 2
- name: Upload Stage 1 Build Dir
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
with:
name: stage1-build
path: build.tar.zst
retention-days: 2
build-stage2-linux:
name: "Build Stage 2 Linux"
needs:
- prepare
- build-stage1-linux
runs-on: ubuntu-22.04
if: github.repository == 'llvm/llvm-project'
steps:
- name: Install Ninja
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main
- name: Download Stage 1 Artifacts
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
pattern: stage1-*
merge-multiple: true
- name: Unpack Artifacts
run: |
tar --zstd -xf llvm-project.tar.zst
rm llvm-project.tar.zst
sudo chown $USER:$USER /mnt/
tar --zstd -C /mnt -xf build.tar.zst
rm build.tar.zst
- name: Build Stage 2
run: |
ninja -C /mnt/build stage2-instrumented
# We need to create an archive of the build directory, because it has too
# many files to upload.
- name: Save Build and Source Directories
run: |
tar -c . | zstd -T0 -c > llvm-project.tar.zst
tar -C /mnt/ -c build/ | zstd -T0 -c > build.tar.zst
- name: Upload Stage 2 Source
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
with:
name: stage2-source
path: ${{ github.workspace }}/llvm-project.tar.zst
retention-days: 2
- name: Upload Stage 2 Build Dir
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
with:
name: stage2-build
path: ${{ github.workspace }}/build.tar.zst
retention-days: 2
build-stage3-linux:
name: "Build Stage 3 Linux"
needs:
- prepare
- build-stage2-linux
outputs:
filename: ${{ steps.package-info.outputs.release-filename }}
runs-on: ubuntu-22.04-16x64
if: github.repository == 'llvm/llvm-project'
steps:
- name: Install Ninja
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main
- name: 'Download artifact'
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
pattern: stage2-*
merge-multiple: true
- name: Unpack Artifact
run: |
tar --zstd -xf llvm-project.tar.zst
rm llvm-project.tar.zst
sudo chown $USER:$USER /mnt/
tar --zstd -C /mnt -xf build.tar.zst
rm build.tar.zst
- name: Build Release Package
run: |
ninja -C /mnt/build stage2-package
- id: package-info
run: |
filename="LLVM-${{ needs.prepare.outputs.release-version }}-Linux.tar.gz"
echo "filename=$filename" >> $GITHUB_OUTPUT
echo "path=/mnt/build/tools/clang/stage2-bins/$filename" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
if: always()
with:
name: release-binary
path: ${{ steps.package-info.outputs.path }}
# Clean up some build files to reduce size of artifact.
- name: Clean Up Build Directory
run: |
find /mnt/build -iname ${{ steps.package-info.outputs.filename }} -delete
# We need to create an archive of the build directory, because it has too
# many files to upload.
- name: Save Build and Source Directories
run: |
tar -c . | zstd -T0 -c > llvm-project.tar.zst
tar -C /mnt/ -c build/ | zstd -T0 -c > build.tar.zst
- name: Upload Stage 3 Source
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
with:
name: stage3-source
path: llvm-project.tar.zst
retention-days: 2
- name: Upload Stage 3 Build Dir
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
with:
name: stage3-build
path: build.tar.zst
retention-days: 2
upload-release-binaries-linux:
name: "Upload Linux Release Binaries"
needs:
- prepare
- build-stage3-linux
if : ${{ needs.prepare.outputs.upload == 'true' }}
runs-on: ubuntu-22.04
permissions:
contents: write # For release uploads
steps:
- name: 'Download artifact'
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: release-binary
- name: Upload Release
run: |
sudo apt install python3-github
./llvm-project/llvm/utils/release/github-upload-release.py \
--token ${{ github.token }} \
--release ${{ needs.prepare.outputs.release-version }} \
upload \
--files ${{ needs.build-stage3-linux.outputs.release-filename }}
test-stage3-linux:
name: "Test Stage 3 Linux"
needs:
- prepare
- build-stage3-linux
runs-on: ubuntu-22.04
if: github.repository == 'llvm/llvm-project'
steps:
- name: Install Ninja
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main
- name: 'Download artifact'
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
pattern: stage3-*
merge-multiple: true
- name: Unpack Artifact
run: |
tar --zstd -xf llvm-project.tar.zst
rm llvm-project.tar.zst
sudo chown $USER:$USER /mnt/
tar --zstd -C /mnt -xf build.tar.zst
rm build.tar.zst
- name: Run Tests
run: |
ninja -C /mnt/build stage2-check-all