Download and use packwiz from Maven repository (#1725)

Also
* Added github actions debug support
* added use of fileNotExists
This commit is contained in:
Geoff Bourne 2022-09-10 12:58:32 -05:00 committed by GitHub
parent 4d3464f3f1
commit fabe14db49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 98 additions and 74 deletions

View file

@ -64,5 +64,6 @@ jobs:
MINECRAFT_VERSION: ${{ matrix.mcVersion }}
VARIANT: ${{ matrix.variant }}
MODS_FORGEAPI_KEY: ${{ secrets.MODS_FORGEAPI_KEY }}
DEBUG: ${{ runner.debug }}
run: |
tests/test.sh

View file

@ -46,7 +46,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
ARG MC_HELPER_VERSION=1.22.4
ARG MC_HELPER_VERSION=1.22.6
ARG MC_HELPER_RELEASE=v${MC_HELPER_VERSION}
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_RELEASE}
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \

3
examples/.gitignore vendored
View file

@ -1 +1,2 @@
/data/
/data/
modpacks/

View file

@ -0,0 +1,21 @@
version: '3.8'
services:
minecraft:
image: itzg/minecraft-server
volumes:
- data:/data
- ./mods:/mods
ports:
- "25565:25565"
environment:
EULA: "true"
TYPE: "FORGE"
VERSION: "1.19.2"
DEBUG: "true"
SETUP_ONLY: "true"
tty: True
stdin_open: True
volumes:
data: {}

View file

@ -0,0 +1,21 @@
version: '3.8'
services:
mc:
image: itzg/minecraft-server:java8-multiarch
volumes:
- data:/data
- ./modpacks:/modpacks:ro
environment:
EULA: "true"
TYPE: FORGE
VERSION: "1.15.2"
GENERIC_PACK: /modpacks/Valhelsia_2-2.3.4-SERVER.zip
MEMORY: "2G"
ports:
- "25565:25565"
healthcheck:
test: NONE
volumes:
data: {}

View file

@ -17,7 +17,7 @@ set -e
if isTrue "${REPLACE_ENV_IN_PLACE}"; then
log "Replacing env variables in ${REPLACE_ENV_PATHS} that match the prefix $REPLACE_ENV_VARIABLE_PREFIX ..."
mc-image-helper --debug=${DEBUG} interpolate \
mc-image-helper interpolate \
--replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \
@ -27,7 +27,7 @@ fi
if [[ ${PATCH_DEFINITIONS} ]]; then
log "Applying patch definitions from ${PATCH_DEFINITIONS}"
mc-image-helper --debug=${DEBUG} patch \
mc-image-helper patch \
--patch-env-prefix="${REPLACE_ENV_VARIABLE_PREFIX}" \
"${PATCH_DEFINITIONS}"
fi

View file

