forked from tindy2013/subconverter
-
Notifications
You must be signed in to change notification settings - Fork 0
346 lines (299 loc) · 11.8 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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
name: GitHub CI
on: [push]
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
linux_multi_arch_build:
# The host should always be linux
runs-on: ubuntu-18.04
name: Build on ${{ matrix.distro }} ${{ matrix.arch }}
# Run steps on a matrix of these arch/distro combinations
strategy:
matrix:
include:
- arch: aarch64
distro: ubuntu20.04
- arch: armv7
distro: ubuntu20.04
- arch: 386
distro: ubuntu20.04
base_image: i386/ubuntu:20.04
- arch: x86_64
distro: ubuntu20.04
base_image: amd64/ubuntu:20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: uraimo/run-on-arch-action@v2
name: Run commands
id: runcmd
with:
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}
base_image: ${{ matrix.base_image }}
# Not required, but speeds up builds by storing container images in
# a GitHub package registry.
githubToken: ${{ github.token }}
# Install some dependencies in the container. This speeds up builds if
# you are also using githubToken. Any dependencies installed here will
# be part of the container image that gets cached, so subsequent
# builds don't have to re-install them. The image layer is cached
# publicly in your project's package repository, so it is vital that
# no secrets are present in the container state or logs.
install: |
#!/bin/bash
set -x
apt update
apt install -y git build-essential gcc-8 g++-8 libboost-all-dev \
python3-pip libevent-dev libssl-dev \
libcurl4-openssl-dev libpcre2-dev ninja-build pkg-config
python3 -m pip install --upgrade pip
PIP_ONLY_BINARY=cmake python3 -m pip install cmake || true
hash cmake 2>/dev/null || {
echo "Build CMake from source ..."
cd /tmp
git clone -b 'v3.25.1' --single-branch --depth 1 https://github.com/Kitware/CMake.git CMake
cd CMake
./bootstrap --prefix=/usr/local
make -j$(nproc)
make install
cd ..
rm -rf CMake
}
cmake --version
# Set an output parameter `uname` for use in subsequent steps
run: |
#!/bin/bash
set -x
uname -a
echo ::set-output name=uname::$(uname -a)
git config --global --add safe.directory '*'
export CC=/usr/bin/gcc-8
export CXX=/usr/bin/g++-8
bash ./scripts/build.sh
- name: Upload
uses: actions/upload-artifact@v1
with:
name: subconverter_${{ matrix.arch }}
path: subconverter/
- name: Package Release
if: startsWith(github.ref, 'refs/tags/')
run: tar czf subconverter_${{ matrix.arch }}.tar.gz subconverter
- name: Draft Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: subconverter_${{ matrix.arch }}.tar.gz
draft: true
# For building Entware package
entware_multi_arch_build:
# The host should always be linux
runs-on: ubuntu-18.04
name: Build on ${{ matrix.distro }} ${{ matrix.arch }}
# Run steps on a matrix of these arch/distro combinations
strategy:
matrix:
include:
- arch: aarch64
distro: entware-aarch64-k3.10
base_image: longhronshens/entware-builder:aarch64-k3.10-latest
- arch: armv7
distro: entware-armv7sf-k3.2
base_image: longhronshens/entware-builder:armv7sf-k3.2-latest
- arch: mipsel
distro: entware-mipselsf-k3.4
base_image: longhronshens/entware-builder:mipselsf-k3.4-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: LonghronShen/run-on-arch-action@master
name: Run commands
id: runcmd
with:
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}
base_image: ${{ matrix.base_image }}
qemu_static_image: longhronshens/qemu-user-static
# Not required, but speeds up builds by storing container images in
# a GitHub package registry.
githubToken: ${{ github.token }}
installShell: /opt/bin/bash
install: |
set -x
opkg update
opkg install libatomic
ldconfig -p
shell: /opt/bin/bash
# Set an output parameter `uname` for use in subsequent steps
run: |
set -x
uname -a
echo ::set-output name=uname::$(uname -a)
git config --global --add safe.directory '*'
source /opt/bin/gcc_env.sh
bash ./scripts/build.sh
- name: Upload
uses: actions/upload-artifact@v1
with:
name: subconverter_${{ matrix.distro }}_${{ matrix.arch }}
path: subconverter/
- name: Package Release
if: startsWith(github.ref, 'refs/tags/')
run: tar czf subconverter_${{ matrix.distro }}_${{ matrix.arch }}.tar.gz subconverter
- name: Draft Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: subconverter_${{ matrix.distro }}_${{ matrix.arch }}.tar.gz
draft: true
macos_build:
name: macOS Build
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build
run: cd scripts && ./build.macos.release.sh
- name: Upload
uses: actions/upload-artifact@v1
with:
name: subconverter_darwin64
path: subconverter/
- name: Package Release
if: startsWith(github.ref, 'refs/tags/')
run: tar czf subconverter_darwin64.tar.gz subconverter
- name: Draft Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: subconverter_darwin64.tar.gz
draft: true
windows_build:
runs-on: windows-latest
name: Build on msystem ${{ matrix.msystem }} ${{ matrix.env }}
# Run steps on a matrix of 3 arch/distro combinations
strategy:
matrix:
include:
- { msystem: CLANG64, env: clang-x86_64, name: win64 }
- { msystem: CLANG32, env: clang-i686, name: win32 }
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: msys2/setup-msys2@v2
with:
update: false
msystem: ${{matrix.msystem}}
install: >-
git
make
patch
binutils
pacboy: >-
toolchain:p
cmake:p
ninja:p
libevent:p
pcre2:p
boost:p
- name: Build
run: cd scripts && bash ./build.windows.release.sh
- name: Upload
uses: actions/upload-artifact@v1
with:
name: subconverter_${{ matrix.name }}
path: subconverter/
- name: Package Release
if: startsWith(github.ref, 'refs/tags/')
run: 7z a subconverter_${{ matrix.name }}.7z subconverter/
- name: Draft Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: subconverter_${{ matrix.name }}.7z
draft: true
build_win_msvc:
name: windows-msvc-${{ matrix.arch }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- { arch: amd64, name: msvc_win64, triplet: x64-windows-static }
- { arch: x86, name: msvc_win32, triplet: x86-windows-static }
- {
arch: amd64_arm64,
name: msvc_arm64,
triplet: arm64-windows-static,
}
env:
# Indicates the location of the vcpkg as a Git submodule of the project repository.
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
# Tells vcpkg where binary packages are stored.
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache
VCPKG_TARGET_TRIPLET: "${{ matrix.triplet }}"
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'"
run: mkdir -p $VCPKG_DEFAULT_BINARY_CACHE
shell: bash
- uses: lukka/get-cmake@latest
# Restore both vcpkg and its artifacts from the GitHub cache service.
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v3
with:
# The first path is the location of vcpkg: it contains the vcpkg executable and data files, as long as the
# built package archives (aka binary cache) which are located by VCPKG_DEFAULT_BINARY_CACHE env var.
# The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages.
path: |
${{ env.VCPKG_ROOT }}
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
!${{ env.VCPKG_ROOT }}/installed
# The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service.
# The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm.
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'vcpkg.json' ) }}-${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }}
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly.
# As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
# Run CMake to generate Ninja project files, using the vcpkg's toolchain file to resolve and install the dependencies as specified in vcpkg.json.
- name: Install dependencies and generate project files
run: |
cmake --compile-no-warning-as-error --preset ninja-multi-vcpkg -DVCPKG_TARGET_TRIPLET="${{ matrix.triplet }}"
# Build the whole project with Ninja (which is spawn by CMake). Release configuration.
- name: Build (Release)
run: |
cmake --build --preset ninja-multi-vcpkg-release
- name: Upload
uses: actions/upload-artifact@v1
with:
name: subconverter_${{ matrix.name }}
path: builds/ninja-multi-vcpkg/bin/
- name: Package Release
if: startsWith(github.ref, 'refs/tags/')
run: 7z a subconverter_${{ matrix.name }}.7z builds/ninja-multi-vcpkg/bin/
- name: Draft Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: subconverter_${{ matrix.name }}.7z
draft: true