-
-
Notifications
You must be signed in to change notification settings - Fork 6
293 lines (255 loc) · 9.47 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Copyright (c) 2020 anatawa12 and other contributors
# This file is part of fixRTM, released under GNU LGPL v3 with few exceptions
# See LICENSE at https://github.com/fixrtm/fixRTM for more details
name: Release
on:
workflow_dispatch:
inputs:
release_kind:
type: choice
description: The type of release.
default: prerelease
required: true
options:
- prerelease
- start-rc
- stable
env:
SOMETHING_RELEASER_SEMVER: 1
jobs:
release:
runs-on: ubuntu-latest
environment: deployment
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.PUSH_KEY }}
- uses: anatawa12/something-releaser@v2
- run: set-git-user anatawa12-bot
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
- name: update version name
id: ver_up
run: |
# set version name in properties file
case "$RELEASE_KIND_IN" in
"prerelease" )
set-version "$(version-next "$(get-version)")"
;;
"start-rc" )
set-version "$(version-set-channel "$(get-version)" rc)"
;;
"stable" )
set-version "$(version-set-channel "$(get-version)" stable)"
;;
* )
echo "invalid release kind: $RELEASE_KIND_IN"
exit 255
;;
esac
if [ "$GITHUB_REF_NAME" != "master" ]; then
echo "invalid release kind: $RELEASE_KIND_IN is not allowd for $GITHUB_REF_NAME"
exit 255
fi
gh-export-variable VERSION_NAME "$(get-version)"
gh-export-variable REQUIRED_RTM "$(file-util properties get gradle.properties rtmVersion)"
gh-export-variable REQUIRED_NGTLIB "$(file-util properties get gradle.properties ngtVersion)"
env:
EVENT_NAME: ${{ github.event_name }}
RELEASE_KIND_IN: ${{ github.event.inputs.release_kind }}
- name: compute version kind
id: compute_version_kind
run: |
case "$(version-get-channel $(get-version) 2>/dev/null || echo 'commit')" in
"commit" )
gh-export-variable PRERELEASE true
gh-export-variable NIGHTLY true
;;
"beta" | "candidate" )
gh-export-variable PRERELEASE true
gh-export-variable NIGHTLY false
;;
"stable" )
gh-export-variable PRERELEASE false
gh-export-variable NIGHTLY false
;;
* )
echo "invalid release kind"
exit 255
;;
esac
- name: update version map
id: update_version_map
if: ${{ !fromJSON(env.PRERELEASE) }}
run: |
# update version map
printf "| %-11s | %-14s | %-14s |\n" \
"$REQUIRED_RTM" \
"$REQUIRED_NGTLIB" \
"$VERSION_NAME" \
>> version-map.md
- name: compute output informations
id: compute_output_informations
run: |
asset_path="./build/libs/fixRtm-$VERSION_NAME.jar"
gh-export-variable ASSET_PATH "$asset_path"
# curse info
if $PRERELEASE; then
gh-export-variable CURSE_RELEASE_TYPE "alpha"
else
gh-export-variable CURSE_RELEASE_TYPE "release"
fi
- name: commit
id: commit
if: ${{ !fromJSON(env.NIGHTLY) }}
run: |
if ! $PRERELEASE; then
main_changelog_file_path='CHANGELOG.md'
else
main_changelog_file_path='CHANGELOG-SNAPSHOTS.md'
fi
# first, remove empty section of changelog
! $PRERELEASE && ./.github/workflows/sh/prepare-changelog.sh CHANGELOG.md
./.github/workflows/sh/prepare-changelog.sh CHANGELOG-SNAPSHOTS.md
# then, get release notes for unreleased
unreleased_release_note_path=$(mktemp)
./.github/workflows/sh/get-unreleased-release-note.sh "$main_changelog_file_path" \
> "$unreleased_release_note_path"
# after that, make unreleased -> released
RELEASE_DATE="$(date +%Y-%m-%d)"
# for release, update normal
! $PRERELEASE && ./.github/workflows/sh/update-changelog.sh CHANGELOG.md "$VERSION_NAME" "$RELEASE_DATE"
# for both prerelease and release, update -SNAPSHOTS
./.github/workflows/sh/update-changelog.sh CHANGELOG-SNAPSHOTS.md "$VERSION_NAME" "$RELEASE_DATE"
# create release note for GitHub/CurseForge release page
release_note_path=$(mktemp)
{
if $PRERELEASE; then
echo "**This is SNAPSHOT, not a stable release. make sure this may have many bugs.**"
fi
echo "Requirements for this version: "
echo "RTM $REQUIRED_RTM"
echo "NGTLib $REQUIRED_NGTLIB"
echo ""
cat "$unreleased_release_note_path"
} >> "$release_note_path"
gh-export-variable RELEASE_NOTE_PATH "$release_note_path"
# commit to add updated changelog
git commit -am "chore: bump version to $VERSION_NAME"
git tag "$VERSION_NAME"
- name: prepare patching environment
uses: eskatos/gradle-command-action@v2
with:
arguments: preparePatchingEnvironment
- name: apply patches
run: ./pm.apply-patches
- name: Build
uses: eskatos/gradle-command-action@v2
with:
arguments: build
- name: push releases
id: push_releases
if: ${{ !fromJSON(env.NIGHTLY) }}
run: |
# push
git push
git push origin "$VERSION_NAME"
- uses: actions/upload-artifact@v3
with:
name: jar
path: ${{ env.ASSET_PATH }}
retention-days: 30
- name: Upload To CurseForge
id: upload_curse
if: ${{ !fromJSON(env.NIGHTLY) }}
run: |
# platform version infos
# {"id":6756,"gameVersionTypeID":628,"name":"1.12.2","slug":"1-12-2"},
# {"id":7498,"gameVersionTypeID":68441,"name":"Forge","slug":"forge"},
# {"id":4458,"gameVersionTypeID":2,"name":"Java 8","slug":"java-8"},
# project id for fixRTM is 365235
# see https://www.curseforge.com/minecraft/mc-mods/fixrtm
project_id=365235
publish-to-curse-forge \
--file "$ASSET_PATH" \
--token "$CURSE_TOKEN" \
--project-id "$project_id" \
--changelog-file "$RELEASE_NOTE_PATH" \
--changelog-type "markdown" \
--release-type "$CURSE_RELEASE_TYPE" \
--game-versions "6756" \
--game-versions "7498" \
--game-versions "4458" \
> response.json \
|| { echo "POST to curse forge failed" >&2; exit 255; }
FILE_ID="$(jq '.id' < response.json)"
echo "file_id=$FILE_ID" >> $GITHUB_OUTPUT
env:
CURSE_TOKEN: ${{ secrets.CURSE_TOKEN }}
- name: Upload To GitHub Packages
id: upload_github_packagees
run: |
if $PRERELEASE; then
not_release=--not-release
fi
publish-to-maven \
--file "$ASSET_PATH" \
--group-id "com.anatawa12.fixrtm" \
--artifact-id "fixrtm" \
--version-name "$VERSION_NAME" \
--name "fixrtm" \
--user "fixrtm:$GITHUB_TOKEN" \
--repository "https://maven.pkg.github.com/fixrtm/fixRTM" \
--no-pom \
$not_release
env:
CURSE_TOKEN: ${{ secrets.CURSE_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
- name: Create Release
id: create_release
if: ${{ !fromJSON(env.NIGHTLY) }}
run: |-
gh release create \
"$VERSION_NAME" \
--title "$VERSION_NAME" \
--verify-tag \
--notes-file "$RELEASE_NOTE_PATH" \
${{ fromJSON(env.PRERELEASE) && '--prerelease' || '' }} \
"$ASSET_PATH"
env:
GH_TOKEN: ${{ github.token }}
- name: Send message to discord
id: message_discord
if: ${{ !fromJSON(env.NIGHTLY) }}
run: |
{
echo "fixRTM $VERSION_NAME is released!"
if $PRERELEASE; then
echo "**This is a prerelease, not a stable release. make sure this may have many bugs.**"
fi
echo "Requirements for this version:"
echo "RTM $REQUIRED_RTM"
echo "NGTLib $REQUIRED_NGTLIB"
echo ""
echo "https://www.curseforge.com/minecraft/mc-mods/fixrtm/files/$CURSE_ID"
echo "https://github.com/fixrtm/fixRTM/releases/tag/$VERSION_NAME"
} | send-discord \
-i "$WEBHOOK_ID" \
-t "$WEBHOOK_TOKEN" \
env:
WEBHOOK_ID: ${{ secrets.WEBHOOK_ID }}
WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }}
CURSE_ID: ${{ steps.upload_curse.outputs.file_id }}
- name: create next version commit releases
id: publish_releases
if: ${{ !fromJSON(env.PRERELEASE) }}
run: |
git reset --hard HEAD
version="$(get-version)"
version="$(version-next "$version")"
set-version "$(version-set-channel "$version" beta 0)"
git commit -am "chore: prepare for next version: $version"
git push