brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.3 KiB · a8bae83 Raw
290 lines · yaml
1name: Release Binaries2 3on:4  workflow_dispatch:5    inputs:6      release-version:7        description: 'Release Version'8        required: false9        type: string10      upload:11        description: 'Upload binaries to the release page'12        required: true13        default: false14        type: boolean15      runs-on:16        description: "Runner to use for the build"17        required: true18        type: choice19        # We use ubuntu-22.04 rather than the latest version to make the built20        # binaries more portable (eg functional aginast older glibc).21        options:22          - ubuntu-22.0423          - ubuntu-22.04-arm24          - macos-1425 26  workflow_call:27    inputs:28      release-version:29        description: 'Release Version'30        required: false31        type: string32      upload:33        description: 'Upload binaries to the release page'34        required: true35        default: false36        type: boolean37      runs-on:38        description: "Runner to use for the build"39        required: true40        type: string41    secrets:42      RELEASE_TASKS_USER_TOKEN:43        description: "Secret used to check user permissions."44        required: false45 46 47permissions:48  contents: read # Default everything to read-only49 50jobs:51  prepare:52    name: Prepare to build binaries53    runs-on: ${{ inputs.runs-on }}54    if: github.repository_owner == 'llvm'55    outputs:56      release-version: ${{ steps.vars.outputs.release-version }}57      ref: ${{ steps.vars.outputs.ref }}58      upload: ${{ steps.vars.outputs.upload }}59      target-cmake-flags: ${{ steps.vars.outputs.target-cmake-flags }}60      build-flang: ${{ steps.vars.outputs.build-flang }}61      release-binary-basename: ${{ steps.vars.outputs.release-binary-basename }}62      release-binary-filename: ${{ steps.vars.outputs.release-binary-filename }}63      build-runs-on: ${{ steps.vars.outputs.build-runs-on }}64      test-runs-on: ${{ steps.vars.outputs.build-runs-on }}65 66    steps:67    # It's good practice to use setup-python, but this is also required on macos-1468    # due to https://github.com/actions/runner-images/issues/1038569    - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.070      with:71        python-version: '3.14'72 73    - name: Checkout LLVM74      uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.075 76    - name: Install Dependencies77      shell: bash78      run: |79        pip install --require-hashes -r ./llvm/utils/git/requirements.txt80 81    - name: Check Permissions82      if: github.event_name != 'pull_request'83      env:84        GITHUB_TOKEN: ${{ github.token }}85        USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}86      shell: bash87      run: |88        ./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user "$GITHUB_ACTOR" --user-token "$USER_TOKEN" check-permissions89 90    - name: Collect Variables91      id: vars92      shell: bash93      # In order for the test-release.sh script to run correctly, the LLVM94      # source needs to be at the following location relative to the build dir:95      # | X.Y.Z-rcN | ./rcN/llvm-project96      # | X.Y.Z     | ./final/llvm-project97      #98      # We also need to set divergent flags based on the release version:99      # | X.Y.Z-rcN | -rc N -test-asserts100      # | X.Y.Z     | -final101      run: |102        trimmed=$(echo ${{ inputs.release-version }} | xargs)103        if [ -n "$trimmed" ]; then104          release_version="$trimmed"105          ref="llvmorg-$release_version"106        else107          release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-$GITHUB_SHA"108          ref="$GITHUB_SHA"109        fi110        if [ -n "${{ inputs.upload }}" ]; then111          upload="${{ inputs.upload }}"112        else113          upload="false"114        fi115        echo "release-version=$release_version">> $GITHUB_OUTPUT116        echo "ref=$ref" >> $GITHUB_OUTPUT117        echo "upload=$upload" >> $GITHUB_OUTPUT118 119        release_binary_basename="LLVM-$release_version-$RUNNER_OS-$RUNNER_ARCH"120        echo "release-binary-basename=$release_binary_basename" >> $GITHUB_OUTPUT121        echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT122 123        target="$RUNNER_OS-$RUNNER_ARCH"124 125        # The macOS builds try to cross compile some libraries so we need to126        # add extra CMake args to disable them.127        # See https://github.com/llvm/llvm-project/issues/99767128        if [ "$RUNNER_OS" = "macOS" ]; then129          target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_COMPILER_RT_ENABLE_IOS=OFF"130          if [ "$RUNNER_ARCH" = "ARM64" ]; then131            arches=arm64132          fi133          target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"134        fi135 136        if [ "$RUNNER_OS" = "Windows" ]; then137          # The build times out on Windows, so we need to disable LTO.138          target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF"139        fi140 141        case "${{ inputs.runs-on }}" in142          ubuntu-22.04*)143            build_runs_on="depot-${{ inputs.runs-on }}-16"144            test_runs_on=$build_runs_on145            ;;146          macos-14)147            if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then148              build_runs_on="${{ inputs.runs-on }}"149            else150              build_runs_on="depot-macos-14"151            fi152            test_runs_on="${{ inputs.runs-on }}"153            ;;154          *)155            test_runs_on="${{ inputs.runs-on }}"156            build_runs_on=$test_runs_on157            ;;158        esac159 160        case "$build_runs_on" in161          # These runners cannot build the full release package faster than162          # the 6 hours timeout limit, so we need to use a configuration163          # that builds more quickly.164          macos-14)165            bootstrap_prefix="BOOTSTRAP"166            target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF -DLLVM_RELEASE_ENABLE_PGO=OFF"167            ;;168          *)169            bootstrap_prefix="BOOTSTRAP_BOOTSTRAP"170            ;;171        esac172 173        target_cmake_flags="$target_cmake_flags -D${bootstrap_prefix}_CPACK_PACKAGE_FILE_NAME=$release_binary_basename"174 175        echo "target-cmake-flags=$target_cmake_flags" >> $GITHUB_OUTPUT176        echo "build-runs-on=$build_runs_on" >> $GITHUB_OUTPUT177        echo "test-runs-on=$test_runs_on" >> $GITHUB_OUTPUT178 179  build-release-package:180    name: "Build Release Package"181    needs: prepare182    if: github.repository_owner == 'llvm'183    runs-on: ${{ needs.prepare.outputs.build-runs-on }}184    steps:185 186    - name: Checkout LLVM187      uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0188      with:189        ref: ${{ needs.prepare.outputs.ref }}190 191    - name: Set Build Prefix192      id: setup-stage193      shell: bash194      run: |195        build_prefix=`pwd`196        if [ "${{ runner.os }}" = "Linux" ]; then197          sudo chown $USER:$USER /mnt/198          build_prefix=/mnt/199        fi200        echo "build-prefix=$build_prefix" >> $GITHUB_OUTPUT201 202    - name: Configure203      id: build204      shell: bash205      run: |206        # There were some issues on the ARM64 MacOS runners with trying to build x86 object,207        # so we need to set some extra cmake flags to disable this.208        cmake -G Ninja -S llvm -B ${{ steps.setup-stage.outputs.build-prefix }}/build \209            ${{ needs.prepare.outputs.target-cmake-flags }} \210            -C clang/cmake/caches/Release.cmake211 212    - name: Build213      shell: bash214      run: |215        ninja -v -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-package216        release_dir=`find ${{ steps.setup-stage.outputs.build-prefix }}/build -iname 'stage2-bins'`217        mv $release_dir/${{ needs.prepare.outputs.release-binary-filename }} .218    219    - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0220      with:221        name: ${{ runner.os }}-${{ runner.arch }}-release-binary222        # Due to path differences on Windows when running in bash vs running on node,223        # we need to search for files in the current workspace.224        path: |225          ${{ needs.prepare.outputs.release-binary-filename }}226 227    - name: Run Tests228      # These almost always fail so don't let them fail the build and prevent the uploads.229      continue-on-error: true230      run: |231        ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-check-all232 233  upload-release-binaries:234    name: "Upload Release Binaries"235    needs:236      - prepare237      - build-release-package238    if: >-239      github.event_name != 'pull_request' &&240      needs.prepare.outputs.upload == 'true'241    runs-on: ubuntu-24.04242    permissions:243      contents: write # For release uploads244      id-token: write     # For artifact attestations245      attestations: write # For artifact attestations246 247    steps:248    - name: Checkout Release Scripts249      uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0250      with:251        sparse-checkout: |252          llvm/utils/release/github-upload-release.py253          llvm/utils/git/requirements.txt254        sparse-checkout-cone-mode: false255 256    - name: 'Download artifact'257      uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0258      with:259        pattern: '*-release-binary'260        merge-multiple: true261 262    - name: Attest Build Provenance263      id: provenance264      uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0265      with:266        subject-path: ${{ needs.prepare.outputs.release-binary-filename }}267 268    - name: Rename attestation file269      run:270        mv ${{ steps.provenance.outputs.bundle-path }} ${{ needs.prepare.outputs.release-binary-filename }}.jsonl271 272    - name: Upload Build Provenance273      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0274      with:275        name: ${{ needs.prepare.outputs.release-binary-filename }}-attestation276        path: ${{ needs.prepare.outputs.release-binary-filename }}.jsonl277 278    - name: Install Python Requirements279      run: |280        pip install --require-hashes -r ./llvm/utils/git/requirements.txt281 282    - name: Upload Release283      shell: bash284      run: |285        ./llvm/utils/release/github-upload-release.py \286        --token ${{ github.token }} \287        --release ${{ needs.prepare.outputs.release-version }} \288        upload \289        --files ${{ needs.prepare.outputs.release-binary-filename }}*290