1+ name : Release to CurseForge and Modrinth
2+
3+ on :
4+ release :
5+ types : [created]
6+
7+ jobs :
8+ build-and-release :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Checkout code
12+ uses : actions/checkout@v3
13+
14+ - name : Set up JDK 17
15+ uses : actions/setup-java@v3
16+ with :
17+ distribution : ' temurin'
18+ java-version : ' 17'
19+ cache : ' maven'
20+
21+ - name : Extract branch name and determine Minecraft version
22+ id : extract_branch
23+ run : |
24+ BRANCH_NAME=${GITHUB_REF_NAME}
25+ echo "Branch name: $BRANCH_NAME"
26+
27+ # Extract Minecraft version from branch name (e.g., 1.19.x -> 1.19)
28+ if [[ $BRANCH_NAME =~ ([0-9]+\.[0-9]+)\.x ]]; then
29+ MC_VERSION=${BASH_REMATCH[1]}
30+ echo "Detected Minecraft version: $MC_VERSION"
31+ echo "mc_version=$MC_VERSION" >> $GITHUB_OUTPUT
32+
33+ # Create a list of compatible game versions based on the branch
34+ if [[ $MC_VERSION == "1.19" ]]; then
35+ echo "game_versions=1.19,1.19.1,1.19.2,1.19.3,1.19.4" >> $GITHUB_OUTPUT
36+ elif [[ $MC_VERSION == "1.20" ]]; then
37+ echo "game_versions=1.20,1.20.1,1.20.2,1.20.3,1.20.4" >> $GITHUB_OUTPUT
38+ elif [[ $MC_VERSION == "1.21" ]]; then
39+ echo "game_versions=1.21,1.21.1" >> $GITHUB_OUTPUT
40+ elif [[ $MC_VERSION == "1.18" ]]; then
41+ echo "game_versions=1.18,1.18.1,1.18.2" >> $GITHUB_OUTPUT
42+ else
43+ echo "game_versions=$MC_VERSION" >> $GITHUB_OUTPUT
44+ fi
45+ else
46+ echo "Could not determine Minecraft version from branch name: $BRANCH_NAME"
47+ exit 1
48+ fi
49+
50+ - name : Build with Maven
51+ run : mvn clean package -DskipTests
52+
53+ - name : Get artifact info
54+ id : artifact
55+ run : |
56+ echo "jar_path=$(find target/ -name 'MinecraftServerAPI-*.jar' | head -n 1)" >> $GITHUB_OUTPUT
57+ echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
58+
59+ - name : Upload to Modrinth & Curseforge
60+ uses : Kir-Antipov/mc-publish@v3.3
61+ with :
62+ modrinth-id : H4i6sdRk
63+ modrinth-token : ${{ secrets.MODRINTH_TOKEN }}
64+
65+ curseforge-id : 1101540
66+ curseforge-token : ${{ secrets.CURSEFORGE_TOKEN }}
67+
68+ files : ${{ steps.artifact.outputs.jar_path }}
69+
70+ name : MinecraftServerAPI ${GITHUB_REF_NAME}
71+ version : ${GITHUB_REF_NAME}-${{ steps.artifact.outputs.version }}
72+ version-type : release
73+ game-versions : ${{ steps.extract_branch.outputs.game_versions }}
74+ loaders : |
75+ paper
76+ spigot
77+ bukkit
78+ changelog : |
79+ See [GitHub Release](${{ github.event.release.html_url }}) for changelog.
0 commit comments