-
-
Notifications
You must be signed in to change notification settings - Fork 2
195 lines (172 loc) · 8.59 KB
/
release.yml
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
env:
DIST_DIR: dist
# The project's folder on Arduino's download server for uploading builds
AWS_PLUGIN_TARGET: /tools/
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get-tag.outputs.TAG}}
llvm-version: ${{ steps.get-version.outputs.LLVM_VERSION}}
steps:
- id: get-tag
run: echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
- id: get-version
run: echo ::set-output name=LLVM_VERSION::llvm-project-${GITHUB_REF/refs\/tags\//}.src
build-win-mac:
needs: get-version
name: build (${{ matrix.config.name }}, ${{ matrix.config.arch }})
runs-on:
${{ matrix.config.os }}
strategy:
matrix:
config:
- name: macOS
os: macos-latest
os-cmake-args: '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang'
build-args: '-j$(sysctl -n hw.ncpu)'
bindir: '/build/bin'
arch: 64bit
- name: Windows
os: windows-latest
os-cmake-args: '-DCMAKE_CXX_FLAGS="/MP /std:c++14" -DLLVM_USE_CRT_MINSIZEREL="MT"'
build-args: '--config MinSizeRel'
bindir: '/build/MinSizeRel/bin'
extra-tar-args: '--exclude=${{ needs.get-version.outputs.llvm-version }}/clang/test/Driver/Inputs/* --exclude=${{ needs.get-version.outputs.llvm-version }}/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/* --exclude=${{ needs.get-version.outputs.llvm-version }}/libclc/amdgcn-mesa3d'
arch: 32bit
extension: .exe
- name: Windows
os: windows-latest
os-cmake-args: '-Thost=x64 -DCMAKE_CXX_FLAGS="/MP /std:c++14" -DLLVM_USE_CRT_MINSIZEREL="MT"'
build-args: '--config MinSizeRel'
bindir: '/build/MinSizeRel/bin'
arch: 64bit
extra-tar-args: '--exclude=${{ needs.get-version.outputs.llvm-version }}/clang/test/Driver/Inputs/* --exclude=${{ needs.get-version.outputs.llvm-version }}/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/* --exclude=${{ needs.get-version.outputs.llvm-version }}/libclc/amdgcn-mesa3d'
extension: .exe
env:
COMMON_CMAKE_ARGS: '-DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"'
defaults:
run:
shell: bash
steps:
- name: get llvm-project
run: curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ needs.get-version.outputs.tag }}/${{ needs.get-version.outputs.llvm-version }}.tar.xz | tar -xJ ${{ matrix.config.extra-tar-args }}
- name: cmake
run: |
cd ${{ needs.get-version.outputs.llvm-version }}
mkdir build
cd build
cmake ../llvm ${{ env.COMMON_CMAKE_ARGS }} ${{ matrix.config.os-cmake-args }}
- name: build
run: cmake --build ${{ needs.get-version.outputs.llvm-version }}/build ${{ matrix.config.build-args }} --target clang-format clangd
- name: print macos dependencies
run: |
otool -L ${{ needs.get-version.outputs.llvm-version }}${{ matrix.config.bindir }}/clangd
otool -L ${{ needs.get-version.outputs.llvm-version }}${{ matrix.config.bindir }}/clang-format
if: matrix.config.os == 'macos-latest'
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: clang_${{ matrix.config.name }}_${{ matrix.config.arch }}
path: |
${{ needs.get-version.outputs.llvm-version }}${{ matrix.config.bindir }}/clangd${{ matrix.config.extension }}
${{ needs.get-version.outputs.llvm-version }}${{ matrix.config.bindir }}/clang-format${{ matrix.config.extension }}
build-linux:
needs: get-version
name: build (${{ matrix.config.name }}, ${{ matrix.config.arch }})
runs-on:
ubuntu-latest
# apparently env vars cannot be defined here with container (https://github.community/t/how-to-use-env-with-container-image/17252)
strategy:
matrix:
config:
- name: Linux
arch: 64bit
os-cmake-args: '-DCMAKE_CXX_COMPILER=x86_64-ubuntu16.04-linux-gnu-g++ -DCMAKE_C_COMPILER=x86_64-ubuntu16.04-linux-gnu-gcc'
- name: Linux
arch: 32bit
os-cmake-args: '-DCMAKE_CXX_COMPILER=i686-ubuntu16.04-linux-gnu-g++ -DCMAKE_C_COMPILER=i686-ubuntu16.04-linux-gnu-gcc'
- name: Linux
arch: ARMv6
os-cmake-args: '-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CROSSCOMPILING=True -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DLLVM_TABLEGEN=/tmp/llvm-tblgen -DCLANG_TABLEGEN=/tmp/clang-tblgen'
- name: Linux
arch: ARM64
os-cmake-args: '-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CROSSCOMPILING=True -DLLVM_TARGET_ARCH=AArch64 -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AArch64 -DLLVM_TABLEGEN=/tmp/llvm-tblgen -DCLANG_TABLEGEN=/tmp/clang-tblgen'
container:
image: ghcr.io/arduino/crossbuild:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.CLANG_CI_PAT }}
steps:
- name: Set env vars
run: echo "COMMON_CMAKE_ARGS=-DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_PROJECTS=\"clang;clang-tools-extra\" -DCMAKE_CXX_FLAGS=\"-s -static-libstdc++ -static-libgcc\" -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_SYSTEM_NAME=\"Linux\"" >> $GITHUB_ENV
- name: get llvm-project
run: curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ needs.get-version.outputs.tag }}/${{ needs.get-version.outputs.llvm-version }}.tar.xz | tar -xJ
- name: install Ninja
run: apt update && apt install ninja-build
- name: build llvm-tblgen clang-tblgen with the host toolchain
run: |
cd ${{ needs.get-version.outputs.llvm-version }}
mkdir -p build
cd build
cmake -G Ninja ../llvm ${{ env.COMMON_CMAKE_ARGS }} -DCMAKE_CXX_COMPILER=x86_64-ubuntu16.04-linux-gnu-g++ -DCMAKE_C_COMPILER=x86_64-ubuntu16.04-linux-gnu-gcc
ninja llvm-tblgen clang-tblgen
cp -v bin/llvm-tblgen /tmp
cp -v bin/clang-tblgen /tmp
rm -rf *
if: matrix.config.arch == 'ARMv6' || matrix.config.arch == 'ARM64'
- name: build clangd and clang-format
run: |
cd ${{ needs.get-version.outputs.llvm-version }}
mkdir -p build
cd build
cmake -G Ninja ../llvm ${{ env.COMMON_CMAKE_ARGS }} ${{ matrix.config.os-cmake-args }}
ninja clang-format clangd
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: clang_${{ matrix.config.name }}_${{ matrix.config.arch }}
path: |
${{ needs.get-version.outputs.llvm-version }}/build/bin/clangd*
${{ needs.get-version.outputs.llvm-version }}/build/bin/clang-format*
create-release:
runs-on: ubuntu-latest
needs: [build-linux, build-win-mac, get-version]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
- name: Prepare artifacts for the release
run: |
mkdir ${{ env.DIST_DIR }}
declare -a target_folders=("Linux_64bit" "Linux_32bit" "Linux_ARM64" "Linux_ARMv6" "macOS_64bit" "Windows_32bit" "Windows_64bit")
for folder in "${target_folders[@]}"
do
chmod -v +x clang_$folder/*
CLANGD=clangd_${{ needs.get-version.outputs.tag }}_${folder}.tar.bz2
CLANGFORMAT=clang-format_${{ needs.get-version.outputs.tag }}_${folder}.tar.bz2
tar -cvjf $CLANGD clang_$folder/clangd*
tar -cvjf $CLANGFORMAT clang_$folder/clang-format*
done
mv -v clang*.tar.bz2 ${{ env.DIST_DIR }}/
- name: Create Github Release and upload artifacts
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
# (all the files we need are in the release folder root)
artifacts: ${{ env.DIST_DIR }}/*
- name: Upload release files on Arduino downloads servers
uses: docker://plugins/s3
env:
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}