-
-
Notifications
You must be signed in to change notification settings - Fork 64
476 lines (405 loc) · 21.3 KB
/
recreate-matrix.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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
#
# This action recreate action for building stable images
#
name: Recreate Matrix (push)
on:
schedule:
- cron: '00 5 * * *'
push:
branches:
- 'main'
paths:
- "userpatches/*.template"
- "userpatches/*.map"
- "userpatches/*.blacklist"
- "userpatches/gha/**"
- "userpatches/gha/chunks/**"
- ".github/workflows/recreate-matrix.yml"
workflow_dispatch:
repository_dispatch:
types: [Recreate Matrix]
concurrency:
group: matrix-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Recreate action
if: ${{ github.repository_owner == 'Armbian' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Armbian Framework
uses: actions/checkout@v4
with:
persist-credentials: false
repository: armbian/build
ref: main
fetch-depth: 0
clean: false
path: build
- name: Checkout Armbian OS Config
uses: actions/checkout@v4
with:
persist-credentials: false
repository: armbian/os
ref: main
clean: false
fetch-depth: 0
path: os
- name: "Rsync userpatches"
run: |
rsync -av os/userpatches/. build/userpatches/
rm -f build/userpatches/targets.yaml
- name: "Generate builds lists"
run: |
cat <<- EOF > os/.github/workflows/complete-artifact-one-by-one.yml
name: "Build One by One (anyone)"
on:
workflow_dispatch:
inputs:
armbian_target:
type: choice
description: 'Build'
required: false
options:
- kernel
- build
default: build
armbian_kernel_branch:
type: choice
description: 'Kernel branch'
options:
- legacy
- current
- edge
default: 'current'
armbian_release:
type: choice
description: 'Userspace'
options:
- jammy
- mantic
- bookworm
- trixie
- sid
default: 'jammy'
armbian_ui:
type: choice
description: 'User interface (not all works)'
options:
- minimal
- server
- xfce
- gnome
- cinnamon
- i3-wm
- kde-plasma
default: 'minimal'
armbian_version:
description: 'Version'
required: false
default: ''
armbian_board:
type: choice
description: 'Board'
options:
EOF
# generate lists to include them
ls -1 build/config/boards/*.{conf,wip,csc} | cut -d"/" -f4 | cut -d"." -f1 | uniq | sed 's/.*/ - &/' >> os/.github/workflows/complete-artifact-one-by-one.yml
cat <<- EOF >> os/.github/workflows/complete-artifact-one-by-one.yml
jobs:
build:
name: "Build Armbian"
runs-on: ubuntu-latest
steps:
- uses: armbian/[email protected]
with:
armbian_token: "${{ '\${{secrets.GITHUB_TOKEN}}' }}"
armbian_target: "${{ '\${{inputs.armbian_target}}' }}"
armbian_release: "${{ '\${{inputs.armbian_release}}' }}"
armbian_kernel_branch: "${{ '\${{inputs.armbian_kernel_branch}}' }}"
armbian_ui: "${{ '\${{inputs.armbian_ui}}' }}"
armbian_board: "${{ '\${{inputs.armbian_board}}' }}"
armbian_release_tittle: "Armbian SDK"
armbian_release_body: "Virtual images for x86 and arm64"
armbian_pgp_key: "${{ '\${{secrets.GPG_KEY1}}' }}"
armbian_pgp_password: "${{ '\${{secrets.GPG_PASSPHRASE1}}' }}"
EOF
- name: "Generate builds lists"
run: |
# generate lists to include them
find build/config/boards/*.{conf,wip,tvb,csc} ! '(' -name '*.eos' ')' | cut -d"/" -f4 | cut -d"." -f1 | uniq | sort | sed 's/.*/ - &/' > /tmp/standard-support.txt
cp /tmp/standard-support.txt /tmp/staging.txt
cp /tmp/standard-support.txt /tmp/community-maintained.txt
#ls -1 build/config/boards/*.{conf,wip} | cut -d"/" -f4 | cut -d"." -f1 | uniq | sed 's/.*/ - &/' > /tmp/staging.txt
#ls -1 build/config/boards/*.{tvb,csc} | cut -d"/" -f4 | cut -d"." -f1 | uniq | sed 's/.*/ - &/' > /tmp/community-maintained.txt
grep BOARD_MAINTAINER build/config/boards/*.{conf,eos,wip,csc} | cut -d":" -f2 | cut -d"=" -f2 | sed 's/"/ /g' | tr -d '\n' | tr -s ' ' | xargs -n1 | sort | uniq | sed 's/.*/ - &/' > /tmp/maintainers.txt
git ls-remote --heads https://github.com/armbian/build | grep "v2" | cut -d"/" -f3 | sort | tail -1 | sed '1s/^/main\n/' | sed 's/.*/ - &/' > /tmp/branches.txt
function enable_extension()
{
:
}
function display_alert()
{
:
}
function make-targets()
{
# cycle all board configs but .eos (end of support, which we swithc to when it breaks)
# We are replacing in target yaml. copy from template
cp $2.template $2.yaml
for SECTION in $1; do
# debug
echo "Adding: $SECTION to $2" >> $GITHUB_STEP_SUMMARY
OUTPUT=$(for board in $(ls -1 build/config/boards/*.{conf,csc,wip,tvb}); do
# read board family and determine ARCH
unset KERNEL_TEST_TARGET
SRC=$(pwd)/build
source $board
source build/config/sources/families/${BOARDFAMILY}.conf 2>/dev/null || true
# board status defines where it goes
if [[ $board == *.conf* ]]; then SUPPORT="standard-support";
elif [[ $board == *.wip* ]]; then SUPPORT="staging";
else SUPPORT="community-maintained"; fi
# ... and board ARCH defines where it goes
TARGET_SECTION="${SUPPORT}-slow-hdmi"
if [[ $ARCH == riscv64 ]]; then TARGET_SECTION="${SUPPORT}-riscv64";
elif grep -q 'HAS_VIDEO_OUTPUT="no"' $board; then TARGET_SECTION="${SUPPORT}-headless";
elif [[ $ARCH == arm64 || $ARCH == amd64 ]]; then TARGET_SECTION="${SUPPORT}-fast-hdmi"
fi
# exception. Lets not deal with this special target anymore, but leave it in configs
KERNEL_TARGET=${KERNEL_TARGET/,collabora/}
# if kernel test target is defined, override with it
[[ -n $KERNEL_TEST_TARGET ]] && KERNEL_TARGET=${KERNEL_TEST_TARGET}
# read kernel target
if [[ $(echo $KERNEL_TARGET | cut -d '"' -f 2 | sed "s/,/ /g" | wc -w) -gt 2 ]]; then
KERNEL_TARGET=$(echo $KERNEL_TARGET | cut -d '"' -f 2 | awk -F, '{ print $2,$3 }')
else
KERNEL_TARGET=$(echo $KERNEL_TARGET | cut -d '"' -f 2 | sed "s/,/ /g")
fi
# extract board name from config
board=$(echo $board | cut -d"/" -f4 | cut -d"." -f1)
# skip boards listed in this file
if grep -qw "^${board}" os/userpatches/targets-automation.blacklist; then continue; fi
if [[ $2 == *nightly* ]] && grep -qw "^${board}" os/userpatches/targets-automation-nightly.blacklist; then continue; fi
# our default is current build target. Use it or search further
if [[ $TARGET_SECTION == $SECTION ]]; then
VARIANTS=0
for targets in ${KERNEL_TARGET}; do
if [[ "${targets}" == current && $VARIANTS -lt $3 ]]; then
# check if we have extension mapping defined
EXTENSION=$(grep -P '^(?=.*'$board',)(?=.*current:)' os/userpatches/targets-extensions.map | cut -d"=" -f2)
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi
echo " - { BOARD: $board, BRANCH: current${EXTENSION} }"
VARIANTS=$((VARIANTS+1))
fi
if [[ "${targets}" == edge && $VARIANTS -lt $3 ]]; then
# check if we have extension mapping defined
EXTENSION=$(grep -P '^(?=.*'$board',)(?=.*edge:)' os/userpatches/targets-extensions.map | cut -d"=" -f2)
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi
echo " - { BOARD: $board, BRANCH: edge${EXTENSION} }"
VARIANTS=$((VARIANTS+1))
fi
if [[ "${targets}" == legacy && $VARIANTS -lt $3 ]]; then
# check if we have extension mapping defined
EXTENSION=$(grep -P '^(?=.*'$board',)(?=.*legacy:)' os/userpatches/targets-extensions.map | cut -d"=" -f2)
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi
echo " - { BOARD: $board, BRANCH: legacy${EXTENSION} }"
VARIANTS=$((VARIANTS+1))
fi
if [[ "${targets}" == vendor && $VARIANTS -lt $3 ]]; then
# check if we have extension mapping defined
EXTENSION=$(grep -P '^(?=.*'$board',)(?=.*vendor:)' os/userpatches/targets-extensions.map | cut -d"=" -f2)
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi
echo " - { BOARD: $board, BRANCH: vendor${EXTENSION} }"
VARIANTS=$((VARIANTS+1))
fi
if [[ ! "$targets" =~ ^(legacy|vendor|current|edge)$ && $targets != collabora ]]; then
# otherwise it must be custom kernel target
EXTENSION=$(grep -P '^(?=.*'${board}',)(?=.*'${targets}':)' os/userpatches/targets-extensions.map | cut -d"=" -f2)
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi
echo " - { BOARD: $board, BRANCH: ${targets}${EXTENSION}}"
fi
done
fi
done)
if [[ -n $OUTPUT ]]; then
TEMPFILE=$(mktemp)
(
echo " $SECTION: &$SECTION"
echo " # auto generated section"
while IFS= read -r line
do
echo "$line"
done <<< $OUTPUT
# mark end of the section
echo -e " # end of auto generated section\n"
) > $TEMPFILE
# since its not empty, add to the yaml file
sed -i "/ # automated lists start/r $TEMPFILE" ${2}.yaml
# add also to section
sed -i -e '/ automated-section/,/items/{/items/a \ \ \ \ \ \ - *'$SECTION'' -e '}' ${2}.yaml
else
# remove tags from manually made sections or it will exit with error
sed -i '/'$SECTION'/d' ${2}.yaml
echo "Removing $SECTION from $2"
fi
done
}
# define which sections goes into which list
BUILD_SECTIONS_STANDARD_SUPPORT="
standard-support-slow-hdmi
standard-support-fast-hdmi
standard-support-headless
standard-support-riscv64
"
BUILD_SECTIONS_COMMUNITY_MAINTAINED="
community-maintained-slow-hdmi
community-maintained-fast-hdmi
community-maintained-headless
community-maintained-riscv64
"
BUILD_SECTIONS_NIGHTLY="
standard-support-slow-hdmi
staging-slow-hdmi
standard-support-fast-hdmi
staging-fast-hdmi
standard-support-headless
staging-headless
standard-support-riscv64
staging-riscv64
"
# $1 = parts to add
# $2 = filename that copy from .template to .yaml
# $3 = how many to build 1 or 2 (current,edge,legacy; current,legacy)
make-targets "${BUILD_SECTIONS_STANDARD_SUPPORT}" "os/userpatches/targets-release-standard-support" "2"
make-targets "${BUILD_SECTIONS_STANDARD_SUPPORT}" "os/userpatches/targets-release-apps" "1"
make-targets "${BUILD_SECTIONS_COMMUNITY_MAINTAINED}" "os/userpatches/targets-release-community-maintained" "1"
make-targets "${BUILD_SECTIONS_NIGHTLY}" "os/userpatches/targets-release-nightly" "1"
- name: "Generate Action Script"
run: |
cd build
# Last stable branch
#LAST=$(git branch -r | grep "v2" | tail -1 | cut -d"/" -f2)
# generate targets-release-community-maintained.yaml
#cp userpatches/targets-release-community-maintained.template userpatches/targets-release-community-maintained.yaml
#sed -i '/ # unsupported/r /tmp/unsupported.txt' userpatches/targets-release-community-maintained.yaml
#sed -i '/ # unsupported-headless/r /tmp/unsupported-headless.txt' userpatches/targets-release-community-maintained.yaml
#git add userpatches/targets-release-community-maintained.yaml
#git add userpatches/targets-release-community-maintained.yaml
#git add -f userpatches/targets-release-community-maintained.yaml
#
# copy nightly templates
#
cp userpatches/gha/gha_config_nightly.yaml userpatches/gha/gha_config.yaml
cp userpatches/targets-release-nightly.yaml userpatches/targets.yaml
bash ./compile.sh gha-template
# add boards, maintainers and branches
sed -i '/# boards/r /tmp/staging.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml
# we need unique concurency id
sed -i "s/pipeline-/pipeline-nightly/" output/info/artifact-image-complete-matrix.yml
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-nightly.yml
#
# copy old stable templates
#
#cp userpatches/gha/gha_config_old_stable.yaml userpatches/gha/gha_config.yaml
#cp userpatches/targets-release.yaml userpatches/targets.yaml
#sed -i 's/build_ref: .*/build_ref: "'$LAST'"/' userpatches/gha/gha_config.yaml
#bash ./compile.sh gha-template
# add boards and maintainers
#sed -i '/# boards/r /tmp/boards.txt' output/info/artifact-image-complete-matrix.yml
#sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml
# we need unique concurency id
#sed -i "s/pipeline-/pipeline-old-stable/" output/info/artifact-image-complete-matrix.yml
#cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-old-stable.yml
#
# copy standard support release templates
#
cp userpatches/gha/gha_config_release_standard_support.yaml userpatches/gha/gha_config.yaml
cp userpatches/targets-release-standard-support.yaml userpatches/targets.yaml
bash ./compile.sh gha-template
# add boards and maintainers
sed -i '/# boards/r /tmp/standard-support.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml
# we need unique concurency id
sed -i "s/pipeline-/standard-support/" output/info/artifact-image-complete-matrix.yml
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-standard-support.yml
#
# copy apps release templates
#
cp userpatches/gha/gha_config_release_apps.yaml userpatches/gha/gha_config.yaml
cp userpatches/targets-release-apps.yaml userpatches/targets.yaml
bash ./compile.sh gha-template
# add boards and maintainers
sed -i '/# boards/r /tmp/standard-support.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml
# we need unique concurency id
sed -i "s/pipeline-/apps/" output/info/artifact-image-complete-matrix.yml
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-apps.yml
#
# copy unsupported release templates
#
cp userpatches/gha/gha_config_release_community_maintained.yaml userpatches/gha/gha_config.yaml
cp userpatches/targets-release-community-maintained.yaml userpatches/targets.yaml
bash ./compile.sh gha-template
# add boards and maintainers
sed -i '/# boards/r /tmp/community-maintained.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml
# we need unique concurency id
sed -i "s/pipeline-/unsupported/" output/info/artifact-image-complete-matrix.yml
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-community-maintained.yml
#
# copy all templates
#
cp userpatches/gha/gha_config_all.yaml userpatches/gha/gha_config.yaml
cp userpatches/targets-all-not-eos.yaml userpatches/targets.yaml
bash ./compile.sh gha-template
# add boards and maintainers
sed -i '/# boards/r /tmp/boards.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml
# we need unique concurency id
sed -i "s/pipeline-/pipeline-all/" output/info/artifact-image-complete-matrix.yml
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-all.yml
#
# copy all stable templates
#
cp userpatches/gha/gha_config_all_stable.yaml userpatches/gha/gha_config.yaml
cp userpatches/targets-all-not-eos.yaml userpatches/targets.yaml
bash ./compile.sh gha-template
# add boards and maintainers
sed -i '/# boards/r /tmp/boards.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml
# we need unique concurency id
sed -i "s/pipeline-/pipeline-all/" output/info/artifact-image-complete-matrix.yml
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-all-stable.yml
cd ../os
git config --local user.email "[email protected]"
git config --local user.name "Armbianworker"
# Update build list
git add userpatches/targets-release-standard-support.yaml
git add userpatches/targets-release-community-maintained.yaml
git add userpatches/targets-release-apps.yaml
git add userpatches/targets-release-nightly.yaml
# Add Action Scritps
git add .github/workflows/complete-artifact-matrix-nightly.yml
#git add .github/workflows/complete-artifact-matrix-old-stable.yml
git add .github/workflows/complete-artifact-matrix-standard-support.yml
git add .github/workflows/complete-artifact-matrix-community-maintained.yml
git add .github/workflows/complete-artifact-matrix-apps.yml
git add .github/workflows/complete-artifact-matrix-all.yml
git add .github/workflows/complete-artifact-matrix-all-stable.yml
git add .github/workflows/complete-artifact-one-by-one.yml
git commit --allow-empty -m "Update generated GHA chunk workflow artifact-image-complete-matrix.yml" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.ACCESS_TOKEN_ARMBIANWORKER }}
repository: armbian/os
branch: ${{ github.ref }}
directory: os