7 description: 'Release Version'
11 description: 'Upload binaries to the release page'
16 description: "Runner to use for the build"
28 description: 'Release Version'
32 description: 'Upload binaries to the release page'
37 description: "Runner to use for the build"
41 RELEASE_TASKS_USER_TOKEN:
42 description: "Secret used to check user permissions."
47 contents: read # Default everything to read-only
51 name: Prepare to build binaries
52 runs-on: ${{ inputs.runs-on }}
53 if: github.repository == 'llvm/llvm-project'
55 release-version: ${{ steps.vars.outputs.release-version }}
56 ref: ${{ steps.vars.outputs.ref }}
57 upload: ${{ steps.vars.outputs.upload }}
58 target-cmake-flags: ${{ steps.vars.outputs.target-cmake-flags }}
59 build-flang: ${{ steps.vars.outputs.build-flang }}
60 enable-pgo: ${{ steps.vars.outputs.enable-pgo }}
61 release-binary-basename: ${{ steps.vars.outputs.release-binary-basename }}
62 release-binary-filename: ${{ steps.vars.outputs.release-binary-filename }}
65 # It's good practice to use setup-python, but this is also required on macos-14
66 # due to https://github.com/actions/runner-images/issues/10385
67 - uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f
69 python-version: '3.12'
72 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
74 - name: Install Dependencies
77 pip install --require-hashes -r ./llvm/utils/git/requirements.txt
79 - name: Check Permissions
80 if: github.event_name != 'pull_request'
82 GITHUB_TOKEN: ${{ github.token }}
83 USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
86 ./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user ${{ github.actor }} --user-token "$USER_TOKEN" check-permissions
88 - name: Collect Variables
91 # In order for the test-release.sh script to run correctly, the LLVM
92 # source needs to be at the following location relative to the build dir:
93 # | X.Y.Z-rcN | ./rcN/llvm-project
94 # | X.Y.Z | ./final/llvm-project
96 # We also need to set divergent flags based on the release version:
97 # | X.Y.Z-rcN | -rc N -test-asserts
100 trimmed=$(echo ${{ inputs.release-version }} | xargs)
101 if [ -n "$trimmed" ]; then
102 release_version="$trimmed"
103 ref="llvmorg-$release_version"
105 release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-${{ github.sha }}"
106 ref=${{ github.sha }}
108 if [ -n "${{ inputs.upload }}" ]; then
109 upload="${{ inputs.upload }}"
113 echo "release-version=$release_version">> $GITHUB_OUTPUT
114 echo "ref=$ref" >> $GITHUB_OUTPUT
115 echo "upload=$upload" >> $GITHUB_OUTPUT
117 release_binary_basename="LLVM-$release_version-${{ runner.os }}-${{ runner.arch }}"
118 echo "release-binary-basename=$release_binary_basename" >> $GITHUB_OUTPUT
119 echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT
121 # Detect necessary CMake flags
122 target="${{ runner.os }}-${{ runner.arch }}"
123 echo "enable-pgo=false" >> $GITHUB_OUTPUT
124 target_cmake_flags="-DLLVM_RELEASE_ENABLE_PGO=OFF"
125 # The macOS builds try to cross compile some libraries so we need to
126 # add extra CMake args to disable them.
127 # See https://github.com/llvm/llvm-project/issues/99767
128 if [ "${{ runner.os }}" = "macOS" ]; then
129 target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_COMPILER_RT_ENABLE_IOS=OFF"
130 if [ "${{ runner.arch }}" = "ARM64" ]; then
135 target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
140 if [ "${{ runner.os }}" = "Windows" ]; then
141 # The build times out on Windows, so we need to disable LTO.
142 target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF"
145 echo "target-cmake-flags=$target_cmake_flags" >> $GITHUB_OUTPUT
146 echo "build-flang=$build_flang" >> $GITHUB_OUTPUT
149 name: "Build Stage 1"
151 if: github.repository == 'llvm/llvm-project'
152 runs-on: ${{ inputs.runs-on }}
155 - name: Checkout Actions
156 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
158 ref: ${{ (github.event_name == 'pull_request' && github.sha) || 'main' }}
161 sparse-checkout-cone-mode: false
162 # Check out outside of working directory so the source checkout doesn't
166 # actions/checkout does not support paths outside of the GITHUB_WORKSPACE.
167 # Also, anything that we put inside of GITHUB_WORKSPACE will be overwritten
168 # by future actions/checkout steps. Therefore, in order to checkout the
169 # latest actions from main, we need to first checkout out the actions inside of
170 # GITHUB_WORKSPACE (see previous step), then use actions/checkout to checkout
171 # the code being built and the move the actions from main back into GITHUB_WORKSPACE,
172 # becasue the uses on composite actions only reads workflows from inside GITHUB_WORKSPACE.
174 run: mv workflows ../workflows-main
176 - name: Checkout LLVM
177 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
179 ref: ${{ needs.prepare.outputs.ref }}
181 - name: Copy main workflows
184 mv ../workflows-main .
188 uses: ./workflows-main/.github/workflows/release-binaries-setup-stage
190 - name: Setup sccache
191 uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9
193 # Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174
195 key: sccache-${{ runner.os }}-${{ runner.arch }}-release
198 - name: Build Stage 1 Clang
202 # There were some issues on the ARM64 MacOS runners with trying to build x86 object,
203 # so we need to set some extra cmake flags to disable this.
204 cmake -G Ninja -S llvm -B ${{ steps.setup-stage.outputs.build-prefix }}/build \
205 ${{ needs.prepare.outputs.target-cmake-flags }} \
206 -C clang/cmake/caches/Release.cmake \
207 -DBOOTSTRAP_LLVM_PARALLEL_LINK_JOBS=1 \
208 -DBOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}" \
209 -DCMAKE_C_COMPILER_LAUNCHER=sccache \
210 -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
211 ninja -v -C ${{ steps.setup-stage.outputs.build-prefix }}/build
212 # There is a race condition on the MacOS builders and this command is here
213 # to help debug that when it happens.
214 ls -ltr ${{ steps.setup-stage.outputs.build-prefix }}/build
217 uses: ./workflows-main/.github/workflows/release-binaries-save-stage
219 build-prefix: ${{ steps.setup-stage.outputs.build-prefix }}
222 name: "Build Stage 2"
226 if: github.repository == 'llvm/llvm-project'
227 runs-on: ${{ inputs.runs-on }}
229 - name: Checkout Actions
230 uses: actions/checkout@v4
232 ref: ${{ (github.event_name == 'pull_request' && github.sha) || 'main' }}
235 sparse-checkout-cone-mode: false
239 uses: ./workflows/.github/workflows/release-binaries-setup-stage
241 previous-artifact: build-stage1
243 - name: Build Stage 2
244 # Re-enable once PGO builds are supported.
245 if: needs.prepare.outputs.enable-pgo == 'true'
248 ninja -C ${{ steps.setup-stage.outputs.build-prefix}}/build stage2-instrumented
251 uses: ./workflows/.github/workflows/release-binaries-save-stage
253 build-prefix: ${{ steps.setup-stage.outputs.build-prefix }}
256 name: "Build Stage 3 LLVM/Clang"
260 if: github.repository == 'llvm/llvm-project'
261 runs-on: ${{ inputs.runs-on }}
263 - name: Checkout Actions
264 uses: actions/checkout@v4
266 ref: ${{ (github.event_name == 'pull_request' && github.sha) || 'main' }}
269 sparse-checkout-cone-mode: false
273 uses: ./workflows/.github/workflows/release-binaries-setup-stage
275 previous-artifact: build-stage2
277 - name: Build LLVM/Clang
280 # There is a race condition on the MacOS builders and this command is here
281 # to help debug that when it happens.
282 ls -ltr ${{ steps.setup-stage.outputs.build-prefix }}/build
283 ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-clang
284 # Build some of the larger binaries here too.
285 ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ \
290 ${{ (runner.os == 'Linux' && 'clangd-fuzzer') || '' }} \
301 uses: ./workflows/.github/workflows/release-binaries-save-stage
303 build-prefix: ${{ steps.setup-stage.outputs.build-prefix }}
306 name: "Build Stage 3 Flang/MLIR/Bolt"
310 runs-on: ${{ inputs.runs-on }}
312 - name: Checkout Actions
313 uses: actions/checkout@v4
315 ref: ${{ (github.event_name == 'pull_request' && github.sha) || 'main' }}
318 sparse-checkout-cone-mode: false
322 uses: ./workflows/.github/workflows/release-binaries-setup-stage
324 previous-artifact: build-stage3-clang
326 - name: Build Flang / MLIR / Bolt
329 # Build some of the mlir tools that take a long time to link
330 if [ "${{ needs.prepare.outputs.build-flang }}" = "true" ]; then
331 ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ -j2 flang bbc
333 ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ \
334 mlir-bytecode-parser-fuzzer \
340 mlir-text-parser-fuzzer \
345 mlir-minimal-opt-canonicalize \
346 mlir-pdll-lsp-server \
351 uses: ./workflows/.github/workflows/release-binaries-save-stage
353 build-prefix: ${{ steps.setup-stage.outputs.build-prefix }}
356 name: "Build Stage 3"
360 runs-on: ${{ inputs.runs-on }}
362 - name: Checkout Actions
363 uses: actions/checkout@v4
365 ref: ${{ (github.event_name == 'pull_request' && github.sha) || 'main' }}
368 sparse-checkout-cone-mode: false
372 uses: ./workflows/.github/workflows/release-binaries-setup-stage
374 previous-artifact: build-stage3-flang
376 - name: Build Release Package
380 ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-package
381 # Copy Release artifact to the workspace so it is easier to upload.
382 # This is necessary, because on Windows, the build-prefix path can
383 # only be used on bash steps, because it uses the form of /d/files/
384 # and other steps expect D:\files.
385 mv ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/${{ needs.prepare.outputs.release-binary-filename }} .
387 - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
389 name: ${{ runner.os }}-${{ runner.arch }}-release-binary
390 # Due to path differences on Windows when running in bash vs running on node,
391 # we need to search for files in the current workspace.
393 ${{ needs.prepare.outputs.release-binary-filename }}
395 # Clean up some build files to reduce size of artifact.
396 - name: Clean Up Build Directory
399 find ${{ steps.setup-stage.outputs.build-prefix }}/build -iname ${{ needs.prepare.outputs.release-binary-filename }} -delete
400 rm -Rf ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/_CPack_Packages
403 uses: ./workflows/.github/workflows/release-binaries-save-stage
405 build-prefix: ${{ steps.setup-stage.outputs.build-prefix }}
407 upload-release-binaries:
408 name: "Upload Release Binaries"
414 github.event_name != 'pull_request' &&
415 needs.prepare.outputs.upload == 'true'
416 runs-on: ubuntu-22.04
418 contents: write # For release uploads
419 id-token: write # For artifact attestations
420 attestations: write # For artifact attestations
423 - name: Checkout Release Scripts
424 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
427 llvm/utils/release/github-upload-release.py
428 llvm/utils/git/requirements.txt
429 sparse-checkout-cone-mode: false
431 - name: 'Download artifact'
432 uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
434 pattern: '*-release-binary'
437 - name: Attest Build Provenance
439 uses: actions/attest-build-provenance@897ed5eab6ed058a474202017ada7f40bfa52940 # v1.0.0
441 subject-path: ${{ needs.prepare.outputs.release-binary-filename }}
443 - name: Rename attestation file
445 mv ${{ steps.provenance.outputs.bundle-path }} ${{ needs.prepare.outputs.release-binary-filename }}.jsonl
447 - name: Upload Build Provenance
448 uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 #v4.3.3
450 name: ${{ needs.prepare.outputs.release-binary-filename }}-attestation
451 path: ${{ needs.prepare.outputs.release-binary-filename }}.jsonl
453 - name: Install Python Requirements
455 pip install --require-hashes -r ./llvm/utils/git/requirements.txt
457 - name: Upload Release
460 ./llvm/utils/release/github-upload-release.py \
461 --token ${{ github.token }} \
462 --release ${{ needs.prepare.outputs.release-version }} \
464 --files ${{ needs.prepare.outputs.release-binary-filename }}*
472 github.repository == 'llvm/llvm-project'
473 runs-on: ${{ inputs.runs-on }}
475 - name: Checkout Actions
476 uses: actions/checkout@v4
478 ref: ${{ (github.event_name == 'pull_request' && github.sha) || 'main' }}
481 sparse-checkout-cone-mode: false
485 uses: ./workflows/.github/workflows/release-binaries-setup-stage
487 previous-artifact: build-stage3-all
492 ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-check-all