diff --git a/.github/workflows/pushDocker.yml b/.github/workflows/pushDocker.yml index 0c99282..7f53868 100644 --- a/.github/workflows/pushDocker.yml +++ b/.github/workflows/pushDocker.yml @@ -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: diff --git a/build-images.sh b/build-images.sh index 386fc21..fa87aa5 100755 --- a/build-images.sh +++ b/build-images.sh @@ -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" @@ -43,5 +43,5 @@ build_images() { done } -build_images minecraft -build_images api +build_images latest +build_images recommended diff --git a/fetch-versions.sh b/fetch-versions.sh index 8baac2a..c19473f 100755 --- a/fetch-versions.sh +++ b/fetch-versions.sh @@ -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 @@ -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 'no-reply@cubeengine.org' -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 diff --git a/api-versions.json b/latest-versions.json similarity index 100% rename from api-versions.json rename to latest-versions.json diff --git a/minecraft-versions.json b/minecraft-versions.json deleted file mode 100644 index f00a43f..0000000 --- a/minecraft-versions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "1.16.5": "1.16.5-8.2.1-RC1369", - "1.17.1": "1.17.1-9.0.0-RC977", - "1.18.2": "1.18.2-9.0.0-RC1306", - "1.19.2": "1.19.2-10.0.0-RC1239", - "1.19.3": "1.19.3-10.0.0-RC1277", - "1.19.4": "1.19.4-10.0.0-RC1374", - "1.20.1": "1.20.1-11.0.0-RC1365", - "1.20.2": "1.20.2-11.0.0-RC1375" -} diff --git a/recommended-versions.json b/recommended-versions.json new file mode 100644 index 0000000..ce251e4 --- /dev/null +++ b/recommended-versions.json @@ -0,0 +1,3 @@ +{ + "8": "1.16.5-8.2.0" +}