-
-
Notifications
You must be signed in to change notification settings - Fork 8
122 lines (118 loc) · 4.05 KB
/
build.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
name: Build
on:
push:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Install and configure dependencies
run: |
sudo apt-get install -qq bats
- uses: actions/checkout@v4
- name: Build
run: |
cmake -S . -B build
cmake --build build
- name: Test
run: bats tests.bats
build:
strategy:
fail-fast: false
matrix:
include:
- TARGET: x86_64-linux-gnu # the native build, tested in a container on a mac
OS: ubuntu-latest
CC: cc
- TARGET: x86_64-linux-musl # tested in an alpine container on a mac
OS: ubuntu-latest
CC: x86_64-linux-musl-gcc
- TARGET: aarch64-linux-gnu # tested on aws t4g.nano
OS: ubuntu-latest
CC: aarch64-linux-gnu-gcc
- TARGET: aarch64-linux-musl # tested in an alpine container on aws t4g.nano
OS: ubuntu-latest
CC: aarch64-linux-musl-gcc
- TARGET: arm-linux-gnueabihf # tested on a Raspberry Pi 400
OS: ubuntu-latest
CC: arm-linux-gnueabihf-gcc
- TARGET: arm-linux-musl # tested in an alphine container on a Raspberry Pi 400
OS: ubuntu-latest
CC: arm-linux-musleabihf-gcc
- TARGET: x86_64-apple-darwin # tested on a mac, is not properly signed so there are security warnings
OS: macos-latest
CC: cc
needs: test
runs-on: ${{ matrix.OS }}
env:
NAME: multirun
TARGET: ${{ matrix.TARGET }}
OS: ${{ matrix.OS }}
CC: ${{ matrix.CC }}
steps:
- name: Musl compilers cache
uses: actions/cache@v4
with:
path: |
~/musl-compilers
key: build-musl-compilers-dir
- name: Install and configure dependencies
run: |
# dependencies are only needed on ubuntu as that's the only place where
# we make cross-compilation
if [[ $OS =~ ^ubuntu.*$ ]]; then
sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf
fi
# download musl compilers
mkdir -p $HOME/musl-compilers
pushd $HOME/musl-compilers
if [[ ! -d x86_64-linux-musl-cross ]]; then
wget -q -c http://musl.cc/x86_64-linux-musl-cross.tgz -O - | tar -xz
fi
if [[ ! -d aarch64-linux-musl-cross ]]; then
wget -q -c http://musl.cc/aarch64-linux-musl-cross.tgz -O - | tar -xz
fi
if [[ ! -d arm-linux-musleabihf-cross ]]; then
wget -q -c http://musl.cc/arm-linux-musleabihf-cross.tgz -O - | tar -xz
fi
popd
- uses: actions/checkout@v4
- name: List
run: find .
- name: Build
run: |
export PATH=$PATH:$HOME/musl-compilers/x86_64-linux-musl-cross/bin
export PATH=$PATH:$HOME/musl-compilers/aarch64-linux-musl-cross/bin
export PATH=$PATH:$HOME/musl-compilers/arm-linux-musleabihf-cross/bin
cmake -S . -B build
cmake --build build
- name: Compress
run: |
mkdir -p ./artifacts
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
TAG=$GITHUB_REF_NAME
else
TAG=$GITHUB_SHA
fi
tar -czf ./artifacts/$NAME-$TARGET-${{github.ref_name}}.tar.gz --directory build $NAME
- name: Archive artifact
uses: actions/upload-artifact@v4
with:
name: multirun-${{ matrix.TARGET }}-${{github.ref_name}}.tar.gz
path: ./artifacts/multirun-${{ matrix.TARGET }}-${{github.ref_name}}.tar.gz
# deploys to github releases on tag
deploy:
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: "*.tar.gz"
merge-multiple: true
- name: List
run: find ./artifacts
- name: Release
uses: softprops/action-gh-release@v2
with:
files: ./artifacts/*.tar.gz