77 workflow_dispatch :
88 inputs :
99 create_release :
10- description : ' Create a release with current build'
10+ description : ' Release'
11+ required : true
12+ default : false
13+ type : boolean
14+ sign :
15+ description : ' Sign'
1116 required : true
1217 default : false
1318 type : boolean
1419
1520jobs :
1621 build :
1722 runs-on : windows-latest
23+ outputs :
24+ version : ${{ steps.get_version.outputs.version }}
25+ tag : ${{ steps.get_version.outputs.tag }}
26+ unsigned_artifact_id : ${{ steps.upload-unsigned-artifact.outputs.artifact-id }}
1827
1928 steps :
20- - uses : actions/checkout@v4
29+ - name : Checkout code
30+ uses : actions/checkout@v4
2131 with :
2232 fetch-depth : 1
2333
@@ -134,27 +144,89 @@ jobs:
134144 # 压缩生成的 wheels 目录
135145 Compress-Archive -Path deploy/dist/wheels/* -DestinationPath deploy/dist/ZenlessZoneZero-OneDragon-Environment.zip
136146
137- - name : Upload Installer
147+ - name : Upload Dist
138148 uses : actions/upload-artifact@v4
139149 with :
140- name : Installer
141- path : deploy/dist/OneDragon-Installer.exe
150+ name : dist
151+ if-no-files-found : error
152+ path : deploy/dist
142153
143- - name : Upload Launcher
154+ - name : Upload Unsigned Artifact
155+ if : ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release == true) || startsWith(github.ref, 'refs/tags/') }}
156+ id : upload-unsigned-artifact
144157 uses : actions/upload-artifact@v4
145158 with :
146- name : Launcher
147- path : deploy/dist/OneDragon-Launcher.exe
148-
149- - name : Upload Wheels
159+ # 上传后是 unsigned.zip
160+ name : unsigned
161+ if-no-files-found : error
162+ path : |
163+ .\deploy\dist\OneDragon-Launcher.exe
164+ .\deploy\dist\OneDragon-Installer.exe
165+
166+ sign :
167+ runs-on : windows-latest
168+ needs : build
169+ if : ${{ (github.event_name == 'workflow_dispatch' && inputs.sign == true) || startsWith(github.ref, 'refs/tags/') }}
170+ env :
171+ SIGNED_DIR : ' signed'
172+ SIGNPATH_SIGNING_POLICY_SLUG : ' test-signing'
173+ steps :
174+ - name : Sign Artifact
175+ if : ${{ needs.build.outputs.unsigned_artifact_id != '' }}
176+ uses : signpath/github-action-submit-signing-request@v1.1
177+ with :
178+ api-token : ' ${{ secrets.SIGNPATH_API_TOKEN }}'
179+ organization-id : ' ${{ vars.SIGNPATH_ORGANIZATION_ID }}'
180+ project-slug : ' ZenlessZoneZero-OneDragon'
181+ signing-policy-slug : ' ${{ env.SIGNPATH_SIGNING_POLICY_SLUG }}'
182+ github-artifact-id : " ${{ needs.build.outputs.unsigned_artifact_id }}"
183+ wait-for-completion : true
184+ # 签名后会自动下载到这个目录并解压 文件名和原来的一样
185+ output-artifact-directory : ' ${{ env.SIGNED_DIR }}'
186+
187+ - name : Upload signed executables
150188 uses : actions/upload-artifact@v4
151189 with :
152- name : Wheels
153- path : deploy/dist/ZenlessZoneZero-OneDragon-Environment.zip
190+ name : signed
191+ if-no-files-found : error
192+ path : ${{ env.SIGNED_DIR }}
193+
194+ release :
195+ runs-on : windows-latest
196+ needs :
197+ - build
198+ - sign
199+ if : ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release == true) || startsWith(github.ref, 'refs/tags/') }}
200+ steps :
201+ - name : Checkout code
202+ uses : actions/checkout@v4
203+ with :
204+ fetch-depth : 1
205+
206+ - name : Download dist
207+ uses : actions/download-artifact@v4
208+ with :
209+ name : dist
210+ path : deploy/dist
211+
212+ - name : Download signed executables
213+ if : ${{ needs.sign.result == 'success' }}
214+ uses : actions/download-artifact@v4
215+ with :
216+ name : signed
217+ path : deploy/dist/signed
218+
219+ - name : Replace unsigned executables with signed ones
220+ if : ${{ needs.sign.result == 'success' }}
221+ shell : pwsh
222+ run : |
223+ Copy-Item "deploy/dist/signed/OneDragon-Installer.exe" -Destination "deploy/dist/OneDragon-Installer.exe" -Force
224+ Copy-Item "deploy/dist/signed/OneDragon-Launcher.exe" -Destination "deploy/dist/OneDragon-Launcher.exe" -Force
154225
155226 - name : Prepare release directory and models
156- if : ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release == true) || startsWith(github.ref, 'refs/tags/') }}
157227 shell : pwsh
228+ env :
229+ RELEASE_VERSION : ${{ needs.build.outputs.version }}
158230 run : |
159231 # 将 dist 移动到当前目录的父目录下
160232 $distDir = "deploy/dist"
@@ -320,7 +392,7 @@ jobs:
320392 }
321393
322394 # 获取版本号
323- $version = "${{ steps.get_version.outputs.version }}"
395+ $version = $env:RELEASE_VERSION
324396
325397 # 打包前删除不需要的目录
326398 Remove-Item -Path "deploy/build" -Recurse -Force -ErrorAction SilentlyContinue
@@ -346,10 +418,11 @@ jobs:
346418
347419 - name : Generate Changelog
348420 id : changelog
349- if : ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release == true) || startsWith(github.ref, 'refs/tags/') }}
350421 shell : pwsh
422+ env :
423+ CURRENT_TAG : ${{ needs.build.outputs.tag }}
351424 run : |
352- $current_version_tag = "${{ steps.get_version.outputs.tag }}" # 从 get_version 步骤获取的标签
425+ $current_version_tag = $env:CURRENT_TAG
353426 $commits = @()
354427
355428 if ($env:GITHUB_REF -like 'refs/tags/*') {
@@ -450,17 +523,16 @@ jobs:
450523 echo $delimiter | Out-File -FilePath $env:GITHUB_OUTPUT -Append
451524
452525 - name : Create Release
453- if : ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release == true) || startsWith(github.ref, 'refs/tags/') }}
454526 uses : softprops/action-gh-release@v1
455527 with :
456- tag_name : ${{ steps.get_version .outputs.tag }}
457- name : " Release ${{ steps.get_version .outputs.version }}"
528+ tag_name : ${{ needs.build .outputs.tag }}
529+ name : " Release ${{ needs.build .outputs.version }}"
458530 body : |
459531 # 安装方式
460532
461- - `ZenlessZoneZero-OneDragon-${{ steps.get_version .outputs.version }}-Full-Environment.zip` 为带环境的完整包,不需要额外下载资源。
462- - `ZenlessZoneZero-OneDragon-${{ steps.get_version .outputs.version }}-Full.zip` 为完整包,解压后选择解压目录为安装目录,只需要下载环境依赖。
463- - `ZenlessZoneZero-OneDragon-${{ steps.get_version .outputs.version }}-Installer.exe` 为精简安装程序,运行后会自动下载所需的资源。
533+ - `ZenlessZoneZero-OneDragon-${{ needs.build .outputs.version }}-Full-Environment.zip` 为带环境的完整包,不需要额外下载资源。
534+ - `ZenlessZoneZero-OneDragon-${{ needs.build .outputs.version }}-Full.zip` 为完整包,解压后选择解压目录为安装目录,只需要下载环境依赖。
535+ - `ZenlessZoneZero-OneDragon-${{ needs.build .outputs.version }}-Installer.exe` 为精简安装程序,运行后会自动下载所需的资源。
464536 - 如果你想更新启动器,前往主程序【设置】-【资源下载】页面更新,或者下载 `ZenlessZoneZero-OneDragon-Launcher.zip`,解压后替换。
465537 - __不要下载Source Code__
466538
@@ -471,12 +543,12 @@ jobs:
471543
472544 ${{ steps.changelog.outputs.clean_changelog }}
473545 files : |
474- ZenlessZoneZero-OneDragon-${{ steps.get_version .outputs.version }}-Full-Environment.zip
475- ZenlessZoneZero-OneDragon-${{ steps.get_version .outputs.version }}-Full.zip
476- ZenlessZoneZero-OneDragon-${{ steps.get_version .outputs.version }}-Installer.exe
546+ ZenlessZoneZero-OneDragon-${{ needs.build .outputs.version }}-Full-Environment.zip
547+ ZenlessZoneZero-OneDragon-${{ needs.build .outputs.version }}-Full.zip
548+ ZenlessZoneZero-OneDragon-${{ needs.build .outputs.version }}-Installer.exe
477549 ZenlessZoneZero-OneDragon-Environment.zip
478550 ZenlessZoneZero-OneDragon-Launcher.zip
479551 generate_release_notes : false
480- prerelease : ${{ contains(steps.get_version .outputs.tag, '-beta.') }}
552+ prerelease : ${{ contains(needs.build .outputs.tag, '-beta.') }}
481553 env :
482554 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments