generated from Fallen-Breath/fabric-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 13
202 lines (171 loc) · 7.12 KB
/
release.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Release
# release: <default> (release title)
# dispatch (all): Manual release for $target_release_tag
# dispatch (specified): Manual release for $target_release_tag (subproject: $target_subproject)
run-name: |-
${{ github.event_name == 'workflow_dispatch' && format('Manual release for {0}{1}', inputs.target_release_tag, inputs.target_subproject && format(' (subproject: {0})', inputs.target_subproject) || '') || '' }}
on:
release:
types:
- published
workflow_dispatch:
inputs:
target_subproject:
description: |-
The subproject name(s) of the specified Minecraft version to be released, seperated with ",".
By default all subprojects will be released
type: string
required: false
default: ''
target_release_tag:
description: The tag of the release you want to append the artifact to
type: string
required: true
jobs:
show_action_parameters:
runs-on: ubuntu-latest
steps:
- name: Show action parameters
run: |
cat <<EOF > $GITHUB_STEP_SUMMARY
## Action Parameters
- target_subproject: \`${{ github.event.inputs.target_subproject }}\`
- target_release_tag: \`${{ github.event.inputs.target_release_tag }}\`
EOF
matrix_prep:
uses: ./.github/workflows/matrix_prep.yml
with:
target_subproject: ${{ github.event.inputs.target_subproject }}
# ensure the input release tag is valid
validate_release:
runs-on: ubuntu-latest
steps:
- name: Get github release information
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: cardinalby/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ github.event.inputs.target_release_tag }}
build:
uses: ./.github/workflows/build.yml
secrets: inherit
needs:
- validate_release
with:
target_subproject: ${{ github.event.inputs.target_subproject }}
release: true
release:
needs:
- matrix_prep
- build
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Display context
run: |
echo ref_name = ${{ github.ref_name }}
echo target_subproject = ${{ github.event.inputs.target_subproject }}
echo target_release_tag = ${{ github.event.inputs.target_release_tag }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: build-artifacts
- name: Get github release information
if: ${{ github.event_name == 'workflow_dispatch' }}
id: get_release
uses: cardinalby/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ github.event.inputs.target_release_tag }}
- name: Generate publish related information
id: release_info
run: |
if [ $GITHUB_EVENT_NAME == 'release' ]
then
# Leave an empty value here, so Kir-Antipov/mc-publish will infer the tag from the action context
echo "tag_name=" >> $GITHUB_OUTPUT
elif [ $GITHUB_EVENT_NAME == 'workflow_dispatch' ]
then
echo "tag_name=${{ github.event.inputs.target_release_tag }}" >> $GITHUB_OUTPUT
else
echo Unknown github event name $GITHUB_EVENT_NAME
exit 1
fi
- name: Read common properties
id: properties_g
uses: christian-draeger/[email protected]
with:
path: gradle.properties
properties: 'mod_name mod_version'
- name: Read version-specific properties
id: properties_v
uses: christian-draeger/[email protected]
with:
path: ${{ format('versions/{0}/gradle.properties', matrix.subproject) }}
properties: 'minecraft_version game_versions'
- name: Fix game version
id: game_versions
run: |
# Fixed \n in game_versions isn't parsed by christian-draeger/read-properties as a line separator
echo 'value<<EOF' >> $GITHUB_OUTPUT
echo -e "${{ steps.properties_v.outputs.game_versions }}" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Prepare file information
id: file_info
run: |
shopt -s extglob
FILE_PATHS=$(ls ${{ format('build-artifacts/{0}/build/libs/!(*-@(dev|sources|shadow)).jar', matrix.subproject) }})
if (( ${#FILE_PATHS[@]} != 1 )); then
echo "Error: Found ${#FILE_PATHS[@]} files, expected exactly 1"
exit 1
else
FILE_PATH=${FILE_PATHS[0]}
fi
FILE_NAME=$(basename $FILE_PATH)
FILE_HASH=$(sha256sum $FILE_PATH | awk '{ print $1 }')
echo "path=$FILE_PATH" >> $GITHUB_OUTPUT
echo "name=$FILE_NAME" >> $GITHUB_OUTPUT
echo "hash=$FILE_HASH" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: Prepare changelog
uses: actions/github-script@v6
id: changelog
with:
script: return process.env.CHANGELOG
result-encoding: string
env:
CHANGELOG: |-
${{ format('{0}{1}', github.event.release.body, steps.get_release.outputs.body) }}
-------
Build Information
- File name: `${{ steps.file_info.outputs.name }}`
- SHA-256: `${{ steps.file_info.outputs.hash }}`
- Built from: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Publish Minecraft Mods
uses: Kir-Antipov/[email protected]
with:
modrinth-id: GBeCx05I # https://modrinth.com/mod/tweakermore
modrinth-token: ${{ secrets.MODRINTH_API_TOKEN }}
curseforge-id: 531235 # https://legacy.curseforge.com/minecraft/mc-mods/tweakermore
curseforge-token: ${{ secrets.CF_API_TOKEN }}
github-tag: ${{ steps.release_info.outputs.tag_name }}
github-token: ${{ secrets.GITHUB_TOKEN }}
files: ${{ steps.file_info.outputs.path }}
name: ${{ format('{0} v{1} for mc{2}', steps.properties_g.outputs.mod_name, steps.properties_g.outputs.mod_version, steps.properties_v.outputs.minecraft_version) }}
version: ${{ format('mc{0}-v{1}', steps.properties_v.outputs.minecraft_version, steps.properties_g.outputs.mod_version) }}
version-type: release
loaders: fabric
game-versions: ${{ steps.game_versions.outputs.value }}
game-version-filter: any
dependencies: | # declare the dependencies explicitly, so mc-publish won't try to load from fabric.mod.json
malilib(required)
github-changelog: ${{ format('{0}{1}', github.event.release.body, steps.get_release.outputs.body) }}
modrinth-changelog: ${{ steps.changelog.outputs.result }}
curseforge-changelog: ${{ steps.changelog.outputs.result }}
retry-attempts: 3
retry-delay: 10000