forked from DA-TENSHI/SHINANOSKEY
-
Notifications
You must be signed in to change notification settings - Fork 0
282 lines (250 loc) Β· 8.76 KB
/
release.yaml
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
name: Release
on:
workflow_dispatch:
inputs:
base_version:
type: string
description: Enter base version. (e.g. 2024.8.0)
required: true
default: ""
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: read
jobs:
check-context:
name: Check context
runs-on: ubuntu-22.04
steps:
- name: Check actor
if: github.actor != github.repository_owner
run: exit 1
- name: Check branch
if: github.ref_name != vars.DEVELOP_BRANCH
run: exit 1
- name: Check base version
env:
base_version: ${{ inputs.base_version }}
run: |
if [[ -z "$base_version" ]]; then
exit 1
fi
year="$(cut -d. -f1 <<< "$base_version")"
if [[ ! "$year" =~ ^[0-9]+$ ]]; then
exit 1
fi
month="$(cut -d. -f2 <<< "$base_version")"
if [[ ! "$month" =~ ^[0-9]+$ ]] || \
[[ "$month" -lt 1 || "$month" -gt 12 ]]; then
exit 1
fi
patch="$(cut -d. -f3 <<< "$base_version")"
if [[ ! "$patch" =~ ^[0-9]+$ ]]; then
exit 1
fi
parse-version:
name: Parse new version
runs-on: ubuntu-22.04
needs:
- check-context
outputs:
new_version: ${{ steps.generate.outputs.new_version }}
steps:
- name: Checkout ${{ github.sha }}
uses: actions/[email protected]
with:
persist-credentials: false
ref: ${{ github.sha }}
fetch-depth: 1
- name: Generate new version
id: generate
env:
base_version: ${{ inputs.base_version }}
run: |
current_version="$(cat package.json | jq -r '.version')"
current_base="$(sed 's/-.*//' <<< "$current_version")"
new_base="${base_version:-"$current_base"}"
if [[ "$current_version" != "$current_base" && \
"$current_base" == "$new_base" ]]; then
current_suffix="$((cut -d- -f2 | cut -d. -f2) <<< "$current_version")"
new_suffix="$(("$current_suffix" + 1))"
fi
new_suffix="${new_suffix:-0}"
new_version="${new_base}-taiyme.${new_suffix}"
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
bump-version-update:
name: Bump version (update)
runs-on: ubuntu-22.04
needs:
- parse-version
steps:
- name: Checkout ${{ github.sha }}
uses: actions/[email protected]
with:
persist-credentials: false
ref: ${{ github.sha }}
fetch-depth: 1
- name: Update package.json (root)
run: |
jq --tab '.version = "${{ needs.parse-version.outputs.new_version }}"' package.json > tmp
mv tmp package.json
- name: Update package.json (misskey-js)
working-directory: packages/misskey-js
run: |
jq --tab '.version = "${{ needs.parse-version.outputs.new_version }}"' package.json > tmp
mv tmp package.json
- name: Update compose_example.yml
run: |
old_docker_image="$(yq '.services.web.image' compose_example.yml)"
new_docker_image='${{ vars.DOCKER_IMAGE_NAME }}:${{ needs.parse-version.outputs.new_version }}'
sed -i "s|image: ${old_docker_image}|image: ${new_docker_image}|g" compose_example.yml
- name: Upload artifacts
uses: actions/[email protected]
with:
name: bump_version_files
path: |
package.json
packages/misskey-js/package.json
compose_example.yml
bump-version-upload:
name: Bump version (upload)
runs-on: ubuntu-22.04
needs:
- parse-version
- bump-version-update
steps:
- name: Create GitHub App Token
uses: actions/[email protected]
id: app-token
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_PRIVATE_KEY }}
- name: Get GitHub App User ID
id: get-user-id
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
user_id="$(gh api '/users/${{ steps.app-token.outputs.app-slug }}[bot]' --jq '.id')"
echo "user-id=${user_id}" >> $GITHUB_OUTPUT
- name: Checkout ${{ vars.DEVELOP_BRANCH }}
uses: actions/[email protected]
with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
ref: ${{ vars.DEVELOP_BRANCH }}
fetch-depth: 1
- name: Download artifacts
uses: actions/[email protected]
with:
name: bump_version_files
- name: Commit and Push
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ github.repository }}
git add .
git commit -m 'Release: ${{ needs.parse-version.outputs.new_version }}'
git tag ${{ needs.parse-version.outputs.new_version }}
git push origin HEAD
git push origin ${{ needs.parse-version.outputs.new_version }}
create-pr:
name: Create PR
runs-on: ubuntu-22.04
needs:
- parse-version
- bump-version-upload
outputs:
pr_number: ${{ steps.create-pr.outputs.pr_number }}
steps:
- name: Create GitHub App Token
uses: actions/[email protected]
id: app-token
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_PRIVATE_KEY }}
- name: Checkout ${{ vars.DEVELOP_BRANCH }}
uses: actions/[email protected]
with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
ref: ${{ vars.DEVELOP_BRANCH }}
fetch-depth: 0
- name: Create PR
id: create-pr
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
created_pr="$(
gh pr create --draft \
--base ${{ vars.RELEASE_BRANCH }} \
--head ${{ vars.DEVELOP_BRANCH }} \
--title 'Release: ${{ needs.parse-version.outputs.new_version }}' \
--body ''
)"
pr_number="$(awk -F '/' '/\/pull\/[0-9]+$/ {print $NF}' <<< "$created_pr")"
echo "pr_number=${pr_number}" >> $GITHUB_OUTPUT
merge-pr:
name: Merge PR
runs-on: ubuntu-22.04
needs:
- create-pr
steps:
- name: Create GitHub App Token
uses: actions/[email protected]
id: app-token
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_PRIVATE_KEY }}
- name: Checkout ${{ vars.DEVELOP_BRANCH }}
uses: actions/[email protected]
with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
ref: ${{ vars.DEVELOP_BRANCH }}
fetch-depth: 1
- name: Merge PR
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh pr checks ${{ needs.create-pr.outputs.pr_number }} --watch
gh pr ready ${{ needs.create-pr.outputs.pr_number }}
gh pr merge ${{ needs.create-pr.outputs.pr_number }} --merge --auto
release:
name: Release
runs-on: ubuntu-22.04
needs:
- parse-version
- merge-pr
steps:
- name: Create GitHub App Token
uses: actions/[email protected]
id: app-token
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_PRIVATE_KEY }}
- name: Checkout ${{ vars.RELEASE_BRANCH }}
uses: actions/[email protected]
with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
ref: ${{ vars.RELEASE_BRANCH }}
fetch-depth: 0
- name: Generate release notes
id: generate-release-notes
uses: ./.github/actions/generate-release-notes
with:
token: ${{ steps.app-token.outputs.token }}
version: ${{ needs.parse-version.outputs.new_version }}
- name: Set release notes
env:
release_notes: ${{ steps.generate-release-notes.outputs.release_notes }}
run: |
echo "$release_notes" > /tmp/release-notes.md
- name: Create Release
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh release create ${{ needs.parse-version.outputs.new_version }} \
--title ${{ needs.parse-version.outputs.new_version }} \
--notes-file /tmp/release-notes.md