Skip to content

Commit 08127f5

Browse files
committed
Update publish-curseforge.yml
1 parent dfb4b40 commit 08127f5

File tree

1 file changed

+28
-47
lines changed

1 file changed

+28
-47
lines changed

.github/workflows/publish-curseforge.yml

Lines changed: 28 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ on:
44
release:
55
types: [published]
66

7-
jobs:
7+
jobs:
88
publish:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-latest
1010

1111
steps:
12-
- name: Set up Python
13-
uses: actions/setup-python@v5
14-
with:
15-
python-version: '3.x'
16-
1712
- name: Download release asset
1813
env:
1914
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -22,8 +17,8 @@ jobs:
2217
ASSETS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
2318
"https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets")
2419
25-
# Find the decorations-plus.zip file
26-
ASSET_URL=$(echo "$ASSETS" | jq -r '.[] | select(.name == "decorations-plus.zip") | .url')
20+
# Find the decorations-plus.zip file (fixed jq syntax - no spaces)
21+
ASSET_URL=$(echo "$ASSETS" | jq -r '.[]|select(.name=="decorations-plus.zip")|.url')
2722
2823
if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" == "null" ]; then
2924
echo "❌ Could not find decorations-plus.zip in release assets!"
@@ -32,8 +27,8 @@ jobs:
3227
exit 1
3328
fi
3429
35-
echo "📥 Downloading decorations-plus.zip..."
36-
curl -L -H "Authorization: token $GITHUB_TOKEN" \
30+
echo "📥 Downloading decorations-plus.zip from: $ASSET_URL"
31+
curl -L -H "Authorization: token $GITHUB_TOKEN" \
3732
-H "Accept: application/octet-stream" \
3833
"$ASSET_URL" -o decorations-plus.zip
3934
@@ -49,15 +44,17 @@ jobs:
4944
exit 1
5045
fi
5146
52-
- name: Extract Minecraft versions from release
53-
id: extract_versions
47+
- name: Extract versions and upload to CurseForge
5448
env:
5549
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
50+
PROJECT_ID: 1356841
5651
RELEASE_BODY: ${{ github.event.release.body }}
52+
RELEASE_TAG: ${{ github.event.release.tag_name }}
53+
IS_PRERELEASE: ${{ github.event.release.prerelease }}
5754
run: |
5855
# Extract Minecraft versions from release body
59-
# Format: <!-- minecraft-versions: 1.21, 1.21.2, 1.21.3 -->
60-
VERSIONS=$(echo "$RELEASE_BODY" | grep -oP '(?<=<!-- minecraft-versions: ).*(?= -->)' || echo "")
56+
# Format: <!-- minecraft-versions: 1.21, 1.21.2, 1.21.3 -->
57+
VERSIONS=$(echo "$RELEASE_BODY" | grep -oP '(? <=<!-- minecraft-versions: ).*(? = -->)' || echo "")
6158
6259
if [ -z "$VERSIONS" ]; then
6360
echo "❌ No Minecraft versions specified in release body!"
@@ -81,21 +78,21 @@ jobs:
8178
# Trim whitespace
8279
VERSION=$(echo "$VERSION" | xargs)
8380
84-
# Find the ID for this version
85-
VERSION_ID=$(echo "$GAME_VERSIONS" | jq -r ".[] | select(.name == \"$VERSION\") | .id")
81+
# Find the ID for this version (fixed jq syntax)
82+
VERSION_ID=$(echo "$GAME_VERSIONS" | jq -r ".[]|select(.name==\"$VERSION\")|.id")
8683
8784
if [ -z "$VERSION_ID" ] || [ "$VERSION_ID" == "null" ]; then
8885
echo "⚠️ Warning: Could not find CurseForge ID for Minecraft $VERSION"
8986
continue
9087
fi
9188
92-
echo "✓ Minecraft $VERSION -> ID: $VERSION_ID"
89+
echo "✓ Minecraft $VERSION -> ID: $VERSION_ID"
9390
9491
if [ "$FIRST" = true ]; then
9592
VERSION_IDS="${VERSION_IDS}${VERSION_ID}"
9693
FIRST=false
9794
else
98-
VERSION_IDS="${VERSION_IDS}, ${VERSION_ID}"
95+
VERSION_IDS="${VERSION_IDS},${VERSION_ID}"
9996
fi
10097
done
10198
@@ -107,46 +104,30 @@ jobs:
107104
fi
108105
109106
echo "Game version IDs: $VERSION_IDS"
110-
echo "version_ids=$VERSION_IDS" >> $GITHUB_OUTPUT
111-
112-
- name: Upload to CurseForge
113-
env:
114-
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
115-
PROJECT_ID: 1356841
116-
VERSION_IDS: ${{ steps.extract_versions.outputs.version_ids }}
117-
run: |
107+
118108
# Prepare changelog (escape for JSON)
119-
CHANGELOG=$(echo '${{ github.event.release.body }}' | jq -Rs .)
109+
CHANGELOG=$(echo "$RELEASE_BODY" | jq -Rs .)
120110
121-
# Determine release type based on tag
111+
# Determine release type
122112
RELEASE_TYPE="release"
123-
if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
113+
if [[ "$RELEASE_TAG" == *"beta"* ]] || [[ "$IS_PRERELEASE" == "true" ]]; then
124114
RELEASE_TYPE="beta"
125-
elif [[ "${{ github.event.release.tag_name }}" == *"alpha"* ]]; then
115+
elif [[ "$RELEASE_TAG" == *"alpha"* ]]; then
126116
RELEASE_TYPE="alpha"
127117
fi
128118
129-
# Check if this is a pre-release
130-
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
131-
RELEASE_TYPE="beta"
132-
fi
133-
119+
echo ""
134120
echo "🚀 Uploading to CurseForge..."
135-
echo " Display Name: Decorations Plus ${{ github.event.release.tag_name }}"
121+
echo " Display Name: Decorations Plus $RELEASE_TAG"
136122
echo " Release Type: $RELEASE_TYPE"
137123
echo " Game Versions: $VERSION_IDS"
124+
echo ""
138125
139126
# Upload the data pack to CurseForge
140127
RESPONSE=$(curl -X POST \
141128
"https://minecraft.curseforge.com/api/projects/${PROJECT_ID}/upload-file" \
142129
-H "X-Api-Token: ${CURSEFORGE_TOKEN}" \
143-
-F "metadata={
144-
\"changelog\": $CHANGELOG,
145-
\"changelogType\": \"markdown\",
146-
\"displayName\": \"Decorations Plus ${{ github.event.release.tag_name }}\",
147-
\"gameVersions\": ${VERSION_IDS},
148-
\"releaseType\": \"${RELEASE_TYPE}\"
149-
};type=application/json" \
130+
-F "metadata={\"changelog\": $CHANGELOG,\"changelogType\":\"markdown\",\"displayName\":\"Decorations Plus $RELEASE_TAG\",\"gameVersions\":${VERSION_IDS},\"releaseType\":\"${RELEASE_TYPE}\"};type=application/json" \
150131
-F "file=@decorations-plus.zip" \
151132
-w "\nHTTP_STATUS:%{http_code}")
152133
@@ -159,7 +140,7 @@ jobs:
159140
160141
# Check if upload was successful (200-299 status codes)
161142
if [ "$HTTP_STATUS" -ge 200 ] && [ "$HTTP_STATUS" -lt 300 ]; then
162-
FILE_ID=$(echo "$BODY" | jq -r '.id // empty')
143+
FILE_ID=$(echo "$BODY" | jq -r '.id//empty')
163144
if [ -n "$FILE_ID" ]; then
164145
echo "✅ Successfully uploaded to CurseForge! File ID: $FILE_ID"
165146
echo "file_id=$FILE_ID" >> $GITHUB_ENV
@@ -172,8 +153,8 @@ jobs:
172153
exit 1
173154
fi
174155
175-
- name: Comment on Release
176-
if: success()
156+
- name: Comment on Release
157+
if: success()
177158
uses: actions/github-script@v7
178159
with:
179160
script: |

0 commit comments

Comments
 (0)