Skip to content

Commit b32dda2

Browse files
str4dtstellar
authored andcommitted
github: Add manual workflow to build and upload release binaries
Reviewed By: kwk Differential Revision: https://reviews.llvm.org/D143535 (cherry picked from commit 5b8156b)
1 parent ef4c177 commit b32dda2

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Release Binaries
2+
3+
on:
4+
push:
5+
tags:
6+
- 'llvmorg-*'
7+
workflow_dispatch:
8+
inputs:
9+
upload:
10+
description: 'Upload binaries to the release page'
11+
required: true
12+
default: true
13+
type: boolean
14+
tag:
15+
description: 'Tag to build'
16+
required: true
17+
type: string
18+
19+
permissions:
20+
contents: read # Default everything to read-only
21+
22+
jobs:
23+
prepare:
24+
name: Prepare to build binaries
25+
runs-on: ubuntu-22.04
26+
if: github.repository == 'llvm/llvm-project'
27+
outputs:
28+
release-version: ${{ steps.validate-tag.outputs.release-version }}
29+
release: ${{ steps.validate-tag.outputs.release }}
30+
build-dir: ${{ steps.validate-tag.outputs.build-dir }}
31+
rc-flags: ${{ steps.validate-tag.outputs.rc-flags }}
32+
ref: ${{ steps.validate-tag.outputs.ref }}
33+
34+
steps:
35+
- name: Checkout LLVM
36+
uses: actions/checkout@v3
37+
38+
- name: Validate and parse tag
39+
id: validate-tag
40+
# In order for the test-release.sh script to run correctly, the LLVM
41+
# source needs to be at the following location relative to the build dir:
42+
# | X.Y.Z-rcN | ./rcN/llvm-project
43+
# | X.Y.Z | ./final/llvm-project
44+
#
45+
# We also need to set divergent flags based on the release version:
46+
# | X.Y.Z-rcN | -rc N -test-asserts
47+
# | X.Y.Z | -final
48+
run: |
49+
tag="${{ github.ref_name }}"
50+
trimmed=`echo ${{ inputs.tag }} | xargs`
51+
[[ "$trimmed" != "" ]] && tag="$trimmed"
52+
if [ -n "${{ inputs.upload }}" ]; then
53+
upload="${{ inputs.upload }}"
54+
else
55+
upload="true"
56+
fi
57+
bash .github/workflows/set-release-binary-outputs.sh "${{ github.actor }}" "$tag" "$upload"
58+
59+
build-binaries:
60+
name: ${{ matrix.target.triple }}
61+
permissions:
62+
contents: write # To upload assets to release.
63+
needs: prepare
64+
runs-on: ${{ matrix.target.runs-on }}
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
target:
69+
- triple: x86_64-linux-gnu-ubuntu-22.04
70+
runs-on: ubuntu-22.04-8x32
71+
debian-build-deps: >
72+
chrpath
73+
gcc-multilib
74+
ninja-build
75+
76+
steps:
77+
- name: Checkout LLVM
78+
uses: actions/checkout@v3
79+
with:
80+
ref: ${{ needs.prepare.outputs.ref }}
81+
path: ${{ needs.prepare.outputs.build-dir }}/llvm-project
82+
83+
- name: Install Brew build dependencies
84+
if: matrix.target.brew-build-deps != ''
85+
run: brew install ${{ matrix.target.brew-build-deps }}
86+
87+
- name: Install Debian build dependencies
88+
if: matrix.target.debian-build-deps != ''
89+
run: sudo apt install ${{ matrix.target.debian-build-deps }}
90+
91+
- name: Set macOS build env variables
92+
if: runner.os == 'macOS'
93+
run: |
94+
echo "MACOSX_DEPLOYMENT_TARGET=10.9" >> $GITHUB_ENV
95+
96+
- name: Build and test release
97+
run: |
98+
${{ needs.prepare.outputs.build-dir }}/llvm-project/llvm/utils/release/test-release.sh \
99+
-release ${{ needs.prepare.outputs.release }} \
100+
${{ needs.prepare.outputs.rc-flags }} \
101+
-triple ${{ matrix.target.triple }} \
102+
-use-ninja \
103+
-no-checkout \
104+
-no-test-suite
105+
106+
- name: Upload binaries
107+
if: ${{ always() && needs.prepare.outputs.upload == 'true' }}
108+
run: |
109+
${{ needs.prepare.outputs.build-dir }}/llvm-project/llvm/utils/release/github-upload-release.py \
110+
--token ${{ github.token }} \
111+
--release ${{ needs.prepare.outputs.release-version }} \
112+
upload \
113+
--files ${{ needs.prepare.outputs.build-dir }}/clang+llvm-${{ needs.prepare.outputs.release-version }}-${{ matrix.target.triple }}.tar.xz
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Usage: set-release-binary-outputs.sh <github_user> <tag> <upload>
2+
3+
set -e
4+
5+
if [ -z "$GITHUB_OUTPUT" ]; then
6+
export GITHUB_OUTPUT=`mktemp`
7+
echo "Warning: Environment variable GITHUB_OUTPUT is not set."
8+
echo "Writing output variables to $GITHUB_OUTPUT"
9+
fi
10+
11+
github_user=$1
12+
tag=$2
13+
upload=$3
14+
15+
if [[ "$github_user" != "tstellar" && "$github_user" != "tru" ]]; then
16+
echo "ERROR: User not allowed: $github_user"
17+
exit 1
18+
fi
19+
pattern='^llvmorg-[0-9]\+\.[0-9]\+\.[0-9]\+\(-rc[0-9]\+\)\?$'
20+
echo "$tag" | grep -e $pattern
21+
if [ $? != 0 ]; then
22+
echo "ERROR: Tag '$tag' doesn't match pattern: $pattern"
23+
exit 1
24+
fi
25+
release_version=`echo "$tag" | sed 's/llvmorg-//g'`
26+
release=`echo "$release_version" | sed 's/-.*//g'`
27+
build_dir=`echo "$release_version" | sed 's,^[^-]\+,final,' | sed 's,[^-]\+-rc\(.\+\),rc\1,'`
28+
rc_flags=`echo "$release_version" | sed 's,^[^-]\+,-final,' | sed 's,[^-]\+-rc\(.\+\),-rc \1 -test-asserts,' | sed 's,--,-,'`
29+
echo "release-version=$release_version" >> $GITHUB_OUTPUT
30+
echo "release=$release" >> $GITHUB_OUTPUT
31+
echo "build-dir=$build_dir" >> $GITHUB_OUTPUT
32+
echo "rc-flags=$rc_flags" >> $GITHUB_OUTPUT
33+
echo "upload=$upload" >> $GITHUB_OUTPUT
34+
echo "ref=$tag" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)