-
Notifications
You must be signed in to change notification settings - Fork 17
/
upload-cf.sh
47 lines (40 loc) · 1.51 KB
/
upload-cf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
LATEST_GIT_TAG="$1"
CHANGELOG=$(jq --slurp --raw-input '.' < "CHANGELOG.md")
#### CurseForge Upload
# Docs: https://support.curseforge.com/en/support/solutions/articles/9000197321-curseforge-upload-api
# We get the "gameVersions" by doing an authenticated GET to https://wow.curseforge.com/api/game/versions
# You can do so by opening the API in your browser and manually add the X-API-TOKEN Header with an API-Token to the request (https://authors-old.curseforge.com/account/api-tokens).
# Check the answer for the required version (e.g. name = "1.14.4") and take the "id" field for the gameVersions.
CF_METADATA=$(cat <<-EOF
{
"displayName": "$LATEST_GIT_TAG",
"releaseType": "release",
"changelog": $CHANGELOG,
"changelogType": "markdown",
"gameVersions": [12216, 10272],
"relations": {
"projects": [
{slug: "Ace3", type: "embeddedLibrary"},
{slug: "CallbackHandler", type: "embeddedLibrary"},
{slug: "LibStub", type: "embeddedLibrary"}
]
}
}
EOF
)
response=$(curl -sS \
-o response.txt \
-w "%{http_code}" \
-H "X-API-TOKEN: $CF_API_TOKEN" \
-F "metadata=$CF_METADATA" \
-F "file=@releases/$LATEST_GIT_TAG/ExtendedCharacterStats-$LATEST_GIT_TAG.zip" \
"https://wow.curseforge.com/api/projects/334877/upload-file")
http_status=$(echo "$response" | tail -n1)
if [ "$http_status" -eq 200 ]; then
echo "CurseForge upload successful"
else
echo "CurseForge upload failed, HTTP-code: $http_status"
cat response.txt
exit 1
fi