-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathrelease_meta.sh
executable file
·116 lines (94 loc) · 2.59 KB
/
release_meta.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
#!/bin/bash
#
# Update bakery release metadata
#
# If a sysext name is provided in "$1" we download
# - all sysupdate configurations
# - all SHA256SUMS
# and create a new extension metadata release from that.
#
# If $1 is empty, we update the global SHA256SUMS covering all releases.
set -euo pipefail
cd "$(dirname "$0")"
source "lib/libbakery.sh"
rm -f *.raw SHA256SUMS.* SHA256SUMS *.conf Release.md
extension="$(extension_name "${@:-}")"
tag="${extension:-SHA256SUMS}"
function out() {
echo "${@:-}" | tee -a Release.md
}
# --
function fetch_artefacts() {
local release="$1"
{ curl_api_wrapper \
"https://api.github.com/repos/${bakery}/releases/tags/${release}" \
| jq -r '.assets[] | "\(.name)\t\(.browser_download_url)"' | grep -E '(\bSHA256SUMS|\.conf)$' || true; } \
> downloads.txt
while IFS=$'\t' read -r name url; do
echo " Fetching ${name} <-- ${url}"
curl \
-o "${name}" -fsSL --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 \
--connect-timeout 20 "${url}"
done <downloads.txt
rm -f downloads.txt
}
# --
function fetch_extension_metadata() {
local extension="$1"
local versions="$(./bakery.sh list-bakery "${extension}")"
if [[ -z "${versions}" ]] ; then
out "* SKIPPED ${extension} as no releases are available"
return
fi
for version in $(./bakery.sh list-bakery "${extension}"); do
release="${extension}-${version}"
out "* ${release}"
fetch_artefacts "${release}"
cat SHA256SUMS >> SHA256SUMS.all
done
mv SHA256SUMS.all SHA256SUMS
}
# --
if [[ -n $extension ]] ; then
out "# Extension ${extension} metadata release."
fetch_extension_metadata "$extension"
if [[ ! -f SHA256SUMS ]] ; then
out "No releases available at this time."
else
out ""
out "## Sysupdate confs:"
out '```'
ls -1 *.conf | tee -a Release.md
out '```'
fi
else
out "# Global SHA256SUMS metadata release."
out ""
for extension in $(./bakery.sh list --plain true); do
echo
fetch_artefacts "$extension"
if [[ ! -f SHA256SUMS ]] ; then
out "* SKIPPED ${extension} as no SHA256SUMS is available"
continue
fi
cat SHA256SUMS >> SHA256SUMS.global
out "* ${extension}:"
sed 's:.*\s: * :' SHA256SUMS | tee -a Release.md
rm SHA256SUMS
done
if [[ ! -f SHA256SUMS.global ]] ; then
out "No releases available at this time."
else
mv SHA256SUMS.global SHA256SUMS
fi
fi
# --
if [[ -f SHA256SUMS ]] ; then
out ""
out "# SHA256SUMS:"
out '```'
cat SHA256SUMS | tee -a Release.md
out '```'
fi
git tag -f "${tag}" --force
git push origin "${tag}" --force