@@ -5,6 +5,32 @@ name: Publish Release
55
66on :
77 workflow_dispatch :
8+ inputs :
9+ abort_on_tag_conflict :
10+ description : ' Abort if tag already exists'
11+ required : true
12+ type : boolean
13+ default : true
14+ publish_github_packages :
15+ description : ' Publish to GitHub Packages'
16+ required : true
17+ type : boolean
18+ default : true
19+ publish_modrinth :
20+ description : ' Publish to Modrinth'
21+ required : true
22+ type : boolean
23+ default : true
24+ publish_curseforge :
25+ description : ' Publish to CurseForge'
26+ required : true
27+ type : boolean
28+ default : true
29+ publish_github_release :
30+ description : ' Publish GitHub Release'
31+ required : true
32+ type : boolean
33+ default : true
834
935env :
1036 JAVA_VERSION : 21
@@ -37,22 +63,25 @@ jobs:
3763 echo "Extracted minecraft version: $MC_VERSION"
3864 echo "Tag will be: $TAG"
3965
40- - name : ❌ Check if tag already exists
41- run : |
42- if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.version.outputs.tag }}$"; then
43- echo "❌ Tag ${{ steps.version.outputs.tag }} already exists!"
44- echo "Please update the mod_version in gradle.properties to create a new release."
45- exit 1
46- fi
47- echo "✅ Tag ${{ steps.version.outputs.tag }} does not exist, proceeding..."
48-
4966 - name : 🏷️ Create and push tag
5067 run : |
5168 git config user.name "github-actions[bot]"
5269 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
53- git tag ${{ steps.version.outputs.tag }}
54- git push origin ${{ steps.version.outputs.tag }}
55- echo "✅ Created and pushed tag: ${{ steps.version.outputs.tag }}"
70+
71+ # Check if tag already exists remotely
72+ if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.version.outputs.tag }}$"; then
73+ if [ "${{ inputs.abort_on_tag_conflict }}" = "true" ]; then
74+ echo "❌ Tag ${{ steps.version.outputs.tag }} already exists!"
75+ echo "Please update the mod_version in gradle.properties to create a new release."
76+ exit 1
77+ else
78+ echo "⚠️ Tag ${{ steps.version.outputs.tag }} already exists, skipping tag creation"
79+ fi
80+ else
81+ git tag ${{ steps.version.outputs.tag }}
82+ git push origin ${{ steps.version.outputs.tag }}
83+ echo "✅ Created and pushed tag: ${{ steps.version.outputs.tag }}"
84+ fi
5685
5786 - name : 🛂 Validate Gradle wrapper
5887 uses : gradle/actions/wrapper-validation@v4
@@ -111,29 +140,33 @@ jobs:
111140 path : ' **/build/reports/'
112141
113142 - name : 📤 Publish to GitHub Packages
143+ if : inputs.publish_github_packages
114144 env :
115145 GITHUB_ACTOR : ${{ github.actor }}
116146 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117147 IS_PIPELINE : true
118148 run : gradle publishMavenJavaPublicationToGitHubRepository
119149
120150 - name : 📤 Publish to Modrinth
151+ if : inputs.publish_modrinth
121152 env :
122153 MODRINTH : ${{ secrets.MODRINTH }}
123154 IS_PIPELINE : true
124155 run : gradle publishModrinth
125156
126157 - name : 📤 Publish to CurseForge
158+ if : inputs.publish_curseforge
127159 env :
128160 CURSEFORGE : ${{ secrets.CURSEFORGE }}
129161 IS_PIPELINE : true
130162 run : gradle publishCurseforge
131163
132164 - name : 📤 Create GitHub Release
165+ if : inputs.publish_github_release
133166 env :
134167 GITHUB : ${{ secrets.GITHUB_TOKEN }}
135168 IS_PIPELINE : true
136- run : gradle publishGithub
169+ run : gradle publishGitHub
137170
138171 - name : 🧨 Cleanup Gradle cache
139172 run : |
0 commit comments