forked from PX4/PX4-Autopilot
-
Notifications
You must be signed in to change notification settings - Fork 13
357 lines (324 loc) · 12.2 KB
/
tiiuae-pixhawk-and-saluki.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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
name: tiiuae-pixhawk-and-saluki
on:
push:
branches: [ main ]
tags:
- 'v1.14.0-*'
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
jfrog-upload:
description: 'upload to Artifactory'
required: false
default: true
type: boolean
permissions:
contents: read
packages: write
env:
saluki_pi_fpga_version: "sha-4230961"
saluki_v2_fpga_version: "sha-4230961"
saluki_v3_fpga_version: "sha-4230961"
jobs:
fc_matrix:
strategy:
fail-fast: false
matrix:
product: [pixhawk, saluki-v2_default, saluki-v2_amp, saluki-v2_protected, saluki-v2_kernel, saluki-pi_default, saluki-pi_amp, saluki-pi_protected, saluki-v3_default, saluki-v3_amp]
include:
- product: saluki-v2_custom_keys
keys: Tools/saluki-sec-scripts/custom_keys/saluki-v2/px4_bin_ed25519_private.pem
- product: saluki-v3_custom_keys
keys: Tools/saluki-sec-scripts/custom_keys/saluki-v3/px4_bin_ed25519_private.pem
- product: saluki-pi_custom_keys
keys: Tools/saluki-sec-scripts/custom_keys/saluki-pi/px4_bin_ed25519_private.pem
uses: ./.github/workflows/tiiuae-pixhawk-and-saluki-builder.yaml
with:
product: ${{ matrix.product }}
keys: ${{ matrix.keys }}
# old workflow had condition to run only if PR is done to current repo (or triggered with other event)
enabled: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
secrets: inherit
px4fwupdater:
name: build px4fwupdater
runs-on: ubuntu-latest
needs:
- fc_matrix
steps:
- name: Checkout px4-firmware
uses: actions/checkout@v3
with:
path: px4-firmware
fetch-depth: 0
- name: Download pixhawk artifacts
uses: actions/download-artifact@v3
with:
name: pixhawk
path: bin
- name: Run px4-firmware px4fwupdater build
run: |
set -eux
mkdir -p bin
cd px4-firmware/
./clone_public.sh
./build.sh ../bin/ px4fwupdater
ls ../bin
- name: Upload px4fwupdater to tmp storage
uses: actions/[email protected]
with:
name: pixhawk
path: bin/
retention-days: 1
upload-px4fwupdater:
name: upload px4fwupdater to docker registry
runs-on: ubuntu-latest
needs:
- px4fwupdater
steps:
- name: Checkout px4-firmware
uses: actions/checkout@v3
with:
path: px4-firmware
fetch-depth: 0
- name: Download pixhawk artifacts
uses: actions/download-artifact@v3
with:
name: pixhawk
path: bin
- name: Firmware flasher - Container metadata
id: containermeta # referenced from later step
uses: docker/metadata-action@v4
with:
images: ghcr.io/tiiuae/px4-firmware
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Firmware flasher - Build and push
uses: docker/build-push-action@v3
with:
push: true
context: .
file: px4-firmware/Tools/px_uploader.Dockerfile
tags: ${{ steps.containermeta.outputs.tags }}
labels: ${{ steps.containermeta.outputs.labels }}
build-args: |
"saluki_pi_fpga_version=${{ env.saluki_pi_fpga_version }}"
"saluki_v2_fpga_version=${{ env.saluki_v2_fpga_version }}"
"saluki_v3_fpga_version=${{ env.saluki_v3_fpga_version }}"
upload-px4fwupdater-uae:
name: upload px4fwupdater to UAE docker registry
runs-on: ubuntu-latest
needs:
- px4fwupdater
steps:
- name: Checkout px4-firmware
uses: actions/checkout@v3
with:
path: px4-firmware
fetch-depth: 0
- name: Download pixhawk artifacts
uses: actions/download-artifact@v3
with:
name: pixhawk
path: bin
- name: Firmware flasher - Container metadata
id: containermeta # referenced from later step
uses: docker/metadata-action@v4
with:
images: artifactory.ssrcdevops.tii.ae/tiiuae/px4-firmware
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: Login to SSRC JFrog Container Registry
uses: docker/login-action@v3
with:
registry: artifactory.ssrcdevops.tii.ae
username: ${{ secrets.UAE_RT_USER }}
password: ${{ secrets.UAE_RT_APIKEY }}
# have to login to ghcr as well to download fpga and BL
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Firmware flasher - Build and push
uses: docker/build-push-action@v3
with:
push: true
context: .
file: px4-firmware/Tools/px_uploader.Dockerfile
tags: ${{ steps.containermeta.outputs.tags }}
labels: ${{ steps.containermeta.outputs.labels }}
build-args: |
"saluki_pi_fpga_version=${{ env.saluki_pi_fpga_version }}"
"saluki_v2_fpga_version=${{ env.saluki_v2_fpga_version }}"
"saluki_v3_fpga_version=${{ env.saluki_v3_fpga_version }}"
artifactory:
name: upload builds to artifactory
if: ${{ github.event_name != 'workflow_dispatch' || inputs.jfrog-upload == true }}
runs-on: ubuntu-latest
needs:
- px4fwupdater
- fc_matrix
steps:
- name: Download pixhawk artifacts
uses: actions/download-artifact@v3
with:
name: pixhawk
path: bin
- uses: jfrog/setup-jfrog-cli@v3
env:
JF_ENV_1: ${{ secrets.ARTIFACTORY_CLOUD_TOKEN }}
- name: Upload px4-firmware build to Artifactory
env:
ARTIFACTORY_GEN_REPO: ssrc-gen-private-local
BUILD_NAME_PX4: px4-firmware
CI: true
run: |
set -exu
pr_or_empty=""
latest_link=""
if [ ${{ github.event_name }} == 'pull_request' ]; then
latest_link="pr/"
pr_or_empty="pr/${{ github.head_ref || github.ref_name }}/"
fi
newline=$'\n'
artifactory_links="| target | link |
|--------|------|"
artifactory_base_url="https://ssrc.jfrog.io/artifactory/"
for pkg in $(find bin -type f|sort); do
file_name=$(basename $pkg)
ext="${file_name##*.}"
target_path=""
pkg_name=$(echo $file_name | sed -r -e 's/-[0-9]+\.[0-9]+\.[0-9]+-.*//g')
if [[ $file_name = px4_fmu* ]]; then
target_path="pixhawk"
elif [[ $file_name = ssrc_saluki* ]]; then
target_path="saluki"
else
echo "$pkg ignored"
continue
fi
artifactory_path=$ARTIFACTORY_GEN_REPO/builds/px4-firmware/${target_path}/${pr_or_empty}
artifactory_latest_path=$ARTIFACTORY_GEN_REPO/builds/px4-firmware/${target_path}/${latest_link}latest/${pkg_name}.${ext}
jfrog rt u --target-props COMMIT="$GITHUB_SHA" \
--build-name "$BUILD_NAME_PX4" \
--build-number "$GITHUB_SHA" \
"$pkg" \
"${artifactory_path}$file_name"
# link to latest
jfrog rt cp --flat \
"${artifactory_path}$file_name" \
"${artifactory_latest_path}"
# append every file to artifactory_links
artifactory_links+="${newline}| ${pkg_name} | ${artifactory_base_url}${artifactory_path}${file_name} |"
done
jfrog rt build-publish "$BUILD_NAME_PX4" "$GITHUB_SHA"
jfrog rt bpr "$BUILD_NAME_PX4" "$GITHUB_SHA" "$ARTIFACTORY_GEN_REPO" \
--status dev \
--comment "development build"
# save upload path to output for later use
echo "### Cloud Artifactory links:" >> $GITHUB_STEP_SUMMARY
echo "${artifactory_links}" >> $GITHUB_STEP_SUMMARY
artifactory-uae:
name: upload builds to UAE artifactory
if: ${{ github.event_name != 'workflow_dispatch' || inputs.jfrog-upload == true }}
runs-on: ubuntu-latest
needs:
- px4fwupdater
- fc_matrix
steps:
- name: Download pixhawk artifacts
uses: actions/download-artifact@v3
with:
name: pixhawk
path: bin
- uses: jfrog/setup-jfrog-cli@v3
env:
JF_ENV_1: ${{ secrets.UAE_ARTIFACTORY_TOKEN }}
- name: Upload px4-firmware build to Artifactory
env:
ARTIFACTORY_GEN_REPO: gen-public-local
BUILD_NAME_PX4: px4-firmware
CI: true
run: |
set -exu
pr_or_empty=""
latest_link=""
if [ ${{ github.event_name }} == 'pull_request' ]; then
latest_link="pr/"
pr_or_empty="pr/${{ github.head_ref || github.ref_name }}/"
fi
newline=$'\n'
artifactory_links="| target | link |
|--------|------|"
artifactory_base_url="https://artifactory.ssrcdevops.tii.ae/artifactory/"
for pkg in $(find bin -type f|sort); do
file_name=$(basename $pkg)
ext="${file_name##*.}"
target_path=""
pkg_name=$(echo $file_name | sed -r -e 's/-[0-9]+\.[0-9]+\.[0-9]+-.*//g')
if [[ $file_name = px4_fmu* ]]; then
target_path="pixhawk"
elif [[ $file_name = ssrc_saluki* ]]; then
target_path="saluki"
else
echo "$pkg ignored"
continue
fi
artifactory_path=$ARTIFACTORY_GEN_REPO/builds/px4-firmware/${target_path}/${pr_or_empty}
artifactory_latest_path=$ARTIFACTORY_GEN_REPO/builds/px4-firmware/${target_path}/${latest_link}latest/${pkg_name}.${ext}
jfrog rt u --target-props COMMIT="$GITHUB_SHA" \
--build-name "$BUILD_NAME_PX4" \
--build-number "$GITHUB_SHA" \
"$pkg" \
"${artifactory_path}$file_name"
# link to latest
jfrog rt cp --flat \
"${artifactory_path}$file_name" \
"${artifactory_latest_path}"
# append every file to artifactory_links
artifactory_links+="${newline}| ${pkg_name} | ${artifactory_base_url}${artifactory_path}${file_name} |"
done
jfrog rt build-publish "$BUILD_NAME_PX4" "$GITHUB_SHA"
jfrog rt bpr "$BUILD_NAME_PX4" "$GITHUB_SHA" "$ARTIFACTORY_GEN_REPO" \
--status dev \
--comment "development build"
# export artifactory linds as gh step summary
echo "### UAE Artifactory links:" >> $GITHUB_STEP_SUMMARY
echo "${artifactory_links}" >> $GITHUB_STEP_SUMMARY
- name: Upload px4-fwupdater build to Artifactory
env:
ARTIFACTORY_DEB_REPO: debian-public-local
DISTRIBUTION: focal
COMPONENT: fog-sw
ARCHITECTURE: amd64
BUILD_NAME_DEB: px4-fwupdater
CI: true
run: |
set -exu
pkg=$(find bin -name 'px4fwupdater*.deb')
pkg_name=$(basename $pkg)
jfrog rt u --deb "$DISTRIBUTION/$COMPONENT/$ARCHITECTURE" \
--target-props COMMIT="$GITHUB_SHA" \
--build-name "$BUILD_NAME_DEB" \
--build-number "$GITHUB_SHA" \
"$pkg" \
"$ARTIFACTORY_DEB_REPO/$pkg_name"
jfrog rt build-publish "$BUILD_NAME_DEB" "$GITHUB_SHA"
jfrog rt bpr "$BUILD_NAME_DEB" "$GITHUB_SHA" "$ARTIFACTORY_DEB_REPO" \
--status dev \
--comment "development build"