Commit 8b206ef8 by Jonathan Thomas

Investigating curseforge deploy issue #1

parent 8b632382
Pipeline #12566 passed with stages
in 2 minutes 33 seconds
...@@ -126,6 +126,6 @@ CurseForge: ...@@ -126,6 +126,6 @@ CurseForge:
- chmod +x ./deploy-curseforge.sh - chmod +x ./deploy-curseforge.sh
- ./deploy-curseforge.sh - ./deploy-curseforge.sh
only: only:
- develop - fix-curseforge
tags: tags:
- minecraft - minecraft
...@@ -49,11 +49,17 @@ echo "" ...@@ -49,11 +49,17 @@ echo ""
# Iterate over each jar file in the artifacts # Iterate over each jar file in the artifacts
for FILE in creaturechat*.jar; do for FILE in creaturechat*.jar; do
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
echo "FILE: $FILE"
FILE_BASENAME=$(basename "$FILE") FILE_BASENAME=$(basename "$FILE")
OUR_VERSION=$(echo "$FILE_BASENAME" | sed -n 's/creaturechat-\(.*\)+.*\.jar/\1/p') OUR_VERSION=$(echo "$FILE_BASENAME" | sed -n 's/creaturechat-\(.*\)+.*\.jar/\1/p')
MINECRAFT_VERSION=$(echo "$FILE_BASENAME" | sed -n 's/.*+\(.*\)\.jar/\1/p') MINECRAFT_VERSION=$(echo "$FILE_BASENAME" | sed -n 's/.*+\(.*\)\.jar/\1/p')
VERSION_NUMBER="$OUR_VERSION-$MINECRAFT_VERSION" VERSION_NUMBER="$OUR_VERSION-$MINECRAFT_VERSION"
echo "loop: FILE_BASENAME: $FILE_BASENAME"
echo "loop: OUR_VERSION: $OUR_VERSION"
echo "loop: MINECRAFT_VERSION: $MINECRAFT_VERSION"
echo "loop: VERSION_NUMBER: $VERSION_NUMBER"
# Verify that OUR_VERSION and MINECRAFT_VERSION are not empty and OUR_VERSION matches VERSION # Verify that OUR_VERSION and MINECRAFT_VERSION are not empty and OUR_VERSION matches VERSION
if [ -z "$OUR_VERSION" ] || [ -z "$MINECRAFT_VERSION" ] || [ "$OUR_VERSION" != "$VERSION" ]; then if [ -z "$OUR_VERSION" ] || [ -z "$MINECRAFT_VERSION" ] || [ "$OUR_VERSION" != "$VERSION" ]; then
echo "ERROR: Version mismatch or missing version information in $FILE_BASENAME. OUR_VERSION: $OUR_VERSION, MINECRAFT_VERSION: $MINECRAFT_VERSION, EXPECTED VERSION: $VERSION" echo "ERROR: Version mismatch or missing version information in $FILE_BASENAME. OUR_VERSION: $OUR_VERSION, MINECRAFT_VERSION: $MINECRAFT_VERSION, EXPECTED VERSION: $VERSION"
...@@ -64,46 +70,7 @@ for FILE in creaturechat*.jar; do ...@@ -64,46 +70,7 @@ for FILE in creaturechat*.jar; do
# Fetch game version IDs # Fetch game version IDs
GAME_VERSION_IDS=($(fetch_game_version_ids "$MINECRAFT_VERSION")) GAME_VERSION_IDS=($(fetch_game_version_ids "$MINECRAFT_VERSION"))
echo "GAME_VERSION_IDS: $GAME_VERSION_IDS"
# Create a new version payload
PAYLOAD=$(jq -n --arg changelog "$CHANGELOG" \
--arg changelogType "markdown" \
--arg displayName "$FILE_BASENAME" \
--argjson gameVersions "$(printf '%s\n' "${GAME_VERSION_IDS[@]}" | jq -R . | jq -s .)" \
--argjson gameVersionTypeIds '[75125]' \
--arg releaseType "release" \
--argjson relations '[{"slug": "'"$DEPENDENCY_SLUG"'", "type": "requiredDependency"}]' \
'{
"changelog": $changelog,
"changelogType": $changelogType,
"displayName": $displayName,
"gameVersions": $gameVersions | map(tonumber),
"gameVersionTypeIds": $gameVersionTypeIds,
"releaseType": $releaseType,
"relations": {
"projects": $relations
}
}')
# Write the payload to a temporary file to avoid issues with large payloads
echo "$PAYLOAD" > metadata.json
# Sleep for the specified duration
sleep $SLEEP_DURATION
# Upload the version with the file
echo "Uploading $FILE_BASENAME as version $VERSION_NUMBER..."
HTTP_RESPONSE=$(curl --retry 3 --retry-delay 5 --fail -o response.txt -w "\nHTTP Code: %{http_code}\n" -X POST "$API_URL/projects/$PROJECT_ID/upload-file" \
-H "X-Api-Token: $CURSEFORGE_API_KEY" \
-H "User-Agent: $USER_AGENT" \
-F "metadata=<metadata.json;type=application/json" \
-F "file=@$FILE;type=application/java-archive")
# Output the response and HTTP code
echo "Response:"
cat response.txt
echo "$HTTP_RESPONSE"
echo "Uploaded $FILE_BASENAME as version $VERSION_NUMBER."
fi fi
done done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment