-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-images.sh
executable file
·52 lines (43 loc) · 1.41 KB
/
build-images.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
#!/usr/bin/env bash
set -euo pipefail
build_image() {
local kind="${1?no kind}"
local version="${2?no version}"
local asset="${3?no asset}"
local sponge_jar_file="sponge.jar"
local download_url="$(curl -s "https://dl-api.spongepowered.org/v2/groups/org.spongepowered/artifacts/spongevanilla/versions/$asset" | jq -r '.assets | map(select(.classifier == "universal")) | first | .downloadUrl')"
curl -s -L -o "$sponge_jar_file" "$download_url"
local repo_name="ghcr.io/cubeengine/sponge"
local cache_repo="${repo_name}/cache"
local image_name="${repo_name}:latest"
podman build \
-t "$image_name" \
--layers \
--timestamp 0 \
.
rm "$sponge_jar_file"
local tags=("$kind-$version" "$asset")
for t in "${tags[@]}"
do
local name="$repo_name:$t"
podman tag "$image_name" "$name"
podman push "$name"
done
}
build_images() {
local kind="${1?no kind}"
local file="$kind-versions.json"
readarray -t versions <<< "$(jq -r 'to_entries | map(.key) | .[]' < $file)"
for version in "${versions[@]}"
do
local asset="$(jq -r --arg version "$version" '.[$version]' < $file)"
build_image "$kind" "$version" "$asset"
done
}
if ./fetch-versions.sh || [ "${EVENT_NAME:-}" != "schedule" ]
then
build_images latest
build_images recommended
else
echo "Nothing changed, nothing to build!"
fi