|
1 | | -name: curseforge-modrinth-publish |
2 | 1 |
|
3 | | -run-name: Posting jars on Curseforge and Modrinth |
4 | | - |
5 | | -on: |
6 | | - release: |
7 | | - types: [ published ] |
8 | | - |
9 | | -jobs: |
10 | | - publish: |
11 | | - runs-on: ubuntu-22.04 |
12 | | - steps: |
13 | | - - name: fetching asset paths |
14 | | - id: assets |
15 | | - shell: bash |
16 | | - run: | |
17 | | - echo Attachments |
18 | | - fileNames=(${{ github.event.release.assets[0].name }} ${{ github.event.release.assets[1].name }} ${{ github.event.release.assets[2].name }}) |
19 | | - filePaths=(${{ github.event.release.assets[0].browser_download_url }} ${{ github.event.release.assets[1].browser_download_url }} ${{ github.event.release.assets[2].browser_download_url }}) |
20 | | - |
21 | | - for i in 0 1 2 3 |
22 | | - do |
23 | | - echo "${fileNames[i]}" |
24 | | - echo "${filePaths[i]}" |
25 | | - if [ -n "${filePaths[i]}" ]; then |
26 | | - curl -L -o "./${fileNames[i]}" "${filePaths[i]}" |
27 | | - fi |
28 | | - |
29 | | - if [[ "${fileNames[i]}" == *"fabric"* ]]; then |
30 | | - echo "FABRIC_FILE_NAME=${fileNames[i]}" >> $GITHUB_OUTPUT |
31 | | - echo "FABRIC_FILE_PATH=./${fileNames[i]}" >> $GITHUB_OUTPUT |
32 | | - elif [[ "${fileNames[i]}" == *"neoforge"* ]]; then |
33 | | - echo "NEOFORGE_FILE_NAME=${fileNames[i]}" >> $GITHUB_OUTPUT |
34 | | - echo "NEOFORGE_FILE_PATH=./${fileNames[i]}" >> $GITHUB_OUTPUT |
35 | | - elif [[ "${fileNames[i]}" == *"forge"* ]]; then |
36 | | - echo "FORGE_FILE_NAME=${fileNames[i]}" >> $GITHUB_OUTPUT |
37 | | - echo "FORGE_FILE_PATH=./${fileNames[i]}" >> $GITHUB_OUTPUT |
38 | | - elif [[ "${fileNames[i]}" == *"quilt"* ]]; then |
39 | | - echo "QUILT_FILE_NAME=${fileNames[i]}" >> $GITHUB_OUTPUT |
40 | | - echo "QUILT_FILE_PATH=./${fileNames[i]}" >> $GITHUB_OUTPUT |
41 | | - fi |
42 | | - done |
43 | | - ls -l |
44 | | - - run: echo "fabric is ${{ steps.assets.outputs.FABRIC_FILE_NAME }}" |
45 | | - - run: echo "neoforge is ${{ steps.assets.outputs.NEOFORGE_FILE_NAME }}" |
46 | | - - run: echo "forge is ${{ steps.assets.outputs.FORGE_FILE_NAME }}" |
47 | | - - run: echo "quilt is ${{ steps.assets.outputs.QUILT_FILE_NAME }}" |
48 | | - |
49 | | - - name: getting version info from files |
50 | | - id: version |
51 | | - shell: bash |
52 | | - run: | |
53 | | - parse_fabric () { |
54 | | - unzip -o -j "$1" "$2" -d ./fabric |
55 | | - deps=false |
56 | | - bracket=false |
57 | | - parsedVersion="" |
58 | | - depReg='\s+"depends"' |
59 | | - minecraftVersionReg='\s*?"minecraft":\s*?(.+?)*' |
60 | | - wordReg="(.*?),*" |
61 | | - bracketReg="(.*])" |
62 | | - while read -r; do |
63 | | - if [[ $REPLY =~ $depReg ]]; then |
64 | | - deps=true |
65 | | - elif [[ $REPLY =~ $minecraftVersionReg && $deps == "true" ]]; then |
66 | | - if [[ ${BASH_REMATCH[1]} =~ $wordReg ]]; then |
67 | | - parsedVersion=${BASH_REMATCH[1]} |
68 | | - if [[ ${BASH_REMATCH[1]} == "[" ]]; then |
69 | | - bracket=true |
70 | | - fi |
71 | | - fi |
72 | | - elif [[ $bracket == "true" && $REPLY != *"]"* ]]; then |
73 | | - parsedVersion=${parsedVersion}$REPLY |
74 | | - elif [[ $bracket == "true" && $REPLY =~ $bracketReg ]]; then |
75 | | - parsedVersion=${parsedVersion}${BASH_REMATCH[1]} |
76 | | - bracket=false |
77 | | - fi |
78 | | - done < ./fabric/$2 |
79 | | - } |
80 | | - parse_forge () { |
81 | | - unzip -o -j "$1" "META-INF/$2" -d ./forge |
82 | | - minecraftDep=false |
83 | | - minecraftIdReg='modId\s+=\s+"minecraft"' |
84 | | - versionRangeReg='versionRange\s+=\s+"(.+?)"' |
85 | | - while read -r; do |
86 | | - if [[ $REPLY =~ $minecraftIdReg ]]; then |
87 | | - minecraftDep=true |
88 | | - echo "$REPLY" |
89 | | - elif [[ $REPLY =~ $versionRangeReg && $minecraftDep == "true" ]]; then |
90 | | - parsedVersion="${BASH_REMATCH[1]}" |
91 | | - echo "${BASH_REMATCH[0]}" |
92 | | - echo "${BASH_REMATCH[1]}" |
93 | | - fi |
94 | | - done < ./forge/$2 |
95 | | - } |
96 | | - file="" |
97 | | - if [ -n "${{ steps.assets.outputs.FABRIC_FILE_NAME }}" ]; then |
98 | | - file="${{ steps.assets.outputs.FABRIC_FILE_NAME }}" |
99 | | - elif [ -n "${{ steps.assets.outputs.FORGE_FILE_NAME }}" ]; then |
100 | | - file="${{ steps.assets.outputs.FORGE_FILE_NAME }}" |
101 | | - elif [ -n "${{ steps.assets.outputs.NEOFORGE_FILE_NAME }}" ]; then |
102 | | - file="${{ steps.assets.outputs.NEOFORGE_FILE_NAME }}" |
103 | | - else |
104 | | - file="${{ steps.assets.outputs.QUILT_FILE_NAME }}" |
105 | | - fi |
106 | | - echo "$file" |
107 | | - |
108 | | - # save the current IFS value |
109 | | - OLDIFS=$IFS |
110 | | - # set the IFS to the delimiter ("-") |
111 | | - IFS="-" |
112 | | - # split the string into an array, limiting it to a maximum of 3 fields |
113 | | - array=($file) |
114 | | - # restore the IFS value |
115 | | - IFS=$OLDIFS |
116 | | - |
117 | | - # alphas or beats should be included in the version |
118 | | - if [ ${array[3]:0:1} = "a" ] || [ ${array[3]:0:1} = "b" ]; then |
119 | | - array[2]=${array[2]}-${array[3]} |
120 | | - fi |
121 | | - |
122 | | - release_type="release" |
123 | | - if [ ${array[3]:0:1} = "a" ]; then |
124 | | - release_type="alpha" |
125 | | - elif [ ${array[3]:0:1} = "b" ]; then |
126 | | - release_type="beta" |
127 | | - fi |
128 | | - |
129 | | - echo "release type: ${release_type}" |
130 | | - echo "RELEASE_TYPE=${release_type}" >> $GITHUB_OUTPUT |
131 | | - |
132 | | - mc_version=${array[1]} |
133 | | - |
134 | | - # mod loaders |
135 | | - loaders_fabric=fabric |
136 | | - # check if there is a quilt specific jar |
137 | | - if [ -z "${{ steps.assets.outputs.QUILT_FILE_NAME }}" ]; then |
138 | | - loaders_fabric="${loaders_fabric} quilt" |
139 | | - else |
140 | | - loaders_quilt="quilt" |
141 | | - fi |
142 | | - loaders_forge="forge" |
143 | | - loaders_neoforge="neoforge" |
144 | | - |
145 | | - if [ -n "${{ steps.assets.outputs.FABRIC_FILE_NAME }}" ]; then |
146 | | - parse_fabric ${{ steps.assets.outputs.FABRIC_FILE_NAME }} "fabric.mod.json" |
147 | | - echo "FABRIC_MC_VERSIONS="${parsedVersion}"" >> $GITHUB_OUTPUT |
148 | | - fi |
149 | | - if [ -n "${{ steps.assets.outputs.FORGE_FILE_NAME }}" ]; then |
150 | | - parse_forge ${{ steps.assets.outputs.FORGE_FILE_NAME }} "mods.toml" |
151 | | - echo "FORGE_MC_VERSIONS="${parsedVersion}"" >> $GITHUB_OUTPUT |
152 | | - fi |
153 | | - if [ -n "${{ steps.assets.outputs.NEOFORGE_FILE_NAME }}" ]; then |
154 | | - parse_forge ${{ steps.assets.outputs.NEOFORGE_FILE_NAME }} "neoforge.mods.toml" |
155 | | - echo "NEOFORGE_MC_VERSIONS="${parsedVersion}"" >> $GITHUB_OUTPUT |
156 | | - fi |
157 | | - if [ -n "${{ steps.assets.outputs.QUILT_FILE_NAME }}" ]; then |
158 | | - parse_fabric ${{ steps.assets.outputs.QUILT_FILE_NAME }} "quilt.mod.json" |
159 | | - echo "QUILT_MC_VERSIONS="${parsedVersion}"" >> $GITHUB_OUTPUT |
160 | | - fi |
161 | | - |
162 | | - echo "loaders fabric: ${loaders_fabric}" |
163 | | - echo "LOADERS_FABRIC=${loaders_fabric}" >> $GITHUB_OUTPUT |
164 | | - |
165 | | - echo "loaders forge: ${loaders_forge}" |
166 | | - echo "LOADERS_FORGE=${loaders_forge}" >> $GITHUB_OUTPUT |
167 | | - echo "loaders neoforge: ${loaders_neoforge}" |
168 | | - echo "LOADERS_NEOFORGE=${loaders_neoforge}" >> $GITHUB_OUTPUT |
169 | | - |
170 | | - echo "loaders quilt: ${loaders_quilt}" |
171 | | - echo "LOADERS_QUILT=${loaders_quilt}" >> $GITHUB_OUTPUT |
172 | | - |
173 | | - mod_name="${array[0]^} $mc_version-${array[2]}" |
174 | | - echo "file name fabric: '${mod_name}-fabric'" |
175 | | - echo "VERSION_NAME_FABRIC=${mod_name}-fabric" >> $GITHUB_OUTPUT |
176 | | - echo "file name forge: '${mod_name}-forge'" |
177 | | - echo "VERSION_NAME_FORGE=${mod_name}-forge" >> $GITHUB_OUTPUT |
178 | | - echo "file name neoforge: '${mod_name}-neoforge'" |
179 | | - echo "VERSION_NAME_NEOFORGE=${mod_name}-neoforge" >> $GITHUB_OUTPUT |
180 | | - echo "file name quilt: '${mod_name}-quilt'" |
181 | | - echo "VERSION_NAME_QUILT=${mod_name}-quilt" >> $GITHUB_OUTPUT |
182 | | - |
183 | | - # modrinth mod versions |
184 | | - base_version="$mc_version-${array[2]}" |
185 | | - echo "MOD_VERSION_FABRIC=${base_version}-fabric" >> $GITHUB_OUTPUT |
186 | | - echo "MOD_VERSION_FORGE=${base_version}-forge" >> $GITHUB_OUTPUT |
187 | | - echo "MOD_VERSION_NEOFORGE=${base_version}-neoforge" >> $GITHUB_OUTPUT |
188 | | - echo "MOD_VERSION_QUILT=${base_version}-quilt" >> $GITHUB_OUTPUT |
189 | | - echo "MOD_VERSION=${base_version}" >> $GITHUB_OUTPUT |
190 | | -
|
191 | | - - run: echo "release type is ${{ steps.version.outputs.RELEASE_TYPE }}" |
192 | | - |
193 | | - - run: echo "fabric mc versions are ${{ steps.version.outputs.FABRIC_MC_VERSIONS }}" |
194 | | - - run: echo "fabric mod version ${{ steps.version.outputs.MOD_VERSION_FABRIC }}" |
195 | | - |
196 | | - - run: echo "forge mc versions are ${{ steps.version.outputs.FORGE_MC_VERSIONS }}" |
197 | | - - run: echo "forge mod version ${{ steps.version.outputs.MOD_VERSION_FORGE }}" |
198 | | - |
199 | | - - run: echo "neoforge mc versions are ${{ steps.version.outputs.NEOFORGE_MC_VERSIONS }}" |
200 | | - - run: echo "neoforge mod version ${{ steps.version.outputs.MOD_VERSION_NEOFORGE }}" |
201 | | - |
202 | | - - run: echo "quilt mc versions are ${{ steps.version.outputs.QUILT_MC_VERSIONS }}" |
203 | | - - run: echo "quilt mod version ${{ steps.version.outputs.MOD_VERSION_QUILT }}" |
204 | | - |
205 | | - - name: publish fabric |
206 | | - if: steps.assets.outputs.FABRIC_FILE_PATH != '' |
207 | | - uses: Kir-Antipov/[email protected] |
208 | | - with: |
209 | | - modrinth-id: wGoQDPN5 |
210 | | - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} |
211 | | - modrinth-featured: false |
212 | | - |
213 | | - curseforge-id: 667903 |
214 | | - curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} |
215 | | - |
216 | | - files: ${{ steps.assets.outputs.FABRIC_FILE_PATH }} |
217 | | - |
218 | | - name: "${{ steps.version.outputs.VERSION_NAME_FABRIC }}" |
219 | | - version: "${{ steps.version.outputs.MOD_VERSION_FABRIC }}" |
220 | | - version-type: "${{ steps.version.outputs.RELEASE_TYPE }}" |
221 | | - |
222 | | - loaders: "${{ steps.version.outputs.LOADERS_FABRIC }}" |
223 | | - #game-versions: "${{ steps.version.outputs.FABRIC_MC_VERSIONS }}" |
224 | | - |
225 | | - - name: publish forge |
226 | | - if: steps.assets.outputs.FORGE_FILE_PATH != '' |
227 | | - uses: Kir-Antipov/[email protected] |
228 | | - with: |
229 | | - modrinth-id: wGoQDPN5 |
230 | | - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} |
231 | | - modrinth-featured: false |
232 | | - |
233 | | - curseforge-id: 667903 |
234 | | - curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} |
235 | | - |
236 | | - files: ${{ steps.assets.outputs.FORGE_FILE_PATH }} |
237 | | - |
238 | | - name: "${{ steps.version.outputs.VERSION_NAME_FORGE }}" |
239 | | - version: "${{ steps.version.outputs.MOD_VERSION_FORGE }}" |
240 | | - version-type: "${{ steps.version.outputs.RELEASE_TYPE }}" |
241 | | - |
242 | | - loaders: "${{ steps.version.outputs.LOADERS_FORGE}}" |
243 | | - #game-versions: "${{ steps.version.outputs.FORGE_MC_VERSIONS }}" |
244 | | - |
245 | | - - name: publish neoforge |
246 | | - if: steps.assets.outputs.NEOFORGE_FILE_PATH != '' |
247 | | - uses: Kir-Antipov/[email protected] |
248 | | - with: |
249 | | - modrinth-id: wGoQDPN5 |
250 | | - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} |
251 | | - modrinth-featured: false |
252 | | - |
253 | | - curseforge-id: 667903 |
254 | | - curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} |
255 | | - |
256 | | - files: ${{ steps.assets.outputs.NEOFORGE_FILE_PATH }} |
257 | | - |
258 | | - name: "${{ steps.version.outputs.VERSION_NAME_NEOFORGE }}" |
259 | | - version: "${{ steps.version.outputs.MOD_VERSION_NEOFORGE }}" |
260 | | - version-type: "${{ steps.version.outputs.RELEASE_TYPE }}" |
261 | | - |
262 | | - loaders: "${{ steps.version.outputs.LOADERS_NEOFORGE}}" |
263 | | - #game-versions: "${{ steps.version.outputs.FORGE_MC_VERSIONS }}" |
264 | | - |
265 | | - - name: publish quilt |
266 | | - if: steps.assets.outputs.QUILT_FILE_PATH != '' |
267 | | - uses: Kir-Antipov/[email protected] |
268 | | - with: |
269 | | - modrinth-id: wGoQDPN5 |
270 | | - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} |
271 | | - modrinth-featured: false |
272 | | - |
273 | | - curseforge-id: 667903 |
274 | | - curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} |
275 | | - |
276 | | - files: ${{ steps.assets.outputs.QUILT_FILE_PATH }} |
277 | | - |
278 | | - name: "${{ steps.version.outputs.VERSION_NAME_QUILT }}" |
279 | | - version: "${{ steps.version.outputs.MOD_VERSION_QUILT}}" |
280 | | - version-type: "${{ steps.version.outputs.RELEASE_TYPE }}" |
281 | | - |
282 | | - loaders: "${{ steps.version.outputs.LOADERS_QUILT}}" |
283 | | - #game-versions: "${{ steps.version.outputs.QUILT_MC_VERSIONS }}" |
284 | | - |
285 | | - # update forge versions json |
286 | | - - name: checkout repo forge-versions |
287 | | - if: steps.assets.outputs.FORGE_FILE_PATH != '' || steps.assets.outputs.NEOFORGE_FILE_PATH != '' |
288 | | - uses: actions/checkout@v4 |
289 | | - with: |
290 | | - ref: 'forge-versions' |
291 | | - |
292 | | - - name: setup python |
293 | | - if: steps.assets.outputs.FORGE_FILE_PATH != '' || steps.assets.outputs.NEOFORGE_FILE_PATH != '' |
294 | | - uses: actions/setup-python@v4 |
295 | | - with: |
296 | | - python-version: '3.10' |
297 | | - |
298 | | - - name: execute py script to update forge json |
299 | | - if: steps.assets.outputs.FORGE_FILE_PATH != '' |
300 | | - run: | |
301 | | - python -c " |
302 | | - import sys, json |
303 | | - print(sys.argv) |
304 | | - mc_version = sys.argv[1] |
305 | | - mod_version = sys.argv[2] |
306 | | - release_type = sys.argv[3] |
307 | | - jsonContent = {} |
308 | | - with open('forge_updates.json', 'r') as infile: |
309 | | - jsonContent = json.load(infile) |
310 | | - for str in mc_version.split(','): |
311 | | - version = str.strip('[]\" ') |
312 | | - if version != '' and version[-1:] != ')' and version[:1] != '(': |
313 | | - jsonContent['promos'][version + '-latest'] = mod_version |
314 | | - print('added ' + version + '-latest:' + mod_version) |
315 | | - if release_type == 'release': |
316 | | - jsonContent['promos'][version + '-recommended'] = mod_version |
317 | | - print('added ' + version + '-recommended:' + mod_version) |
318 | | - print(json.dumps(jsonContent, indent='\t')) |
319 | | - with open('forge_updates.json', 'w') as outfile: |
320 | | - outfile.write(json.dumps(jsonContent, indent='\t')) |
321 | | - " "${{ steps.version.outputs.FORGE_MC_VERSIONS }}" "${{ steps.version.outputs.MOD_VERSION }}" "${{ steps.version.outputs.RELEASE_TYPE }}" |
322 | | -
|
323 | | - - name: execute py script to update neoforge json |
324 | | - if: steps.assets.outputs.NEOFORGE_FILE_PATH != '' |
325 | | - run: | |
326 | | - python -c " |
327 | | - import sys, json |
328 | | - print(sys.argv) |
329 | | - mc_version = sys.argv[1] |
330 | | - mod_version = sys.argv[2] |
331 | | - release_type = sys.argv[3] |
332 | | - jsonContent = {} |
333 | | - with open('neoforge_updates.json', 'r') as infile: |
334 | | - jsonContent = json.load(infile) |
335 | | - for str in mc_version.split(','): |
336 | | - version = str.strip('[]\" ') |
337 | | - if version != '' and version[-1:] != ')' and version[:1] != '(': |
338 | | - jsonContent['promos'][version + '-latest'] = mod_version |
339 | | - print('added ' + version + '-latest:' + mod_version) |
340 | | - if release_type == 'release': |
341 | | - jsonContent['promos'][version + '-recommended'] = mod_version |
342 | | - print('added ' + version + '-recommended:' + mod_version) |
343 | | - print(json.dumps(jsonContent, indent='\t')) |
344 | | - with open('neoforge_updates.json', 'w') as outfile: |
345 | | - outfile.write(json.dumps(jsonContent, indent='\t')) |
346 | | - " "${{ steps.version.outputs.NEOFORGE_MC_VERSIONS }}" "${{ steps.version.outputs.MOD_VERSION }}" "${{ steps.version.outputs.RELEASE_TYPE }}" |
347 | | -
|
348 | | - - name: push new update json forge |
349 | | - if: steps.assets.outputs.FORGE_FILE_PATH != '' && steps.assets.outputs.NEOFORGE_FILE_PATH == '' |
350 | | - uses: EndBug/add-and-commit@v9 |
351 | | - with: |
352 | | - message: 'update forge ${{ steps.version.outputs.FORGE_MC_VERSIONS }} to ${{ steps.version.outputs.MOD_VERSION }}' |
353 | | - push: true |
354 | | - |
355 | | - - name: push new update json neoforge |
356 | | - if: steps.assets.outputs.FORGE_FILE_PATH == '' && steps.assets.outputs.NEOFORGE_FILE_PATH != '' |
357 | | - uses: EndBug/add-and-commit@v9 |
358 | | - with: |
359 | | - message: 'update neoforge ${{ steps.version.outputs.NEOFORGE_MC_VERSIONS }} to ${{ steps.version.outputs.MOD_VERSION }}' |
360 | | - push: true |
361 | | - |
362 | | - - name: push new update json forge+neoforge |
363 | | - if: steps.assets.outputs.FORGE_FILE_PATH != '' && steps.assets.outputs.NEOFORGE_FILE_PATH != '' |
364 | | - uses: EndBug/add-and-commit@v9 |
365 | | - with: |
366 | | - message: 'update forge ${{ steps.version.outputs.FORGE_MC_VERSIONS }} to ${{ steps.version.outputs.MOD_VERSION }} and update neoforge ${{ steps.version.outputs.NEOFORGE_MC_VERSIONS }} to ${{ steps.version.outputs.MOD_VERSION }}' |
367 | | - push: true |
0 commit comments