forked from OneDragon-Anything/ZenlessZoneZero-OneDragon
-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (230 loc) · 9.32 KB
/
Copy pathbuild-release.yml
File metadata and controls
273 lines (230 loc) · 9.32 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
name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
create_release:
description: 'Create Release'
required: true
default: false
type: boolean
env:
CREATE_RELEASE: ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release == true) || startsWith(github.ref, 'refs/tags/') }}
jobs:
version:
runs-on: windows-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
tag: ${{ steps.get_version.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Get version
if: ${{ env.CREATE_RELEASE == 'true' }}
id: get_version
shell: pwsh
run: python tools/ci/get_version.py
build:
runs-on: windows-latest
needs: version
outputs:
unsigned_artifact_id: ${{ steps.upload-unsigned-artifact.outputs.artifact-id }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
shell: pwsh
run: |
Invoke-WebRequest -Uri https://astral.sh/uv/install.ps1 | Invoke-Expression
- name: Create and activate virtual environment
shell: pwsh
run: |
uv venv .venv --python=3.11.12
- name: Install dependencies
shell: pwsh
run: |
.\.venv\Scripts\Activate.ps1
uv sync --group dev
- name: Download and extract UPX into venv Scripts
shell: pwsh
run: |
$venvScripts = ".\.venv\Scripts"
$upxDir = Join-Path $venvScripts "upx"
$sourceUpxPath = Join-Path $upxDir "upx-4.2.3-win64" "upx.exe"
$destinationUpxPath = Join-Path $venvScripts "upx.exe"
$zipPath = "upx.zip"
Invoke-WebRequest -Uri "https://github.com/upx/upx/releases/download/v4.2.3/upx-4.2.3-win64.zip" -OutFile $zipPath
Expand-Archive -Path $zipPath -DestinationPath $upxDir -Force
Move-Item -Path $sourceUpxPath -Destination $destinationUpxPath -Force
Remove-Item -Path $upxDir -Recurse -Force
Remove-Item -Path $zipPath -Force
- name: Build executables
shell: pwsh
env:
RELEASE_VERSION: ${{ needs.version.outputs.version }}
run: |
echo "__version__ = '$env:RELEASE_VERSION'" | Out-File -FilePath src/one_dragon/version.py -Encoding utf8
.\.venv\Scripts\Activate.ps1
cd deploy
pyinstaller "OneDragon-Installer.spec"
pyinstaller "OneDragon-Launcher.spec"
- name: Bundle dependencies into wheels
shell: pwsh
run: |
# 激活虚拟环境
.\.venv\Scripts\Activate.ps1
# 创建目标目录并生成 wheel 包
New-Item -ItemType Directory -Path deploy/dist/wheels -Force
uv export --no-hashes --no-dev --format requirements-txt > deploy/dist/requirements.txt
pip wheel --wheel-dir=deploy/dist/wheels -r deploy/dist/requirements.txt
# 压缩生成的 wheels 目录
Compress-Archive -Path deploy/dist/wheels/* -DestinationPath deploy/dist/ZenlessZoneZero-OneDragon-Environment.zip
- name: Upload Installer
if: ${{ env.CREATE_RELEASE == 'false' }}
uses: actions/upload-artifact@v4
with:
name: Installer
path: deploy/dist/OneDragon-Installer.exe
- name: Upload Launcher
if: ${{ env.CREATE_RELEASE == 'false' }}
uses: actions/upload-artifact@v4
with:
name: Launcher
path: deploy/dist/OneDragon-Launcher.exe
- name: Upload Wheels
if: ${{ env.CREATE_RELEASE == 'false' }}
uses: actions/upload-artifact@v4
with:
name: Wheels
path: deploy/dist/ZenlessZoneZero-OneDragon-Environment.zip
- name: Upload Dist
if: ${{ env.CREATE_RELEASE == 'true' }}
uses: actions/upload-artifact@v4
with:
name: dist
if-no-files-found: error
path: deploy/dist
- name: Upload Unsigned Artifact
if: ${{ env.CREATE_RELEASE == 'true' }}
id: upload-unsigned-artifact
uses: actions/upload-artifact@v4
with:
# 上传后是 unsigned.zip
name: unsigned
if-no-files-found: error
path: |
.\deploy\dist\OneDragon-Launcher.exe
.\deploy\dist\OneDragon-Installer.exe
sign:
runs-on: windows-latest
needs:
- version
- build
if: ${{ github.repository_owner == 'OneDragon-Anything' &&
((github.event_name == 'workflow_dispatch' && inputs.create_release == true) || startsWith(github.ref, 'refs/tags/'))
}}
env:
SIGNED_DIR: 'signed'
SIGNPATH_SIGNING_POLICY_SLUG: 'release-signing'
steps:
- name: Sign Artifact
if: ${{ needs.build.outputs.unsigned_artifact_id != '' }}
uses: signpath/github-action-submit-signing-request@v1.1
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '${{ vars.SIGNPATH_ORGANIZATION_ID }}'
project-slug: 'ZenlessZoneZero-OneDragon'
signing-policy-slug: '${{ env.SIGNPATH_SIGNING_POLICY_SLUG }}'
github-artifact-id: "${{ needs.build.outputs.unsigned_artifact_id }}"
wait-for-completion: true
# 签名后会自动下载到这个目录并解压 文件名和原来的一样
output-artifact-directory: '${{ env.SIGNED_DIR }}'
- name: Upload signed executables
uses: actions/upload-artifact@v4
with:
name: signed
if-no-files-found: error
path: ${{ env.SIGNED_DIR }}
release:
runs-on: windows-latest
needs:
- version
- build
- sign
if: ${{ always() &&
needs.build.result == 'success' &&
((github.event_name == 'workflow_dispatch' && inputs.create_release == true) || startsWith(github.ref, 'refs/tags/')) &&
(github.repository_owner != 'OneDragon-Anything' || needs.sign.result == 'success')
}}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Download dist
uses: actions/download-artifact@v4
with:
name: dist
path: deploy/dist
- name: Download signed executables
if: ${{ needs.sign.result == 'success' }}
uses: actions/download-artifact@v4
with:
name: signed
path: deploy/dist/signed
- name: Prepare release directory and models
shell: pwsh
env:
RELEASE_VERSION: ${{ needs.version.outputs.version }}
run: python tools/ci/prepare_release_assets.py --release-version "$env:RELEASE_VERSION"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.version.outputs.tag }}
name: "Release ${{ needs.version.outputs.version }}"
body: |
## 安装方式
- `ZenlessZoneZero-OneDragon-${{ needs.version.outputs.version }}-Full-Environment.zip` 为带环境的完整包,不需要额外下载资源。
- `ZenlessZoneZero-OneDragon-${{ needs.version.outputs.version }}-Full.zip` 为完整包,解压后选择解压目录为安装目录,只需要下载环境依赖。
- `ZenlessZoneZero-OneDragon-${{ needs.version.outputs.version }}-Installer.exe` 为精简安装程序,运行后会自动下载所需的资源。
- 如果你想更新启动器,前往主程序【设置】-【资源下载】页面更新,或者下载 `ZenlessZoneZero-OneDragon-Launcher.zip`,解压后替换。
- __不要下载Source Code__
安装前请查看 [安装指南](https://one-dragon.com/zzz/zh/quickstart.html)
若运行出错请查看 [自助排障指南](https://docs.qq.com/doc/p/7add96a4600d363b75d2df83bb2635a7c6a969b5)
已有 Mirror酱 CDK?前往 [Mirror酱](https://mirrorchyan.com/zh/projects?rid=ZZZ-OneDragon&source=zzzgh-release) 高速下载
## 签名策略 (Code Signing Policy)
免费代码签名由 [SignPath.io](https://signpath.io/) 提供,证书由 [SignPath Foundation](https://signpath.org/) 颁发
审批人:[DoctorReid](https://github.com/DoctorReid) [ShadowLemoon](https://github.com/ShadowLemoon)
Free code signing provided by [SignPath.io](https://signpath.io/), certificate by [SignPath Foundation](https://signpath.org/)
Approvers: [DoctorReid](https://github.com/DoctorReid) [ShadowLemoon](https://github.com/ShadowLemoon)
## 隐私政策 (Privacy Policy)
本程序的隐私政策详见:[隐私政策](.github/PRIVACY.md)。
See the [Privacy Policy](.github/PRIVACY.md).
files: |
ZenlessZoneZero-OneDragon-${{ needs.version.outputs.version }}-Full-Environment.zip
ZenlessZoneZero-OneDragon-${{ needs.version.outputs.version }}-Full.zip
ZenlessZoneZero-OneDragon-${{ needs.version.outputs.version }}-Installer.exe
ZenlessZoneZero-OneDragon-Environment.zip
ZenlessZoneZero-OneDragon-Launcher.zip
generate_release_notes: false
prerelease: ${{ contains(needs.version.outputs.version, '-beta.') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}