-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathupdate_workflows.sh
More file actions
executable file
·119 lines (104 loc) · 4.23 KB
/
update_workflows.sh
File metadata and controls
executable file
·119 lines (104 loc) · 4.23 KB
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
#!/bin/bash
# SPDX-FileCopyrightText: Timothée Ravier <tim@siosm.fr>
# SPDX-License-Identifier: MIT
# Re-generate the GitHub workflows based on templates. We do not use a matrix
# build strategy in GitHub worflows to reduce overall build time and avoid
# pulling the same base container image multiple time, once for each individual
# job.
set -euo pipefail
# set -x
main() {
if [[ ! -d .github ]] || [[ ! -d .git ]]; then
echo "This script must be run at the root of the repo"
exit 1
fi
local -r tmpl=".github/workflow-templates"
if [[ ! -d "${tmpl}" ]]; then
echo "Could not find the templates. Is this script run from the root of the repo?"
exit 1
fi
# Remove all existing worflows
rm -f "./.github/workflows/containers"*".yml"
rm -f "./.github/workflows/sysexts"*".yml"
local -r releaseurl="https://github.com/\${{ github.repository }}/releases/download"
arches=(
'x86_64'
'aarch64'
)
images=(
'quay.io/fedora-ostree-desktops/base-atomic:43'
'quay.io/fedora-ostree-desktops/base-atomic:44'
'quay.io/fedora-ostree-desktops/silverblue:43'
'quay.io/fedora-ostree-desktops/silverblue:44'
'quay.io/fedora-ostree-desktops/kinoite:43'
'quay.io/fedora-ostree-desktops/kinoite:44'
'quay.io/fedora/fedora-coreos:stable'
'quay.io/fedora/fedora-coreos:next'
)
# Set jobnames
declare -A jobnames
jobnames["quay.io/fedora-ostree-desktops/base-atomic:43"]="fedora-43"
jobnames["quay.io/fedora-ostree-desktops/base-atomic:44"]="fedora-44"
jobnames["quay.io/fedora-ostree-desktops/silverblue:43"]="fedora-silverblue-43"
jobnames["quay.io/fedora-ostree-desktops/silverblue:44"]="fedora-silverblue-44"
jobnames["quay.io/fedora-ostree-desktops/kinoite:43"]="fedora-kinoite-43"
jobnames["quay.io/fedora-ostree-desktops/kinoite:44"]="fedora-kinoite-44"
jobnames["quay.io/fedora/fedora-coreos:stable"]="fedora-coreos-stable"
jobnames["quay.io/fedora/fedora-coreos:next"]="fedora-coreos-next"
# Get the list of sysexts for each image and each arch
declare -A sysexts
for arch in "${arches[@]}"; do
for image in "${images[@]}"; do
list=()
for s in $(git ls-tree -d --name-only HEAD | grep -Ev ".github|docs|LICENSES"); do
pushd "${s}" > /dev/null
# Only require the architecture to be explicitly listed for non x86_64 for now
if [[ "${arch}" == "x86_64" ]]; then
if [[ $(just targets | grep -c "${image}") == "1" ]]; then
list+=("${s}")
fi
else
if [[ $(just targets | grep -cE "${image} .*${arch}.*") == "1" ]]; then
list+=("${s}")
fi
fi
popd > /dev/null
done
sysexts["${image}-${arch}"]="$(echo "${list[@]}" | tr ' ' ';')"
done
done
# Generate EROFS sysexts workflows
{
sed -e "s|%%RELEASEURL%%|${releaseurl}|g" \
"${tmpl}/00_sysexts_header"
for arch in "${arches[@]}"; do
runson="ubuntu-24.04"
if [[ "${arch}" == "aarch64" ]]; then
runson="ubuntu-24.04-arm"
fi
for image in "${images[@]}"; do
sed -e "s|%%JOBNAME%%|${jobnames["${image}"]}-${arch}|g" \
-e "s|%%RUNSON%%|${runson}|g" \
-e "s|%%IMAGE%%|${image}|g" \
"${tmpl}/10_sysexts_build_header"
echo ""
for s in $(echo "${sysexts["${image}-${arch}"]}" | tr ';' ' '); do
sed "s|%%SYSEXT%%|${s}|g" "${tmpl}/15_sysexts_build"
echo ""
done
done
done
# TODO: Dynamic list of jobs to depend on
all_sysexts=()
for arch in "${arches[@]}"; do
for image in "${images[@]}"; do
for s in $(echo "${sysexts["${image}-${arch}"]}" | tr ';' ' '); do
all_sysexts+=("${s}")
done
done
done
uniq_sysexts="$(echo "${all_sysexts[@]}" | tr ' ' '\n' | sort -u | tr '\n' ';')"
sed -e "s|%%SYSEXTS%%|${uniq_sysexts}|g" "${tmpl}/20_sysexts_gather"
} > ".github/workflows/sysexts-fedora.yml"
}
main "${@}"