-
Notifications
You must be signed in to change notification settings - Fork 25
/
update-flatcar-versions.sh
executable file
·68 lines (57 loc) · 2.32 KB
/
update-flatcar-versions.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
#!/bin/bash
set -euo pipefail
WEBSITE_DIR="$(git rev-parse --show-toplevel)"
FCL_RELEASE_SCRIPTS="${FCL_RELEASE_SCRIPTS:-$WEBSITE_DIR/../flatcar-linux-release-info}"
# Note: Since it does not pull, one should also prefix with "origin/" when overwriting
# except if one has an own local branch
BRANCH="${BRANCH:-origin/master}"
if [ ! -d "$FCL_RELEASE_SCRIPTS" ]; then
echo "Please get the flatcar-linux-release-info project"
echo " git clone https://github.com/kinvolk/flatcar-linux-release-info.git"
echo ""
echo "You can set its location by setting a FCL_RELEASE_SCRIPTS env var."
exit 1
fi
git -C "$FCL_RELEASE_SCRIPTS" fetch
git -C "$FCL_RELEASE_SCRIPTS" checkout "${BRANCH}"
LTS_INFO=$(curl -sSfL https://lts.release.flatcar-linux.net/lts-info)
mapfile -t LTS_SUPPORTED < <(echo "${LTS_INFO}" | { grep -v unsupported || true ; } | cut -d : -f 2 | sed 's/^/lts-/' || true)
if [ "${LTS_SUPPORTED[*]}" = "" ]; then
echo "Error: lts-info file seems empty"
exit 1
fi
for L in "${LTS_SUPPORTED[@]}"; do
echo "Found active LTS: $L"
if [ "$L" = "" ]; then
echo "Error: empty line in lts-info file?"
exit 1
fi
done
FLATCAR_DATA="$WEBSITE_DIR"/data
# stable must be last
CHANNELS=(
alpha
beta
lts
"${LTS_SUPPORTED[@]}"
stable
)
generate-release-feeds() {
RELEASES_DIR="$WEBSITE_DIR"/static/
for CHANNEL in "${CHANNELS[@]}" ; do \
"$FCL_RELEASE_SCRIPTS"/releases_as_json.py "$FLATCAR_DATA"/releases/"$CHANNEL"/*.yml > "$RELEASES_DIR"/releases-json/releases-"$CHANNEL".json;
"$FCL_RELEASE_SCRIPTS"/releases_as_feed.py "$FLATCAR_DATA"/releases/"$CHANNEL"/*.yml > "$RELEASES_DIR"/releases-feed/releases-"$CHANNEL".xml;
done
# releases/*/ will resolve stable as last one so that it wins for the "current" entry
"$FCL_RELEASE_SCRIPTS"/releases_as_json.py "$FLATCAR_DATA"/releases/*/*.yml > "$RELEASES_DIR"/releases-json/releases.json
FEED="all" "$FCL_RELEASE_SCRIPTS"/releases_as_feed.py "$FLATCAR_DATA"/releases/*/*.yml > "$RELEASES_DIR"/releases-feed/releases.xml
echo "Updated feeds"
}
fetch-current-releases() {
for CHANNEL in "${CHANNELS[@]}"; do
pushd "$FLATCAR_DATA" && "$FCL_RELEASE_SCRIPTS"/flatcar_release_info.py -c "$CHANNEL" -r current && popd
done
echo "Updated $FLATCAR_DATA/releases/*/*.yml"
}
fetch-current-releases
generate-release-feeds