-
-
Notifications
You must be signed in to change notification settings - Fork 24
262 lines (231 loc) · 8.79 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
name: Create Release
on:
workflow_dispatch:
inputs:
release_kind:
type: choice
description: The type of release.
default: prerelease
required: true
options:
- prerelease
- start-rc
- stable
publish:
description: "True to publish release to git, vpm. if false, this creates release asset only"
type: boolean
required: false
env:
PKG_NAME: com.anatawa12.avatar-optimizer
SOMETHING_RELEASER_SEMVER: 1
concurrency:
group: publish
cancel-in-progress: true
permissions: write-all
jobs:
create-release:
runs-on: ubuntu-latest
environment:
name: actions-github-app
outputs:
version: ${{ steps.update-version.outputs.version }}
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
submodules: recursive
- uses: anatawa12/something-releaser@v2
- uses: snow-actions/[email protected]
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.3'
extended: true
- name: Check release is public
if: github.event.inputs.release_kind == 'stable'
run: |
if [[ "$(jq '.private == true' < package.json)" == "true" ]]; then
echo "package.json is private"
exit 255
fi
- name: Check release is public
run: |
if [[ "$(jq '.["private-beta"] == true' < package.json)" == "true" ]]; then
echo "package.json is private-beta"
exit 255
fi
- name: Update Version Name
id: update-version
run: |
# set version name in properties file
case "$RELEASE_KIND_IN" in
"prerelease" )
set-version "$(version-next "$(get-version)")"
gh-export-variable PRERELEASE true
;;
"start-rc" )
set-version "$(version-set-channel "$(get-version)" rc)"
gh-export-variable PRERELEASE true
;;
"stable" )
set-version "$(version-set-channel "$(get-version)" stable)"
gh-export-variable PRERELEASE false
;;
* )
echo "invalid release kind: $RELEASE_KIND_IN"
exit 255
;;
esac
case "$GITHUB_REF_NAME" in
master | master-* )
echo "head is master or master-*"
;;
* )
echo "invalid release kind: $RELEASE_KIND_IN is not allowd for $GITHUB_REF_NAME"
exit 255
;;
esac
gh-export-variable VERSION "$(get-version)"
gh-set-output version "$(get-version)"
env:
RELEASE_KIND_IN: ${{ github.event.inputs.release_kind }}
# region changelog
- name: Create Changelog
id: changelog
uses: anatawa12/sh-actions/changelog/prepare-release@master
with:
version: ${{ env.VERSION }}
prerelease: ${{ env.PRERELEASE }}
tag-prefix: v
prerelease-note-heading: |
Version ${{ env.VERSION }}
---
Installer unitypackage for this version is [here][installer for this].
[installer for this]: https://api.anatawa12.com/create-vpai/?name=AvatarOptimizer-{}-installer.unitypackage&repo=https://vpm.anatawa12.com/vpm.json&package=com.anatawa12.avatar-optimizer&version=${{ env.VERSION }}
**This is SNAPSHOT, not a stable release. make sure this may have many bugs.**
release-note-heading: |
Version ${{ env.VERSION }}
---
Installer unitypackage for this version is [here][installer for this].
[installer for this]: https://api.anatawa12.com/create-vpai/?name=AvatarOptimizer-{}-installer.unitypackage&repo=https://vpm.anatawa12.com/vpm.json&package=com.anatawa12.avatar-optimizer&version=${{ env.VERSION }}
- name: Upload CHANGELOG.md
if: ${{ !fromJSON(env.PRERELEASE) }}
uses: actions/upload-artifact@v3
with:
name: CHANGELOG
path: CHANGELOG.md
- name: Upload CHANGELOG-PRERELEASE.md
uses: actions/upload-artifact@v3
with:
name: CHANGELOG-PRERELEASE
path: CHANGELOG-PRERELEASE.md
- run: cp "${{ steps.changelog.outputs.release-note }}" release-note.md
- name: Upload release note
uses: actions/upload-artifact@v3
with:
name: changelog
path: release-note.md
- run: rm release-note.md
# endregion changelog
- name: Commit & tag version
if: ${{ inputs.publish }}
run: |
git commit -am "chore: bump version to $VERSION"
git tag "v$VERSION"
# region building
- name: Prepare build folder
run: mkdir build
- name: update changelog url
run: |
STABLE_URL="https://vpm.anatawa12.com/avatar-optimizer/en/docs/changelog/"
BETA_URL="https://vpm.anatawa12.com/avatar-optimizer/beta/en/docs/changelog/"
if $PRERELEASE; then
sed -i'.bak' -e "s|${STABLE_URL}|${BETA_URL}#${VERSION}|" package.json
else
sed -i'.bak' -e "s|${STABLE_URL}|${STABLE_URL}#${VERSION}|" package.json
fi
rm package.json.bak
- name: update csc.rsp
run: |
sed -n '/PUBLISH DELETE MARKER/q;p' -i .csc.rsp.nullunsafe
sed -n '/PUBLISH DELETE MARKER/q;p' -i .csc.rsp.nullsafe
# region vpm release
- name: Build VPM release
run: |
zip -r "build/$PKG_NAME-$VERSION.zip" . -x 'build*' '.*' 'Test~/*'
- name: Upload VPM release
uses: actions/upload-artifact@v3
with:
name: vpm-package
path: build/${{ env.PKG_NAME }}-${{ env.VERSION }}.zip
# endregion vpm release
# region docs
# remember update update-website.yml
- name: Update .docs/config.toml
run: sed -i'.bak' -e "s/(SNAPSHOT)/($VERSION)/" .docs/config.toml && rm .docs/config.toml.bak
- name: Build docs as a beta docs
working-directory: .docs
run: ./build.sh 'https://vpm.anatawa12.com/avatar-optimizer/beta' "$VERSION"
- name: Copy to beta dir if it's release
if: ${{ !fromJSON(env.PRERELEASE) }}
working-directory: .docs
run: mkdir -p static && mv public static/beta
- name: Build docs as a release docs if it's release
if: ${{ !fromJSON(env.PRERELEASE) }}
working-directory: .docs
run: ./build.sh 'https://vpm.anatawa12.com/avatar-optimizer' "$VERSION"
- name: zip docs
run: cd .docs/public && zip ../../build/website.zip -r .
- name: Upload docs
uses: actions/upload-artifact@v3
with:
name: website
path: .docs/public
- name: Restore .docs/config.toml
run: git restore --staged --worktree .docs/config.toml
# endregion docs
# endregion building
- name: Publish Release
if: ${{ inputs.publish }}
run: |
git push && git push origin "v$VERSION"
- name: Publish release to github
if: ${{ inputs.publish }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_NOTE: ${{ steps.changelog.outputs.release-note }}
shell: bash
run: |
sleep 1
# upload release assets
gh release create "v$VERSION" \
-F "$RELEASE_NOTE" \
${{ fromJSON(env.PRERELEASE) && '--prerelease' || '' }} \
"build/$PKG_NAME-$VERSION.zip" \
build/website.zip \
"package.json" \
- name: Restore package.json
run: git restore --staged --worktree package.json
- name: prepare next release & push
if: inputs.publish && !fromJSON(env.PRERELEASE)
run: |
VERSION="$(version-next "$(get-version)")"
set-version "$(version-set-channel "$VERSION" beta 0)"
git commit -am "chore: prepare for next version: $VERSION"
git push && git push --tags
publish-vpm:
uses: anatawa12/vpm.anatawa12.com/.github/workflows/update-package.yml@master
needs: create-release
if: inputs.publish
with:
version: ${{ needs.create-release.outputs.version }}
environment: vpm.anatawa12.com
website_zip: https://github.com/anatawa12/AvatarOptimizer/releases/download/v${{ needs.create-release.outputs.version }}/website.zip
website_path: ${{ contains(needs.create-release.outputs.version, '-') && 'beta' || '' }}
secrets:
TOKEN: ${{ secrets.VPM_GITHUB_PAT }}