-
Notifications
You must be signed in to change notification settings - Fork 36
/
release_build.sh
executable file
·140 lines (119 loc) · 4.18 KB
/
release_build.sh
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
#!/bin/bash
#
# Build a bakery release of all sysexts.
#
# The release will include all sysexts from the "latest" release
# (these will be downloaded). Sysexts listed in release_build_versions.txt
# and _not_ included in the "latest" release will be built.
set -euo pipefail
: ${REPO:=flatcar/sysext-bakery}
echo
echo "Fetching list of latest Kubernetes minor releases"
echo "================================================="
KBS_VERS=$(curl -fsSL --retry-delay 1 --retry 60 --retry-connrefused \
--retry-max-time 60 --connect-timeout 20 \
https://raw.githubusercontent.com/kubernetes/website/main/data/releases/schedule.yaml \
| yq -r '.schedules[] | .previousPatches[0] // (.release = .release + ".0") | .release')
if [[ -z "${KBS_VERS}" ]] ; then
echo "Failed fetching Kubernetes versions"
exit 1
fi
KBS_VERS_ARRAY=(${KBS_VERS})
printf "%s\n" "${KBS_VERS_ARRAY[@]}"
echo "Fetching list of latest CRI-O patch releases"
echo "================================================="
git ls-remote --tags --sort=-v:refname https://github.com/cri-o/cri-o \
| grep -v "{}" \
| awk '{ print $2}' \
| cut --delimiter='/' --fields=3 \
> crio.txt
CRIO=()
for r in "${KBS_VERS_ARRAY[@]}"; do
if ! grep -q "v${r%.*}" crio.txt; then
echo "Skipping $r"
continue
fi
version=$(cat crio.txt | grep "v${r%.*}" | head -n1)
CRIO+=( "crio-${version:1}" )
done
echo
echo "Fetching previous 'latest' release sysexts"
echo "=========================================="
curl -fsSL --retry-delay 1 --retry 60 --retry-connrefused \
--retry-max-time 60 --connect-timeout 20 \
https://api.github.com/repos/"${REPO}"/releases/latest \
| jq -r '.assets[] | "\(.name)\t\(.browser_download_url)"' | { grep -E '\.raw$' || true; } | tee prev_release_sysexts.txt
while IFS=$'\t' read -r name url; do
echo
echo " ## Fetching ${name} <-- ${url}"
curl -o "${name}" -fsSL --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 "${url}"
done <prev_release_sysexts.txt
streams=()
echo
echo "Building sysexts"
echo "================"
mapfile -t images < <( awk '{ content=sub("[[:space:]]*#.*", ""); if ($0) print $0; }' \
release_build_versions.txt )
KUBERNETES=()
for v in "${KBS_VERS_ARRAY[@]}"; do
KUBERNETES+=( "kubernetes-v${v}" )
done
images+=( "${CRIO[@]}" )
images+=( "${KUBERNETES[@]}" )
echo "building: ${images[@]}"
echo "# Release $(date '+%Y-%m-%d %R')" > Release.md
echo "The release adds the following sysexts:" >> Release.md
for image in "${images[@]}"; do
component="${image%-*}"
version="${image#*-}"
for arch in x86-64 arm64; do
target="${image}-${arch}.raw"
if [ -f "${target}" ] ; then
echo " ## Skipping ${target} because it already exists (asset from previous release)"
continue
fi
echo " ## Building ${target}."
ARCH="${arch}" "./create_${component}_sysext.sh" "${version}" "${component}"
mv "${component}.raw" "${target}"
echo "* ${target}" >> Release.md
done
streams+=("${component}:-@v")
if [ "${component}" = "kubernetes" ] || [ "${component}" = "crio" ]; then
streams+=("${component}-${version%.*}:.@v")
# Should give, e.g., v1.28 for v1.28.2 (use ${version#*.*.} to get 2)
fi
done
echo "" >> Release.md
echo "The release includes the following sysexts from previous releases:" >> Release.md
awk '{ print "* ["$1"]("$2")" }' prev_release_sysexts.txt >>Release.md
echo
echo "Generating systemd-sysupdate configurations and SHA256SUM."
echo "=========================================================="
for stream in "${streams[@]}"; do
component="${stream%:*}"
pattern="${stream#*:}"
cat << EOF > "${component}.conf"
[Transfer]
Verify=false
[Source]
Type=url-file
Path=https://github.com/flatcar/sysext-bakery/releases/latest/download/
MatchPattern=${component}${pattern}-%a.raw
[Target]
InstancesMax=3
Type=regular-file
Path=/opt/extensions/${component%-*}
CurrentSymlink=/etc/extensions/${component%-*}.raw
EOF
done
cat << EOF > "noop.conf"
[Source]
Type=regular-file
Path=/
MatchPattern=invalid@v.raw
[Target]
Type=regular-file
Path=/
EOF
# Generate new SHA256SUMS from all assets
sha256sum *.raw | tee SHA256SUMS