forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
341 lines (293 loc) · 11.8 KB
/
build-firmware.yaml
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
name: Firmware at GHA
#
# this github action uses generate_matrix.sh to scan the file system and automatically produce build matrix!
#
# this github action is the heaviest one we've got, with each run taking around 10 minutes and the matrix which has a few dozens of these runs
#
# We have two mechanists to reduce github action runner consumption
# * 'skip_rate' ratio in meta-info.env files allows to skip some builds with specific skip percentage
# * 'only' syntax allow to build only specificed configuration, for example 'only:uaefi' line in the commit message would only build 'uaefi' configuration
# * for random commits we can build zero jobs if we do 'only:docs' or anything similar
#
on:
push:
pull_request:
schedule:
# this produces GitHub nightly releases https://github.com/rusefi/rusefi/releases
# by the way GitHub actions use UTC https://www.utctime.net/ which matches GMT time
# See https://github.com/rusefi/rusefi/issues/6286 for notes on scopes enabled on NIGHTLY_RELEASE_ACCESS_TOKEN
- cron: '27 0 * * *'
workflow_dispatch:
inputs:
lts:
description: 'LTS Build'
required: false
type: boolean
jobs:
build-libopenblt-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: cmake configure libopenblt
working-directory: ./firmware/ext/openblt/Host/Source/LibOpenBLT/build
run: cmake -DCMAKE_BUILD_TYPE=Release ..
# - name: make libopenblt
# working-directory: ./firmware/ext/openblt/Host/Source/LibOpenBLT/build
# run: make -j8
- name: cmake configure libopenblt_jni
working-directory: ./misc/libopenblt_jni/build
run: cmake -DCMAKE_BUILD_TYPE=Release ..
# - name: make libopenblt_jni
# working-directory: ./misc/libopenblt_jni/build
# run: make -j8
- name: coalesce
if: 0
run: |
mkdir deliver
cp ./firmware/ext/openblt/Host/libopenblt.so deliver/
cp ./misc/libopenblt_jni/build/libopenblt_jni.so deliver/
# - uses: actions/upload-artifact@v4
# if: 0
# name: libopenblt-linux
# path: |
# ./deliver/libopenblt.so
# ./deliver/libopenblt_jni.so
release:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Set run condition variables 1
# at this point 'full' means 'release' or 'server'
run: |
if [ "${{github.event_name}}" = "schedule" ] && [ "${{github.repository}}" = "rusefi/rusefi" ]; then
echo "full=true" >> $GITHUB_ENV
echo "upload=release" >> $GITHUB_ENV
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
fi
- uses: mukunku/[email protected]
id: checkTag
with:
tag: ${{ env.date }}
- name: Create Release Tag
if: ${{ env.upload == 'release' && steps.checkTag.outputs.exists == 'false' }}
id: tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.NIGHTLY_RELEASE_ACCESS_TOKEN }}
custom_tag: ${{ env.date }}
tag_prefix: ''
- name: Create Release
if: ${{ env.upload == 'release' }}
uses: ncipollo/[email protected]
with:
tag: ${{ env.date }}
name: "Nightly ${{ env.date }}"
artifacts: "artifacts/rusefi_bundle_*.zip"
replacesArtifacts: false
token: ${{ secrets.NIGHTLY_RELEASE_ACCESS_TOKEN }}
allowUpdates: true
prerelease: true
- name: coalesce
if: 0
run: |
mkdir deliver
cp ./firmware/ext/openblt/Host/libopenblt.dylib deliver/
cp ./misc/libopenblt_jni/build/libopenblt_jni.dylib deliver/
# - uses: actions/upload-artifact@v4
# with:
# name: bootcommander-linux
# path: |
# ./deliver/libopenblt.dylib
# ./deliver/libopenblt_jni.dylib
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Set matrix
id: set-matrix
run: |
export EVENT_NAME="${{github.event_name}}"
export RUN_ATTEMPT="${{github.run_attempt}}"
read -d '' COMMIT_MESSAGE << EOM || true
${{ github.event.head_commit.message }}
EOM
export COMMIT_MESSAGE
echo "matrix=$(bash firmware/bin/generate_matrix.sh)" >> $GITHUB_OUTPUT
build-firmware:
runs-on: ubuntu-latest
needs: [
# todo proper build of build-libopenblt #5866
#build-libopenblt-linux,
#build-libopenblt-macos,
release,
generate-matrix]
if: ${{ ! contains(needs.generate-matrix.outputs.matrix, '[]') }}
strategy:
# Let all builds finish even if one fails early
fail-fast: false
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
steps:
- name: Check branch name
if: ${{ contains(github.ref_name, '.') }}
run: echo '::error::Branch names must not contain ".", this breaks firmware autoupdates. Branch name is "${{ github.ref_name }}".' && exit 1
- name: Set run condition variables 2
run: |
if [ "${{github.event_name}}" = "schedule" ] && [ "${{github.repository}}" = "rusefi/rusefi" ]; then
echo "Creating nightly build"
echo "full=true" >> $GITHUB_ENV
echo "upload=release" >> $GITHUB_ENV
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
elif [ "${{github.event_name}}" = "push" ]\
&& [ "${{github.ref}}" = "refs/heads/master" ]\
|| [ "${{toJSON(inputs.lts)}}" = "true" ]; then
echo "Server upload mode"
echo "full=true" >> $GITHUB_ENV
echo "upload=server" >> $GITHUB_ENV
else
echo "GHA artifact mode"
echo "upload=gha_artifact" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
- name: Checkout Submodules
run: |
misc/git_scripts/common_submodule_init.sh
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
- name: Install multilib, mingw, sshpass and mtools
run: |
sudo bash misc/actions/add-ubuntu-latest-apt-mirrors.sh
sudo bash misc/actions/ubuntu-install-tools.sh
- name: Set Build Env Variables
working-directory: ./firmware/
run: |
echo AUTOMATION_LTS=${{toJSON(inputs.lts)}} >> $GITHUB_ENV
echo AUTOMATION_REF=${{github.ref_name}} >> $GITHUB_ENV
echo BOARD_META_PATH=${{matrix.meta-info}} >> $GITHUB_ENV
echo "WHITE_LABEL=rusefi" >> $GITHUB_ENV
- name: Git Status
run: |
git status
#
# Note to humans: on personal devices we have firmware/provide_gcc.sh and setup_linux_environment.sh
#
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '12.3.Rel1'
# Make sure the compiler we just downloaded works - just print out the version
- name: Test arm-none-eabi-gcc Compiler
run: arm-none-eabi-gcc -v
- name: Configs build_server upload SSH variables
if: ${{ env.upload == 'server' }}
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
run: |
echo "RUSEFI_SSH_SERVER=${{secrets.RUSEFI_SSH_SERVER}}" >> $GITHUB_ENV
echo "RUSEFI_SSH_USER=${{secrets.RUSEFI_SSH_USER}}" >> $GITHUB_ENV
echo "RUSEFI_SSH_PASS=${{secrets.RUSEFI_SSH_PASS}}" >> $GITHUB_ENV
# - name: Download LibOpenBLT Tool (Linux)
# uses: actions/download-artifact@v3
# with:
# name: libopenblt-linux
# path: ./firmware/ext/openblt/Host/
# - name: Download LibOpenBLT Tool (MacOS)
# uses: actions/download-artifact@v3
# with:
# name: libopenblt-macos
# path: ./firmware/ext/openblt/Host/
- name: Clean (Just in Case)
working-directory: ./firmware/
run: |
make clean
- name: Handle configs separately just to make github logs more readable
working-directory: ./firmware/
run: |
bash bin/compile.sh ${{env.BOARD_META_PATH}} docs-enums
bash bin/compile.sh ${{env.BOARD_META_PATH}} config
- name: Building Windows simulator separately just to make github logs more readable
working-directory: ./firmware/
run: |
bash bin/compile.sh ${{env.BOARD_META_PATH}} ../simulator/build/rusefi_simulator.exe
# Build the firmware! We have the technology to build _everything_ in one 'make' invocation but choose to do separately for sake of more readable GHA logs
- name: Build Firmware
working-directory: ./firmware/
run: |
bash bin/compile.sh ${{env.BOARD_META_PATH}} bundles --output-sync=recurse
- name: Check for illegal time conversions
working-directory: ./firmware/
run: bash check_illegal_conversion.sh
- name: Upload Bundle
if: ${{ env.full == 'true' }}
working-directory: ./artifacts
run: |
source ../firmware/config/boards/common_script_read_meta_env.inc ../firmware/${{ env.BOARD_META_PATH }}
bash ../firmware/bin/upload_bundle.sh ${{ secrets.RUSEFI_SSH_USER }} "${{ secrets.RUSEFI_SSH_PASS }}" ${{ secrets.RUSEFI_SSH_SERVER }} ${BUNDLE_NAME}
- name: Add Bundles to Release
if: ${{ env.upload == 'release' }}
uses: ncipollo/[email protected]
with:
tag: ${{ env.date }}
name: "Nightly ${{ env.date }}"
artifacts: "artifacts/rusefi_bundle_*.zip"
replacesArtifacts: false
token: ${{ secrets.NIGHTLY_RELEASE_ACCESS_TOKEN }}
allowUpdates: true
prerelease: true
- name: Upload .ini files to rusEFI Online server
if: ${{ env.full == 'true' }}
working-directory: ./firmware
run: |
source config/boards/common_script_read_meta_env.inc ${{ env.BOARD_META_PATH }}
cd ${META_OUTPUT_ROOT_FOLDER}tunerstudio/generated
${OLDPWD}/tunerstudio/upload_ini.sh ${{ secrets.RUSEFI_ONLINE_FTP_USER }} "${{ secrets.RUSEFI_ONLINE_FTP_PASS }}" ${{ secrets.RUSEFI_FTP_SERVER }}
- name: Upload github action elf artifact
if: ${{ env.upload == 'gha_artifact' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.elf
path: ./firmware/build/rusefi.elf
- name: Upload github action map artifact
if: ${{ env.upload == 'gha_artifact' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.map
path: ./firmware/build/rusefi.map
- name: Upload github action bin artifact
if: ${{ env.upload == 'gha_artifact' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.bin
path: ./firmware/deliver/rusefi*.bin
- name: Upload github action hex artifact
if: ${{ env.upload == 'gha_artifact' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.hex
# we have a bit of a mess - this file from 'build' folder is only legit for not-BLT builds
# todo: we should produce .hex in both OpenBLT and non-OpenBLT case same as we do for .bin and .elf
path: ./firmware/build/rusefi*.hex
- name: Upload github action dfu artifact
if: ${{ env.upload == 'gha_artifact' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.dfu
path: ./firmware/deliver/rusefi*.dfu
- name: Upload bundle artifact
uses: actions/upload-artifact@v4
with:
name: rusefi_bundle_${{matrix.build-target}}.zip
path: ./artifacts/rusefi_bundle_${{matrix.build-target}}.zip
- name: Upload github action autoupdate artifact
uses: actions/upload-artifact@v4
with:
name: rusefi_bundle_${{matrix.build-target}}_autoupdate.zip
path: ./artifacts/rusefi_bundle_${{matrix.build-target}}_autoupdate.zip