forked from docker-library/ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-stackbrew-library.jq
More file actions
77 lines (68 loc) · 2.33 KB
/
generate-stackbrew-library.jq
File metadata and controls
77 lines (68 loc) · 2.33 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
to_entries
# latest version is the first one since it is already in version order
| first(.[] | select(.value and (.key | endswith("-rc") | not))) as $latestMajor
# latest suite of each variant in the latest version
| first($latestMajor.value.variants | keys_unsorted[] | select(contains("alpine"))) as $latestAlpine
| first($latestMajor.value.variants | keys_unsorted[] | select(contains("alpine") | not)) as $latestDebian
| $latestMajor.key as $latestMajor
# loop over major versions
| .[]
| .key as $majorVersion
| .value
# only the major versions asked for "./generate-stackbrew-library.sh X Y ..."
| if $ARGS.positional | length > 0 then
select(IN($majorVersion; $ARGS.positional[]))
else . end
# explode a version to a list of tags
# e.g. "1.2.3" -> [ "1.2.3", "1.2", "1", "" ]
# e.g. "1.2.3-beta.1" -> [ "1.2.3-beta.1", "1-rc" ]
| (
.version
# this is an RC, so don't explode the version
| if $majorVersion | endswith("-rc") then
[ ., $majorVersion ]
else
split(".")
# TODO if more than one minor of a major version is tracked (6.1 and 6.0), then this needs to be filtered when not the latest (so only one would get `6`)
| [ foreach .[] as $c ([]; .+=[$c]) | join(".") ]
| reverse
# add plain variant/latest if this is the newest version
| if $majorVersion == $latestMajor then
. + [ "" ] # empty for plain variant tag and latest
else . end
end
) as $versionTags
# loop over variants (in versions.json order)
| .variants | to_entries[]
| .key as $variant
| .value
# generate a list of tags for this variant
| (
[
$versionTags[] as $version
# create a list of variant suffixes
| [
$variant, # "alpine3.22" or "bookworm"
# if it is the newest alpine, add suffix without alpine version
if $variant == $latestAlpine then
"alpine"
else empty end,
# if it is the newest debian, add an empty suffix to get plain tags
if $variant == $latestDebian then
""
else empty end,
empty
][] as $suffix
# join each version with each suffix
| [ $version, $suffix | select(. != "") ] # remove empty strings so that join doesn't create "-alpine" or "-"
| join("-")
| if . == "" then "latest" else . end
]
) as $tags
| (
"", # newline between library entries
"Tags: \($tags | join(", "))",
"Directory: \($majorVersion)/\($variant)",
"Architectures: \(.arches - (.arches - $parentArches[.from]) | join(", "))",
empty
)