-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (49 loc) · 1.81 KB
/
Copy pathdotnet.yml
File metadata and controls
60 lines (49 loc) · 1.81 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
name: Build & Release SLDataAPI
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: 📥 Checkout 仓库
uses: actions/checkout@v4
- name: 🧰 设置 MSBuild
uses: microsoft/setup-msbuild@v2
- name: 📦 安装 NuGet
uses: NuGet/setup-nuget@v2
- name: 📦 还原依赖
run: dotnet restore
- name: 🛠 编译项目
run: msbuild SLDataAPI.csproj /p:Configuration=Release
- name: 📂 查找 DLL
id: find_dll
run: |
$dll = Get-ChildItem -Recurse -Filter "*.dll" | Where-Object { $_.Name -eq "SLDataAPI.dll" } | Select-Object -First 1
echo "dll_path=$($dll.FullName)" >> $env:GITHUB_OUTPUT
- name: 🏷 获取版本号
id: version
run: |
# ★ 修复:从 Plugin.cs 读取源代码版本号,保证与源代码对齐
$content = Get-Content Plugin.cs -Raw
if ($content -match 'new Version\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)') {
$ver = "$($Matches[1]).$($Matches[2]).$($Matches[3])"
} else {
$ver = "0.0.0"
}
# ★ 构建时间:年月日时分 (YYMMDDHHmm),用全角括号追加在版本号后
$buildTime = Get-Date -Format "yyMMddHHmm"
$version = "v${ver}(${buildTime})"
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "Resolved release version: $version"
- name: 🚀 创建 Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: SLDataAPI ${{ steps.version.outputs.version }}
files: ${{ steps.find_dll.outputs.dll_path }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}