-
-
Notifications
You must be signed in to change notification settings - Fork 16
154 lines (136 loc) · 5.21 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Publish Release
run-name: "Publish release from ${{ github.ref_name }} branch"
permissions:
# Needed to push the tag.
contents: write
# Needed to close the milestone.
issues: write
on:
workflow_dispatch:
inputs:
close_milestone:
description: "Close milestone"
required: true
type: boolean
default: true
upload_backups:
description: "Upload to backups server"
required: true
type: boolean
default: true
publish_github:
description: "Publish to GitHub"
required: true
type: boolean
default: true
publish_curseforge:
description: "Publish to CurseForge"
required: true
type: boolean
default: true
publish_modrinth:
description: "Publish to Modrinth"
required: true
type: boolean
default: true
update_website:
description: "Update wimods.net post (only works if there already is one and publish_curseforge is true)"
required: false
type: boolean
default: false
jobs:
publish:
runs-on: ubuntu-latest
env:
WI_BACKUPS_API_KEY: ${{ secrets.WI_BACKUPS_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Include all tags in case the new tag already exists.
fetch-tags: true
- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "microsoft"
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build
run: ./gradlew build --stacktrace --warning-mode=fail
- name: Create and push tag
run: |
MOD_VERSION=$(grep "^mod_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
git config --global user.name "Wurst-Bot"
git config --global user.email "[email protected]"
git tag "v$MOD_VERSION"
git push origin "v$MOD_VERSION"
- name: Close milestone
if: ${{ inputs.close_milestone }}
run: ./gradlew closeMilestone --stacktrace
- name: Upload backups
if: ${{ inputs.upload_backups }}
run: ./gradlew uploadBackups --stacktrace
- name: Publish to GitHub
if: ${{ inputs.publish_github }}
env:
GITHUB_TOKEN: ${{ secrets.MCX_PUBLISH_TOKEN }}
run: ./gradlew github --stacktrace
- name: Publish to CurseForge
if: ${{ inputs.publish_curseforge }}
run: ./gradlew publishCurseforge --stacktrace
- name: Get CurseForge file ID
id: cf_file_id
if: ${{ inputs.publish_curseforge }}
run: |
file_id=$(./gradlew getCurseforgeId -x publishCurseforge | grep -o 'CURSEFORGE_FILE_ID=[0-9]*' | grep -o '[0-9]*')
echo "file_id=$file_id" >> "$GITHUB_OUTPUT"
echo "CurseForge file ID: \`$file_id\`" >> $GITHUB_STEP_SUMMARY
- name: Publish to Modrinth
if: ${{ inputs.publish_modrinth }}
run: ./gradlew publishModrinth --stacktrace
- name: Build website update inputs
id: website_inputs
if: ${{ inputs.update_website && inputs.publish_curseforge }}
run: |
MOD_VERSION=$(grep "^mod_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r' | sed 's/-MC.*$//')
MC_VERSION=$(grep "^minecraft_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
FAPI_VERSION=$(grep "^fabric_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
JSON_STRING=$(cat << EOF
{
"mod": "mo-glass",
"modloader": "fabric",
"mod_version": "$MOD_VERSION",
"mc_version": "$MC_VERSION",
"fapi_version": "$FAPI_VERSION",
"file_id": "${{ steps.cf_file_id.outputs.file_id }}"
}
EOF
)
# Convert to single line and escape quotes
echo "json=${JSON_STRING//$'\n'/}" >> "$GITHUB_OUTPUT"
- name: Trigger website update
id: website_dispatch
if: ${{ inputs.update_website && inputs.publish_curseforge }}
uses: codex-/return-dispatch@v2
with:
token: ${{ secrets.WIMODS_NET_PUBLISH_TOKEN }}
owner: Wurst-Imperium
repo: wimods.net
ref: master
workflow: add_mod_port.yml
workflow_inputs: ${{ steps.website_inputs.outputs.json }}
- name: Wait for website update to finish (run ${{ steps.website_dispatch.outputs.run_id }})
if: ${{ inputs.update_website && inputs.publish_curseforge }}
uses: codex-/await-remote-run@v1
with:
token: ${{ secrets.WIMODS_NET_PUBLISH_TOKEN }}
owner: Wurst-Imperium
repo: wimods.net
run_id: ${{ steps.website_dispatch.outputs.run_id }}
run_timeout_seconds: 600 # 10 minutes