Skip to content

Commit

Permalink
fetch latest and recommended instead of api and minecraft
Browse files Browse the repository at this point in the history
  • Loading branch information
pschichtel committed Oct 3, 2023
1 parent 4743d89 commit eded644
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pushDocker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
branches:
- master
paths:
- minecraft-versions.json
- api-versions.json
- latest-versions.json
- recommended-versions.json
- Dockerfile
- build-images.sh
workflow_dispatch:
Expand Down
6 changes: 3 additions & 3 deletions build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build_image() {
.
rm "$sponge_jar_file"

local tags=("$kind-$version" "$kind-$asset")
local tags=("$kind-$version" "$asset")
for t in "${tags[@]}"
do
local name="$repo_name:$t"
Expand All @@ -43,5 +43,5 @@ build_images() {
done
}

build_images minecraft
build_images api
build_images latest
build_images recommended
30 changes: 11 additions & 19 deletions fetch-versions.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#!/usr/bin/env bash

minecraft_versions=(
1.20.2
1.20.1
1.19.4
1.19.3
1.19.2
1.18.2
1.17.1
1.16.5
)
set -euo pipefail

api_versions=(
11
Expand All @@ -20,30 +11,31 @@ api_versions=(

fetch_versions() {
local kind="${1?no kind!}"
shift 1
local recommended="${2?no recommended flag!}"
shift 2
for v in "$@"
do
curl -s "https://dl-api.spongepowered.org/v2/groups/org.spongepowered/artifacts/spongevanilla/versions?tags=${kind}:${v}&offset=0&limit=1" \
| jq --arg version "$v" -Mc '{key: $version, value: .artifacts | to_entries | first | .key}'
curl -s "https://dl-api.spongepowered.org/v2/groups/org.spongepowered/artifacts/spongevanilla/versions?tags=${kind}:${v}&recommended=${recommended}&offset=0&limit=1" \
| jq --arg version "$v" -Mc '{key: $version, value: (.artifacts // {}) | to_entries | first | .key}'
done
}

transform_to_versions() {
jq -s 'sort_by(.key) | from_entries'
jq -s 'sort_by(.key) | map(select(.value != null)) | from_entries'
}

versions_file="$(mktemp)"

minecraft_versions_file="minecraft-versions.json"
api_versions_file="api-versions.json"
latest_versions_file="latest-versions.json"
recommended_versions_file="recommended-versions.json"

fetch_versions "minecraft" "${minecraft_versions[@]}" | transform_to_versions > "$minecraft_versions_file"
fetch_versions "api" "${api_versions[@]}" | transform_to_versions > "$api_versions_file"
fetch_versions "api" false "${api_versions[@]}" | transform_to_versions > "$latest_versions_file"
fetch_versions "api" true "${api_versions[@]}" | transform_to_versions > "$recommended_versions_file"

git config user.name 'CubeEngine Sponge Updater'
git config user.email '[email protected]'

git add "$minecraft_versions_file" "$api_versions_file"
git add "$latest_versions_file" "$recommended_versions_file"

if git commit -m 'My hands are typing words....'
then
Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions minecraft-versions.json

This file was deleted.

3 changes: 3 additions & 0 deletions recommended-versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"8": "1.16.5-8.2.0"
}

0 comments on commit eded644

Please sign in to comment.