-
Notifications
You must be signed in to change notification settings - Fork 417
284 lines (260 loc) · 11.1 KB
/
release.yml
File metadata and controls
284 lines (260 loc) · 11.1 KB
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
name: release
on:
workflow_dispatch:
inputs:
dry-run:
description: "Use dry-run"
required: false
type: boolean
default: false
run-id:
description: "Build workflow run ID"
required: true
type: string
only-publish-to:
description: "Only publish packages to"
required: false
type: choice
default: All
options:
- npmjs.com
- NuGet.org
- PyPI.org
- GitHub
- MirrorChyan
- All
run-name:
description: "Run name"
required: false
type: string
run-name: "${{ inputs.run-name }} Release | ${{ inputs.only-publish-to }} ${{inputs.dry-run && '| Dry Run ' || ''}}| Build from #${{ inputs.run-id }}"
concurrency:
group: ${{ github.workflow }}-${{ inputs.run-id }}
cancel-in-progress: false
# 注意:如果 only-publish-to 是 All,则所有 jobs 的状态都必须是成功,All 的状态由 create_issue 判断
jobs:
meta:
uses: ./.github/workflows/meta.yml
with:
reuse-from-run-id: ${{ inputs.run-id }}
changelog:
name: Generate changelog
needs: meta
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: .github/cliff.toml
args: >-
-vv --latest --strip header
${{ needs.meta.outputs.is-prerelease == 'false' && '--tag-pattern "^v[0-9]+\\.[0-9]+\\.[0-9]+$"' || '' }}
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}
nuget:
if: ${{ inputs.only-publish-to == 'NuGet.org' || inputs.only-publish-to == 'All' }}
continue-on-error: ${{ inputs.only-publish-to == 'All' }}
runs-on: ubuntu-latest
outputs:
result: ${{ steps.publish.outcome }}
permissions:
id-token: write
env:
NUGET_PACKAGE_SOURCE: ${{ inputs.dry-run && 'https://apiint.nugettest.org/v3/index.json' || 'https://api.nuget.org/v3/index.json' }}
NUGET_AUDIENCE: ${{ inputs.dry-run && 'https://int.nugettest.org' || 'https://www.nuget.org' }}
steps:
- uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
run_id: ${{ inputs.run-id }}
name: pkgs-nuget
path: assets/pkgs-nuget
check_artifacts: true
if_no_artifact_found: fail
- id: login
uses: NuGet/login@v1
with:
user: moomiji
token-service-url: ${{ env.NUGET_AUDIENCE }}/api/v2/token
audience: ${{ env.NUGET_AUDIENCE }}
- name: Publish NuGet
id: publish
run: |
dotnet nuget push assets/pkgs-nuget/*.nupkg \
--api-key ${{steps.login.outputs.NUGET_API_KEY}} \
--source ${{ env.NUGET_PACKAGE_SOURCE }} \
--skip-duplicate
nodejs:
if: ${{ inputs.only-publish-to == 'npmjs.com' || inputs.only-publish-to == 'All' }}
continue-on-error: ${{ inputs.only-publish-to == 'All' }}
runs-on: ubuntu-latest
outputs:
result: ${{ steps.publish.outcome }}
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
run_id: ${{ inputs.run-id }}
name: pkgs-nodejs
path: assets/pkgs-nodejs
check_artifacts: true
if_no_artifact_found: fail
- uses: ./.github/actions/publish_nodejs
id: publish
with:
access: public
path: assets/pkgs-nodejs
dry-run: ${{ inputs.dry-run }}
pip:
if: ${{ inputs.only-publish-to == 'PyPI.org' || inputs.only-publish-to == 'All' }}
continue-on-error: ${{ inputs.only-publish-to == 'All' }}
runs-on: ubuntu-latest
outputs:
result: ${{ steps.publish.outcome }}
permissions:
id-token: write
env:
PYPI_REPOSITORY: ${{ inputs.dry-run && 'testpypi' || 'pypi' }}
steps:
- uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
run_id: ${{ inputs.run-id }}
name: pkgs-pip
path: assets/pkgs-pip
check_artifacts: true
if_no_artifact_found: fail
- name: Publish Pip Packages
id: publish
run: |
pip install --upgrade twine packaging
python -m twine upload \
assets/pkgs-pip/*.whl \
--repository ${{ env.PYPI_REPOSITORY }} \
--skip-existing
github:
needs: [meta, changelog]
if: ${{ inputs.only-publish-to == 'GitHub' || inputs.only-publish-to == 'All' }}
continue-on-error: ${{ inputs.only-publish-to == 'All' }}
runs-on: ubuntu-latest
outputs:
result: ${{ steps.publish.outcome }}
permissions:
contents: write
steps:
- uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
run_id: ${{ inputs.run-id }}
name_is_regexp: true
name: MAA-*
path: assets
check_artifacts: true
if_no_artifact_found: fail
- name: Package artifacts
run: |
cd assets
for f in *; do
(cd $f && zip -r ../$f-${{ needs.meta.outputs.tag }}.zip .)
done
- id: publish
uses: softprops/action-gh-release@v2
with:
files: assets/*.zip
tag_name: ${{ inputs.dry-run && 'v0.0.0' || needs.meta.outputs.tag }}
prerelease: ${{ needs.meta.outputs.is-prerelease == 'true' }}
body: ${{ needs.changelog.outputs.release_body }}
mirrorchyan:
needs: [meta, github]
if: always() && needs.meta.result == 'success' && (
inputs.only-publish-to == 'MirrorChyan' ||
inputs.only-publish-to == 'All'
)
continue-on-error: ${{ inputs.only-publish-to == 'All' }}
runs-on: ubuntu-latest
outputs:
result: ${{ steps.publish.outcome }}
steps:
- name: Trigger MirrorChyanUploading
id: publish
if: inputs.only-publish-to == 'MirrorChyan' ||
( inputs.only-publish-to == 'All' && needs.github.outputs.result == 'success' )
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ inputs.dry-run }}" = "true" ]; then
echo "Dry run mode, skipping MirrorChyan upload."
exit 0
fi
gh workflow run --repo ${{ github.repository }} mirrorchyan.yml -f tag=${{ needs.meta.outputs.tag }}
gh workflow run --repo ${{ github.repository }} mirrorchyan_release_note.yml -f tag=${{ needs.meta.outputs.tag }}
create_issue:
needs: [meta, changelog, nuget, nodejs, pip, github, mirrorchyan]
runs-on: ubuntu-latest
if: success() && (
needs.nuget.outputs.result != 'success' ||
needs.nodejs.outputs.result != 'success' ||
needs.pip.outputs.result != 'success' ||
needs.github.outputs.result != 'success' ||
needs.mirrorchyan.outputs.result != 'success'
)
env:
ISSUE_TITLE: "${{ needs.meta.outputs.tag }} failed to release"
ISSUE_BODY: |
A new release attempt for tag ${{ needs.meta.outputs.tag }} failed.
${{ needs.nuget.outputs.result != 'success' && '- nuget @moomiji' || '' }}
${{ needs.nodejs.outputs.result != 'success' && '- nodejs @neko-para' || '' }}
${{ needs.pip.outputs.result != 'success' && '- pip @MistEO' || '' }}
${{ needs.github.outputs.result != 'success' && '- github @MistEO' || '' }}
${{ needs.mirrorchyan.outputs.result != 'success' && '- mirrorchyan @MistEO' || '' }}
Release run: [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
Build run: [${{ inputs.run-id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ inputs.run-id }})
| Job | Result |
| --- | ------ |
| nuget | ${{ needs.nuget.outputs.result }} |
| nodejs | ${{ needs.nodejs.outputs.result }} |
| pip | ${{ needs.pip.outputs.result }} |
| mirrorchyan | ${{ needs.mirrorchyan.outputs.result }} |
| github | ${{ needs.github.outputs.result }} |
cc @MistEO
steps:
- name: find issues
id: find-issues
uses: actions-cool/issues-helper@v3
with:
actions: "find-issues"
issue-state: "all"
title-includes: "${{ env.ISSUE_TITLE }}"
- name: Create issue
if: ${{ fromJSON(steps.find-issues.outputs.issues)[0] == null }}
uses: actions-cool/issues-helper@v3
with:
actions: "create-issue"
title: ${{ env.ISSUE_TITLE }}
body: ${{ env.ISSUE_BODY }}
- name: Open issue
if: ${{ fromJSON(steps.find-issues.outputs.issues)[0].state == 'closed' }}
uses: actions-cool/issues-helper@v3
with:
actions: "open-issue"
issue-number: ${{ fromJSON(steps.find-issues.outputs.issues)[0].number }}
- name: Add comment
if: ${{ fromJSON(steps.find-issues.outputs.issues)[0] != null }}
uses: actions-cool/issues-helper@v3
with:
actions: "create-comment"
issue-number: ${{ fromJSON(steps.find-issues.outputs.issues)[0].number }}
body: ${{ env.ISSUE_BODY }}