summaryrefslogtreecommitdiff
path: root/.github/workflows/release-binaries.yml
blob: 2be6f0fbdc537eded31fe21e8fd8a5a59b4bd44e (plain)
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
name: Release Binaries

on:
  push:
    tags:
      - 'llvmorg-*'
  workflow_dispatch:
    inputs:
      upload:
        description: 'Upload binaries to the release page'
        required: true
        default: true
        type: boolean
      tag:
        description: 'Tag to build'
        required: true
        type: string

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.validate-tag.outputs.release-version }}
      release: ${{ steps.validate-tag.outputs.release }}
      build-dir: ${{ steps.validate-tag.outputs.build-dir }}
      rc-flags: ${{ steps.validate-tag.outputs.rc-flags }}
      ref: ${{ steps.validate-tag.outputs.ref }}
      upload: ${{ steps.validate-tag.outputs.upload }}

    steps:
    - name: Checkout LLVM
      uses: actions/checkout@v3

    - name: Validate and parse tag
      id: validate-tag
      # 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.tag }} | xargs`
        [[ "$trimmed" != "" ]] && tag="$trimmed"
        if [ -n "${{ inputs.upload }}" ]; then
          upload="${{ inputs.upload }}"
        else
          upload="true"
        fi
        bash .github/workflows/set-release-binary-outputs.sh "${{ github.actor }}" "$tag" "$upload"

  build-binaries:
    name: ${{ matrix.target.triple }}
    permissions:
      contents: write # To upload assets to release.
    needs: prepare
    runs-on: ${{ matrix.target.runs-on }}
    strategy:
      fail-fast: false
      matrix:
        target:
          - triple: x86_64-linux-gnu-ubuntu-22.04
            runs-on: ubuntu-22.04-8x32
            debian-build-deps: >
              chrpath
              gcc-multilib
              ninja-build

    steps:
    - name: Checkout LLVM
      uses: actions/checkout@v3
      with:
        ref: ${{ needs.prepare.outputs.ref }}
        path: ${{ needs.prepare.outputs.build-dir }}/llvm-project

    - name: Install Brew build dependencies
      if: matrix.target.brew-build-deps != ''
      run: brew install ${{ matrix.target.brew-build-deps }}

    - name: Install Debian build dependencies
      if: matrix.target.debian-build-deps != ''
      run: sudo apt install ${{ matrix.target.debian-build-deps }}

    - name: Set macOS build env variables
      if: runner.os == 'macOS'
      run: |
        echo "MACOSX_DEPLOYMENT_TARGET=10.9" >> $GITHUB_ENV

    - name: Build and test release
      run: |
        ${{ needs.prepare.outputs.build-dir }}/llvm-project/llvm/utils/release/test-release.sh \
        -release ${{ needs.prepare.outputs.release }} \
        ${{ needs.prepare.outputs.rc-flags }} \
        -triple ${{ matrix.target.triple }} \
        -use-ninja \
        -no-checkout \
        -no-test-suite

    - name: Upload binaries
      if: ${{ always() && needs.prepare.outputs.upload == 'true' }}
      run: |
        sudo apt install python3-github
        ${{ needs.prepare.outputs.build-dir }}/llvm-project/llvm/utils/release/github-upload-release.py \
        --token ${{ github.token }} \
        --release ${{ needs.prepare.outputs.release-version }} \
        upload \
        --files ${{ needs.prepare.outputs.build-dir }}/clang+llvm-${{ needs.prepare.outputs.release-version }}-${{ matrix.target.triple }}.tar.xz