Skip to content

Commit c2071e5

Browse files
authored
Add VERSION_FROM_MODRINTH_PROJECTS (#3580)
1 parent 02640e5 commit c2071e5

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
4848
--var version=${MC_SERVER_RUNNER_VERSION} --var app=mc-server-runner --file {{.app}} \
4949
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
5050

51-
ARG MC_HELPER_VERSION=1.47.3
51+
ARG MC_HELPER_VERSION=1.48.0
5252
ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
5353
# used for cache busting local copy of mc-image-helper
5454
ARG MC_HELPER_REV=1

docs/mods-and-plugins/modrinth.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@
4242
datapack:terralith
4343
```
4444

45+
## Version from Projects
46+
47+
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`.
48+
49+
!!! example
50+
51+
Given the environment variables
52+
53+
```yaml
54+
MODRINTH_PROJECTS: |
55+
viaversion
56+
viabackwards
57+
griefprevention
58+
discordsrv
59+
VERSION_FROM_MODRINTH_PROJECTS: true
60+
```
61+
62+
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.
63+
4564
## Extra options
4665

4766
`MODRINTH_DOWNLOAD_DEPENDENCIES`
@@ -52,3 +71,4 @@
5271

5372
`MODRINTH_LOADER`
5473
: When using a custom server, set this to specify which loader type will be requested during lookups
74+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
mc:
3+
image: itzg/minecraft-server
4+
environment:
5+
EULA: true
6+
TYPE: paper
7+
MODRINTH_PROJECTS: |
8+
viaversion
9+
viabackwards
10+
griefprevention
11+
discordsrv
12+
VERSION_FROM_MODRINTH_PROJECTS: true
13+
SETUP_ONLY: true
14+
ports:
15+
- "25565:25565"

scripts/start-configuration

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ cd /data || exit 1
139139
export DECLARED_TYPE=${TYPE^^}
140140
export DECLARED_VERSION="$VERSION"
141141

142+
if isTrue "${VERSION_FROM_MODRINTH_PROJECTS:-}" && [[ ${MODRINTH_PROJECTS:-} ]]; then
143+
if ! VERSION=$(mc-image-helper version-from-modrinth-projects --projects "${MODRINTH_PROJECTS}"); then
144+
logError "failed to resolve version from MODRINTH_PROJECTS: ${MODRINTH_PROJECTS}"
145+
exit 1
146+
fi
147+
log "Resolved Minecraft version $VERSION from Modrinth projects"
148+
export VERSION
149+
fi
150+
142151
if isTrue "${ENABLE_AUTOPAUSE}"; then
143152
"${SCRIPTS:-/}start-autopause"
144153
fi

0 commit comments

Comments
 (0)