Skip to content

Commit a4e53cc

Browse files
publish workflow
1 parent 98098fb commit a4e53cc

1 file changed

Lines changed: 58 additions & 9 deletions

File tree

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Publish to Modrinth
1+
name: Publish to Modrinth and CurseForge
22

33
on:
44
workflow_dispatch:
55
inputs:
66
channel:
7-
description: 'Release channel on Modrinth'
7+
description: 'Release channel'
88
type: choice
99
options: [release, beta, alpha]
1010
default: release
@@ -18,8 +18,15 @@ permissions:
1818
contents: read
1919

2020
jobs:
21-
modrinth:
21+
# Resolves versions, downloads the JAR once and shares it with both publish jobs.
22+
prepare:
2223
runs-on: ubuntu-latest
24+
outputs:
25+
mc: ${{ steps.versions.outputs.mc }}
26+
mc_family: ${{ steps.versions.outputs.mc_family }}
27+
mod: ${{ steps.versions.outputs.mod }}
28+
jar: ${{ steps.release.outputs.jar }}
29+
changelog: ${{ steps.release.outputs.changelog }}
2330
steps:
2431
- name: Checkout code
2532
uses: actions/checkout@v4
@@ -33,6 +40,8 @@ jobs:
3340
| sed 's/.*=\s*//' | tr -d '[:space:]')
3441
echo "mc=$MC" >> "$GITHUB_OUTPUT"
3542
echo "mod=$MOD" >> "$GITHUB_OUTPUT"
43+
# CurseForge groups versions by family, e.g. 1.21.1 -> "Minecraft 1.21"
44+
echo "mc_family=$(echo "$MC" | cut -d. -f1,2)" >> "$GITHUB_OUTPUT"
3645
3746
# Release for v<mc>-<mod>; if it doesn't exist, use the latest release.
3847
- name: Download JAR and notes from GitHub release
@@ -57,7 +66,7 @@ jobs:
5766
5867
# Only the compiled mod JAR: skip -sources / -javadoc / -dev
5968
find dist -name '*.jar' \
60-
\( -name '*-sources.jar' -o -name '*-javadoc.jar' -o -name '*-dev.jar' \) -delete
69+
\( -name '*-sources.jar' -o -name '*-javadoc.jar' -o -name '*-dev.jar' -o -name '*-slim.jar' \) -delete
6170
6271
COUNT=$(find dist -name '*.jar' | wc -l)
6372
if [ "$COUNT" -ne 1 ]; then
@@ -79,15 +88,55 @@ jobs:
7988
echo 'CHANGELOG_EOF'
8089
} >> "$GITHUB_OUTPUT"
8190
91+
- name: Share JAR with publish jobs
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: mod-jar
95+
path: dist/*.jar
96+
if-no-files-found: error
97+
98+
modrinth:
99+
needs: prepare
100+
runs-on: ubuntu-latest
101+
steps:
102+
- name: Download JAR
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: mod-jar
106+
path: dist
107+
82108
- name: Publish to Modrinth
83109
uses: cloudnode-pro/modrinth-publish@v2
84110
with:
85111
token: ${{ secrets.MODRINTH_TOKEN }}
86112
project: ${{ vars.MODRINTH_ID }}
87-
name: ${{ steps.versions.outputs.mod }} (MC ${{ steps.versions.outputs.mc }})
88-
version: ${{ steps.versions.outputs.mod }}
113+
name: ${{ needs.prepare.outputs.mod }} (MC ${{ needs.prepare.outputs.mc }})
114+
version: ${{ needs.prepare.outputs.mod }}
89115
channel: ${{ inputs.channel }}
90-
changelog: ${{ steps.release.outputs.changelog }}
116+
changelog: ${{ needs.prepare.outputs.changelog }}
91117
loaders: neoforge
92-
game-versions: ${{ steps.versions.outputs.mc }}
93-
files: ${{ steps.release.outputs.jar }}
118+
game-versions: ${{ needs.prepare.outputs.mc }}
119+
files: ${{ needs.prepare.outputs.jar }}
120+
121+
curseforge:
122+
needs: prepare
123+
runs-on: ubuntu-latest
124+
steps:
125+
- name: Download JAR
126+
uses: actions/download-artifact@v4
127+
with:
128+
name: mod-jar
129+
path: dist
130+
131+
- name: Publish to CurseForge
132+
uses: itsmeow/curseforge-upload@v3
133+
with:
134+
token: ${{ secrets.CURSEFORGE_TOKEN }}
135+
project_id: ${{ vars.CURSEFORGE_ID }}
136+
game_endpoint: minecraft
137+
file_path: ${{ needs.prepare.outputs.jar }}
138+
display_name: ${{ needs.prepare.outputs.mod }} (MC ${{ needs.prepare.outputs.mc }})
139+
release_type: ${{ inputs.channel }}
140+
changelog: ${{ needs.prepare.outputs.changelog }}
141+
changelog_type: markdown
142+
game_versions: "Minecraft ${{ needs.prepare.outputs.mc_family }}:${{ needs.prepare.outputs.mc }},Java 21,NeoForge"

0 commit comments

Comments
 (0)