-
Notifications
You must be signed in to change notification settings - Fork 3
91 lines (80 loc) · 3.37 KB
/
Copy pathrelease.yml
File metadata and controls
91 lines (80 loc) · 3.37 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
# 正式发布工作流:push tag `v<version>` → 构建 .tlx → 建 GitHub Release 并附产物(永久保存)。
#
# 与另两条 workflow 的分工:
# pr-test.yml —— PR/push 的编译 + 单测门禁(轻量)
# build-tlx.yml —— push master 出 14 天临时 artifact(供自测,非发布)
# release.yml —— 本文件,只由 tag 触发,产物进 Release 页面、永久可下载
#
# 打包同样委托 tools/pack-tlx.ps1(单一事实来源),产物名 <id>-<version>.tlx,
# 其中 version 取自 manifest.json —— 故 **tag 必须与 manifest.json 的 version 一致**,
# 下方 verify 步骤会强制校验,对不上直接失败(防止发出版本号自相矛盾的包)。
name: Release
on:
push:
tags: [ "v*" ]
workflow_dispatch:
inputs:
tag:
description: "要发布的 tag(如 v1.0.0)"
required: true
jobs:
release:
runs-on: windows-latest
permissions:
contents: write # 建 Release 需要写权限
steps:
- name: Checkout DiffSingerForTuneLab
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag || github.ref }}
path: DiffSingerForTuneLab
- name: Checkout TuneLab SDK (release/2.0.0)
uses: actions/checkout@v4
with:
repository: LiuYunPlayer/TuneLab
ref: release/2.0.0
path: TuneLab
sparse-checkout: |
TuneLab.SDK
TuneLab.Foundation
sparse-checkout-cone-mode: false
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Verify tag matches manifest version
id: verify
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$tag = "${{ github.event.inputs.tag || github.ref_name }}"
$version = (Get-Content DiffSingerForTuneLab/manifest.json -Raw | ConvertFrom-Json).version
if ($tag -ne "v$version") {
Write-Error "tag「$tag」与 manifest.json 的 version「$version」不一致(应为 v$version)。发版前请同步 manifest.json + csproj 的 <Version> + tag 三处。"
}
Write-Host "版本校验通过:$tag == v$version"
"version=$version" >> $env:GITHUB_OUTPUT
"tag=$tag" >> $env:GITHUB_OUTPUT
- name: Run unit tests
shell: pwsh
run: |
Set-Location DiffSingerForTuneLab
dotnet test tests/DiffSinger.Tests/DiffSinger.Tests.csproj --configuration Release --logger:"console;verbosity=normal"
- name: Build & pack .tlx
shell: pwsh
run: pwsh DiffSingerForTuneLab/tools/pack-tlx.ps1 -Configuration Release
- name: Report artifact
shell: pwsh
run: |
$tlx = Get-ChildItem DiffSingerForTuneLab/tools/tlx/*.tlx | Select-Object -First 1
if (-not $tlx) { Write-Error "未找到打包产物 .tlx" }
Write-Host ("产物: {0} ({1:N2} MB)" -f $tlx.Name, ($tlx.Length/1MB))
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.verify.outputs.tag }}
name: ${{ steps.verify.outputs.tag }}
draft: true # 先出草稿,人工过目发行说明后再点发布
generate_release_notes: true
files: DiffSingerForTuneLab/tools/tlx/*.tlx