forked from Questie/Questie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-cf.sh
61 lines (52 loc) · 2.04 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
LATEST_GIT_TAG="$1"
CHANGELOG=$(jq --slurp --raw-input '.' < "CHANGELOG.md")
if [ "$LATEST_GIT_TAG" == *"-b"* ]; then
RELEASE_TYPE="beta"
else
RELEASE_TYPE="release"
fi
echo "Uploading $RELEASE_TYPE $LATEST_GIT_TAG to CurseForge"
#### 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_TYPE",
"changelog": $CHANGELOG,
"changelogType": "markdown",
"gameVersions": [10272, 12216, 11925],
"relations": {
"projects": [
{slug: "Ace3", type: "embeddedLibrary"},
{slug: "CallbackHandler", type: "embeddedLibrary"},
{slug: "HereBeDragons", type: "embeddedLibrary"},
{slug: "LibCompress", type: "embeddedLibrary"},
{slug: "LibDataBroker-1-1", type: "embeddedLibrary"},
{slug: "LibDBIcon-1-0", type: "embeddedLibrary"},
{slug: "LibSharedMedia-3-0", type: "embeddedLibrary"},
{slug: "LibStub", type: "embeddedLibrary"},
{slug: "LibUIDropDownMenu", 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/Questie-$LATEST_GIT_TAG.zip" \
"https://wow.curseforge.com/api/projects/334372/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