Add VERSION_FROM_MODRINTH_PROJECTS (#3580)

This commit is contained in:
Geoff Bourne
2025-08-02 19:01:49 -05:00
committed by GitHub
parent 02640e5414
commit c2071e5038
4 changed files with 45 additions and 1 deletions

View File

@@ -48,7 +48,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=${MC_SERVER_RUNNER_VERSION} --var app=mc-server-runner --file {{.app}} \
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
ARG MC_HELPER_VERSION=1.47.3
ARG MC_HELPER_VERSION=1.48.0
ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
# used for cache busting local copy of mc-image-helper
ARG MC_HELPER_REV=1

View File

@@ -42,6 +42,25 @@
datapack:terralith
```
## Version from Projects
When the environment variable `VERSION_FROM_MODRINTH_PROJECTS` is set to "true" the Minecraft [`VERSION`](../versions/minecraft.md) will be automatically determined by looking at the most recent version of Minecraft that is supported by all the projects provided in `MODRINTH_PROJECTS`.
!!! example
Given the environment variables
```yaml
MODRINTH_PROJECTS: |
viaversion
viabackwards
griefprevention
discordsrv
VERSION_FROM_MODRINTH_PROJECTS: true
```
Let's say all are supported on Minecraft up to 1.21.8 except griefprevention, which is only supported up to 1.21.7. In that case, `VERSION` will be automatically set to 1.21.7.
## Extra options
`MODRINTH_DOWNLOAD_DEPENDENCIES`
@@ -52,3 +71,4 @@
`MODRINTH_LOADER`
: When using a custom server, set this to specify which loader type will be requested during lookups

View File

@@ -0,0 +1,15 @@
services:
mc:
image: itzg/minecraft-server
environment:
EULA: true
TYPE: paper
MODRINTH_PROJECTS: |
viaversion
viabackwards
griefprevention
discordsrv
VERSION_FROM_MODRINTH_PROJECTS: true
SETUP_ONLY: true
ports:
- "25565:25565"

View File

@@ -139,6 +139,15 @@ cd /data || exit 1
export DECLARED_TYPE=${TYPE^^}
export DECLARED_VERSION="$VERSION"
if isTrue "${VERSION_FROM_MODRINTH_PROJECTS:-}" && [[ ${MODRINTH_PROJECTS:-} ]]; then
if ! VERSION=$(mc-image-helper version-from-modrinth-projects --projects "${MODRINTH_PROJECTS}"); then
logError "failed to resolve version from MODRINTH_PROJECTS: ${MODRINTH_PROJECTS}"
exit 1
fi
log "Resolved Minecraft version $VERSION from Modrinth projects"
export VERSION
fi
if isTrue "${ENABLE_AUTOPAUSE}"; then
"${SCRIPTS:-/}start-autopause"
fi