@@ -3,100 +3,9 @@ name: Mod Build
33on : [ workflow_dispatch, push ]
44
55jobs :
6- build :
7- runs-on : ubuntu-latest
6+ mod_build :
87 permissions :
8+ contents : read
99 packages : write
10-
11- steps :
12- - uses : actions/checkout@v4
13- with :
14- fetch-depth : 200
15- - name : Set up JDK 17
16- uses : actions/setup-java@v4
17- with :
18- java-version : 17
19- distribution : zulu
20- cache : gradle
21- - name : Build with Gradle
22- env :
23- USERNAME : ${{ secrets.USERNAME }}
24- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
25- uses : nick-invision/retry@v3
26- with :
27- timeout_minutes : 10
28- max_attempts : 3
29- command : ./gradlew build
30- - name : Publish to Github Packages
31- env :
32- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
33- run : ./gradlew build publish
34- - name : Cleanup old artifacts
35- uses : actions/delete-package-versions@v5
36- with :
37- package-name : ' sophisticatedstorageinmotion.sophisticatedstorageinmotion'
38- package-type : ' maven'
39- min-versions-to-keep : 10
40- continue-on-error : true
41- - name : Publish to CurseForge
42- env :
43- CURSEFORGE_TOKEN : ${{ secrets.CURSEFORGE_TOKEN }}
44- run : |
45- BRANCH_NAME=${GITHUB_REF##*/}
46- if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.([0-9]+|x)$ ]]; then
47- ./gradlew curseforge
48- else
49- echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping CurseForge upload."
50- exit 0
51- fi
52- - name : Publish to Modrinth
53- env :
54- MODRINTH_TOKEN : ${{ secrets.MODRINTH_TOKEN }}
55- run : |
56- BRANCH_NAME=${GITHUB_REF##*/}
57- if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.([0-9]+|x)$ ]]; then
58- ./gradlew modrinth
59- else
60- echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping Modrinth upload."
61- exit 0
62- fi
63- - name : Code Quality
64- env :
65- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66- run : ./gradlew -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dsonar.organization=p3pp3rf1y-github sonarqube
67- - name : Retrieve Version
68- run : |
69- echo "$(${{github.workspace}}/gradlew -q printVersionName | awk -F "version:" '{printf $2}')"
70- echo "VERSION_NAME=$(${{github.workspace}}/gradlew -q printVersionName | awk -F "version:" '{printf $2}')" >> $GITHUB_OUTPUT
71- id : version
72- - name : Compile version message
73- uses : actions/github-script@v7
74- with :
75- script : |
76- const gh = ${{ toJSON(github) }};
77-
78- core.setOutput('EMBED_TITLE', "[" + gh.event.repository.name + ":" + gh.ref_name +"] new build ${{steps.version.outputs.VERSION_NAME}}");
79- core.setOutput('EMBED_URL', "https://github.com/P3pp3rF1y/SophisticatedStorage/packages/1388832?version=${{steps.version.outputs.VERSION_NAME}}");
80- core.setOutput('EMBED_AUTHOR_NAME', gh.event.sender.login);
81- core.setOutput('EMBED_AUTHOR_ICON_URL', gh.event.sender.avatar_url);
82-
83- const commits = ${{ toJSON(github.event.commits) }};
84- let description = "";
85- for (const commit of commits) {
86- if (description.length !== 0) {
87- description += "\n";
88- }
89- description += "[" + commit.id.slice(0,7) + "](<" + commit.url + ">) " + commit.message + " - " + commit.author.username;
90- }
91- core.setOutput('EMBED_DESCRIPTION', description);
92- id : embed
93- - name : Send Discord Notification
94- uses : tsickert/discord-webhook@v6.0.0
95- with :
96- webhook-url : ${{ secrets.DISCORD_WEBHOOK }}
97- embed-title : " ${{steps.embed.outputs.EMBED_TITLE}}"
98- embed-url : " ${{steps.embed.outputs.EMBED_URL}}"
99- embed-description : " ${{steps.embed.outputs.EMBED_DESCRIPTION}}"
100- embed-author-name : " ${{steps.embed.outputs.EMBED_AUTHOR_NAME}}"
101- embed-author-icon-url : " ${{steps.embed.outputs.EMBED_AUTHOR_ICON_URL}}"
102- embed-color : 58633
10+ uses : P3pp3rF1y/MultiWorkspace/.github/workflows/mod-build-template.yml@1.20.x
11+ secrets : inherit
0 commit comments