Release Binaries #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --require-hashes -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 | |
# Re-enable once PGO builds are supported. | |
if: false | |
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.xz" | |
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 |