-
-
Notifications
You must be signed in to change notification settings - Fork 18
90 lines (75 loc) · 3.24 KB
/
Copy pathrelease.yml
File metadata and controls
90 lines (75 loc) · 3.24 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Build & Publish Bedrock Addon
permissions:
contents: write
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Package mcaddon
run: |
VERSION=${{ github.event.release.tag_name }}
OUTPUT="Canopy-${VERSION}.mcaddon"
mkdir build
cp -r "Canopy [BP]" "build/Canopy[BP]"
cp -r "Canopy [RP]" "build/Canopy[RP]"
cp LICENSE "build/Canopy[BP]"
cp LICENSE "build/Canopy[RP]"
cd build
zip -r "$OUTPUT" "Canopy[BP]" "Canopy[RP]"
mv "$OUTPUT" ..
cd ..
- name: Upload asset to GitHub Release
uses: softprops/action-gh-release@e798e6a1ede8d07b74ac4cdac6bdfa4cc1653907
with:
files: Canopy-${{ github.event.release.tag_name }}.mcaddon
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to CurseForge
env:
RELEASE_BODY: ${{ github.event.release.body }}
run: |
VERSION=${{ github.event.release.tag_name }}
# Read the game version from manifest.json
MIN_ENGINE_VERSION=$(jq -r '.header.min_engine_version | @csv' "Canopy [BP]/manifest.json")
IFS=',' read -r LEADING MAJOR MINOR <<< "$MIN_ENGINE_VERSION"
ENGINE_PREFIX="${MAJOR}.${MINOR}"
# Fetch all Bedrock versions from CurseForge API
CF_VERSIONS_JSON=$(curl -s -H "X-Api-Token: ${{ secrets.CF_API_TOKEN }}" \
"https://minecraft-bedrock.curseforge.com/api/game/versions")
# Extract all game version IDs whose name matches the game version from the manifest.json
GAME_VERSION_IDS=$(echo "$CF_VERSIONS_JSON" | jq -c --arg prefix "$ENGINE_PREFIX" '
[ .[] | select(.name | startswith($prefix)) | .id ]
')
if [ -z "$GAME_VERSION_IDS" ]; then
echo "No matching CurseForge versions found for engine prefix $ENGINE_PREFIX"
exit 1
fi
echo "Found CurseForge version IDs for game version $ENGINE_PREFIX: $GAME_VERSION_IDS"
# Use the Github release body as the changelog
CHANGELOG=$(printf "%s" "$RELEASE_BODY" | jq -Rs .)
ADDON_FILENAME=Canopy-$VERSION.mcaddon
# Upload the addon
RESPONSE=$(curl -s -X POST \
-H "X-Api-Token: ${{ secrets.CF_API_TOKEN }}" \
-F "metadata={
\"changelog\": $CHANGELOG,
\"changelogType\": \"markdown\",
\"displayName\": \"$ADDON_FILENAME\",
\"releaseType\": \"release\",
\"gameVersions\": $GAME_VERSION_IDS
}" \
-F "file=@$ADDON_FILENAME" \
https://minecraft-bedrock.curseforge.com/api/projects/1062078/upload-file
)
UPLOADED_ID=$(echo "$RESPONSE" | jq -r '.id // empty')
if [ -n "$UPLOADED_ID" ]; then
echo "Successfully uploaded release. File ID: $UPLOADED_ID"
else
echo "Upload failed. Response:"
echo "$RESPONSE"
exit 1
fi