PaperMC / website

The PaperMC website
https://papermc.io/
MIT License
51 stars 34 forks source link

Latest stable build script incorrect #95

Closed phant0m2290 closed 8 months ago

phant0m2290 commented 8 months ago

in the script showed here it asks for a project entry but uses it only once and does not implement it in the way that it could support all projects.

this is the script listed on the docs:

#!/bin/bash

PROJECT="paper"
MINECRAFT_VERSION="1.20.4"

LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/paper | \
    jq -r '.versions[-1]')

LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds | \
    jq -r '.builds | map(select(.channel == "default") | .build) | .[-1]')

JAR_NAME=paper-${LATEST_VERSION}-${LATEST_BUILD}.jar

PAPERMC_URL="https://api.papermc.io/v2/projects/paper/versions/${LATEST_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}"

# Download the latest PaperMC version
curl -o server.jar $PAPERMC_URL
echo "Downloads completed"

Let me list the flaws

  1. line 5: LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/paper | \ the url is hardcoded to the paper project
  2. line 12: JAR_NAME=paper-${LATEST_VERSION}-${LATEST_BUILD}.jar the filename is hardcoded to the paper project
  3. line 14: PAPERMC_URL="https://api.papermc.io/v2/projects/paper/versions/${LATEST_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}" the url is hardcoded to the paper project.

This is a slightly modified version of the script that does support all projects and does not hard code any projects into the script

#!/bin/bash

PROJECT="paper"
MINECRAFT_VERSION="1.20.4"

LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/${PROJECT} | \
    jq -r '.versions[-1]')

LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds | \
    jq -r '.builds | map(select(.channel == "default") | .build) | .[-1]')

JAR_NAME=${PROJECT}-${LATEST_VERSION}-${LATEST_BUILD}.jar

PAPERMC_URL="https://api.papermc.io/v2/projects/${PROJECT}/versions/${LATEST_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}"

# Download the latest PaperMC version
curl -o server.jar $PAPERMC_URL
echo "Downloads completed"
olijeffers0n commented 8 months ago

Hi there, thanks for pointing this out! This is the wrong repository though - would you mind closing this and reopening it on our PaperMC/docs repo. Thanks ☺️

phant0m2290 commented 8 months ago

oh im sorry. thanks ill do that

phant0m2290 commented 8 months ago

https://github.com/PaperMC/docs/issues/308