@ -22,39 +22,26 @@ if isTrue "${REMOVE_OLD_MODS}" && [ -z "${MODS_FILE}" ]; then
rm -f "$sum_file"
fi
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
if [[ "${PACKWIZ_URL:-}" ]]; then
# Ensure we have the latest packwiz bootstrap installer
latestPackwiz=$(get_from_gh "https://api.github.com/repos/packwiz/packwiz-installer-bootstrap/releases/latest")
if [[ -z "${latestPackwiz}" ]]; then
log "WARNING: Could not retrieve Packwiz bootstrap installer release information"
else
isDebugging && log "Latest packwiz ${latestPackwiz}"
latestPackwizVer=$(echo "${latestPackwiz}" | jq --raw-output '.tag_name')
latestPackwizUrl=$(echo "${latestPackwiz}" | jq --raw-output '.assets[] | select(.name | match("packwiz-installer-bootstrap.jar")) | .url')
: "${PACKWIZ_BOOTSTRAP_JAR:=packwiz-installer-bootstrap_${latestPackwizVer}.jar}"
if [[ ! -e $PACKWIZ_BOOTSTRAP_JAR ]]; then
log "Downloading Packwiz ${latestPackwizVer}"
if ! curl -H "Accept:application/octet-stream" -o "$PACKWIZ_BOOTSTRAP_JAR" -fsSL ${latestPackwizUrl}; then
log "ERROR: failed to download Packwiz bootstrap installer"
exit 1
fi
function handlePackwiz() {
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
if [[ "${PACKWIZ_URL:-}" ]]; then
if ! packwizInstaller=$(mc-image-helper maven-download \
--maven-repo=https://maven.packwiz.infra.link/repository/release/ \
--group=link.infra.packwiz --artifact=packwiz-installer --classifier=dist \
--skip-existing); then
log "ERROR: failed to get packwiz installer"
exit 1
fi
log "Running packwiz installer against URL: ${PACKWIZ_URL}"
if ! java -cp "${packwizInstaller}" link.infra.packwiz.installer.Main "${PACKWIZ_URL}"; then
log "ERROR failed to run packwiz installer"
exit 1
fi
fi
log "Running packwiz installer against URL: ${PACKWIZ_URL}"
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -s server "${PACKWIZ_URL}"
#if bootstrap download fails, download installer manually - then run without updating
returnVal=$?
if [[ $returnVal ]]; then
latestPackwizInstaller=$(get_from_gh "https://api.github.com/repos/packwiz/packwiz-installer/releases/latest")
latestPackwizInstallerVer=$(echo "${latestPackwizInstaller}" | jq --raw-output '.tag_name')
latestPackwizInstallerUrl=$(echo "${latestPackwizInstaller}" | jq --raw-output '.assets[] | select(.name | match("packwiz-installer.jar")) | .url')
log "Packwiz couldn't update - Downloading Packwiz Installer ${latestPackwizInstallerVer}"
get_from_gh "${latestPackwizInstallerUrl}" -H "Accept:application/octet-stream" -o "packwiz-installer.jar"
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -bootstrap-no-update -s server "${PACKWIZ_URL}"
fi
fi
}
function handleModpackListOrFile() {
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
if [[ "$MODPACK" ]]; then
if isURL "${MODPACK}"; then
@ -149,7 +136,9 @@ elif [[ "$MODS_FILE" ]]; then
exit 1
fi
fi
}
function handleCurseForgeManifest() {
if [[ "$MANIFEST" ]]; then
if [[ -e "$MANIFEST" ]]; then
EFFECTIVE_MANIFEST_FILE=$MANIFEST
@ -192,6 +181,7 @@ case "X$EFFECTIVE_MANIFEST_FILE" in
;;
esac
fi
}
function genericPacks() {
: "${GENERIC_PACKS:=${GENERIC_PACK}}"
@ -291,6 +281,12 @@ function modrinthProjects() {
fi
}
handlePackwiz
handleModpackListOrFile
handleCurseForgeManifest
genericPacks
modrinthProjects

View file

@ -30,7 +30,7 @@ if [ -d /plugins ]; then
mkdir -p /data/plugins
log "Copying plugins over..."
mc-image-helper \
--debug=${DEBUG} ${subcommand} $updateArg \
${subcommand} $updateArg \
--replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \
@ -46,7 +46,7 @@ fi
if [ -d /mods ]; then
log "Copying any mods over..."
mc-image-helper \
--debug=${DEBUG} ${subcommand} $updateArg \
${subcommand} $updateArg \
--replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \
@ -59,7 +59,7 @@ fi
if [ -d /config ]; then
log "Copying any configs from /config to ${COPY_CONFIG_DEST}"
mc-image-helper \
--debug=${DEBUG} ${subcommand} $updateArg \
${subcommand} $updateArg \
--replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \

View file

@ -63,47 +63,27 @@ function getFilenameFromUrl() {
}
function isTrue() {
local oldState
oldState=$(shopt -po xtrace)
shopt -u -o xtrace
local value=${1,,}
result=
case ${value} in
true | on)
result=0
local arg="${1?}"
case ${arg,,} in
true | on | 1)
return 0
;;
*)
result=1
return 1
;;
esac
eval "$oldState"
return ${result}
}
function isFalse() {
local oldState
oldState=$(shopt -po xtrace)
shopt -u -o xtrace
local value=${1,,}
result=
case ${value} in
false | off)
result=0
local arg="${1?}"
case ${arg,,} in
false | off | 0)
return 0
;;
*)
result=1
return 1
;;
esac
eval "$oldState"
return ${result}
}
function isDebugging() {

View file

@ -1,5 +1,7 @@
mc-image-helper assert fileExists world/level.dat && \
mc-image-helper assert fileExists world_nether/DIM-1/some_spigot_nether_file && \
mc-image-helper assert fileExists world_the_end/DIM1/some_spigot_end_file && \
! mc-image-helper assert fileExists world_nether/DIM-1/some_vanilla_nether_file && \
! mc-image-helper assert fileExists world_the_end/DIM1/some_vanilla_end_file
mc-image-helper assert fileExists \
world/level.dat \
world_nether/DIM-1/some_spigot_nether_file \
world_the_end/DIM1/some_spigot_end_file
mc-image-helper assert fileNotExists \
world_nether/DIM-1/some_vanilla_nether_file \
world_the_end/DIM1/some_vanilla_end_file

View file

@ -11,11 +11,11 @@ services:
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "true"
SETUP_ONLY: "true"
PACKWIZ_URL: http://web/pack.toml
TYPE: CUSTOM
CUSTOM_SERVER: /servers/fake.jar
VERSION: 1.19
DEBUG_HELPER: "true"
volumes:
- ./data:/data
- ./fake.jar:/servers/fake.jar

View file

@ -39,8 +39,10 @@ setupOnlyMinecraftTest(){
fi
fi
# false positive since it's used in delta calculations below
# shellcheck disable=SC2034
start=$(date +%s)
if ! logs=$(docker compose run mc 2>&1); then
if ! logs=$(docker compose run --rm -e SETUP_ONLY=true -e DEBUG="${DEBUG:-false}" mc 2>&1); then
outputContainerLog "$logs"
result=1
elif [ -f verify.sh ]; then