@@ -2,37 +2,77 @@ name: Release
22
33on :
44 push :
5- tags :
6- - " v*"
75 pull_request :
86 workflow_dispatch :
97 inputs :
108 version :
11- description : " Release version (default: VERSION file) "
9+ description : " 发布版本(默认: VERSION 文件) "
1210 required : false
1311 default : " "
1412 create_release :
15- description : " Create GitHub Release ( true/false, default: false) "
13+ description : " 创建 GitHub Release( true/false,默认: false) "
1614 required : false
1715 default : " false"
1816
1917permissions :
2018 contents : write
2119
2220jobs :
21+ ci :
22+ name : 持续集成(${{ matrix.os }})
23+ if : ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')) }}
24+ runs-on : ${{ matrix.os }}
25+ concurrency :
26+ group : ci-${{ github.ref }}-${{ matrix.os }}
27+ cancel-in-progress : true
28+ strategy :
29+ fail-fast : false
30+ matrix :
31+ os : [windows-latest, ubuntu-latest, macos-latest]
32+ steps :
33+ - name : 检出代码
34+ uses : actions/checkout@v4
35+
36+ - name : 安装 .NET SDK
37+ uses : actions/setup-dotnet@v4
38+ with :
39+ dotnet-version : 10.0.x
40+ dotnet-quality : preview
41+
42+ - name : 还原依赖
43+ run : dotnet restore SecRandom.slnx
44+
45+ - name : 构建
46+ run : dotnet build SecRandom.slnx -c Release --no-restore
47+
48+ - name : 检测测试项目
49+ shell : bash
50+ run : |
51+ set -euo pipefail
52+ if find . -type f \( -name '*Test*.csproj' -o -name '*Tests*.csproj' \) | grep -q .; then
53+ echo "HAS_TESTS=true" >> "$GITHUB_ENV"
54+ else
55+ echo "HAS_TESTS=false" >> "$GITHUB_ENV"
56+ fi
57+
58+ - name : 运行测试
59+ if : env.HAS_TESTS == 'true'
60+ run : dotnet test SecRandom.slnx -c Release --no-build
61+
2362 version :
24- name : Resolve version
63+ name : 解析版本
64+ if : ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') }}
2565 runs-on : ubuntu-latest
2666 outputs :
2767 version : ${{ steps.v.outputs.version }}
2868 version_no_v : ${{ steps.v.outputs.version_no_v }}
2969 changelog : ${{ steps.v.outputs.changelog }}
3070 create_release : ${{ steps.v.outputs.create_release }}
3171 steps :
32- - name : Checkout
72+ - name : 检出代码
3373 uses : actions/checkout@v4
3474
35- - name : Resolve
75+ - name : 解析
3676 id : v
3777 shell : bash
3878 run : |
68108 echo "create_release=${create_release}" >> "$GITHUB_OUTPUT"
69109
70110 publish :
71- name : Publish ( ${{ matrix.rid }})
111+ name : 发布构建( ${{ matrix.rid }})
72112 needs : [version]
73113 runs-on : ${{ matrix.os }}
74114 strategy :
@@ -77,24 +117,30 @@ jobs:
77117 include :
78118 - os : windows-latest
79119 rid : win-x64
120+ - os : windows-latest
121+ rid : win-x86
122+ - os : windows-latest
123+ rid : win-arm64
80124 - os : ubuntu-latest
81125 rid : linux-x64
126+ - os : ubuntu-latest
127+ rid : linux-arm64
82128 - os : macos-latest
83129 rid : osx-x64
84130 - os : macos-latest
85131 rid : osx-arm64
86132
87133 steps :
88- - name : Checkout
134+ - name : 检出代码
89135 uses : actions/checkout@v4
90136
91- - name : Setup .NET SDK
137+ - name : 安装 .NET SDK
92138 uses : actions/setup-dotnet@v4
93139 with :
94140 dotnet-version : 10.0.x
95141 dotnet-quality : preview
96142
97- - name : Publish
143+ - name : 发布
98144 run : >
99145 dotnet publish src/SecRandom.Avalonia/SecRandom.Avalonia.csproj
100146 -c Release
@@ -104,7 +150,7 @@ jobs:
104150 /p:PublishSingleFile=true
105151 /p:IncludeNativeLibrariesForSelfExtract=true
106152
107- - name : Package ( Windows zip)
153+ - name : 打包( Windows zip)
108154 if : runner.os == 'Windows'
109155 shell : pwsh
110156 run : |
@@ -113,7 +159,7 @@ jobs:
113159 $outFile = "dist/SecRandom-${versionNoV}-${{ matrix.rid }}.zip"
114160 Compress-Archive -Path "artifacts/SecRandom-${{ matrix.rid }}/*" -DestinationPath $outFile -Force
115161
116- - name : Package ( Linux deb)
162+ - name : 打包( Linux deb)
117163 if : runner.os == 'Linux'
118164 shell : bash
119165 run : |
@@ -122,6 +168,12 @@ jobs:
122168 version_no_v="${{ needs.version.outputs.version_no_v }}"
123169 mkdir -p dist
124170
171+ deb_arch="amd64"
172+ case "${{ matrix.rid }}" in
173+ linux-x64) deb_arch="amd64" ;;
174+ linux-arm64) deb_arch="arm64" ;;
175+ esac
176+
125177 pkgroot="$(pwd)/pkgroot"
126178 rm -rf "$pkgroot"
127179 mkdir -p "$pkgroot/DEBIAN"
@@ -158,14 +210,14 @@ jobs:
158210 Version: ${version_no_v}
159211 Section: utils
160212 Priority: optional
161- Architecture: amd64
213+ Architecture: ${deb_arch}
162214 Maintainer: SECTL
163215 Description: SecRandom
164216 EOF
165217
166218 dpkg-deb --build "$pkgroot" "dist/SecRandom-${version_no_v}-${{ matrix.rid }}.deb"
167219
168- - name : Package ( macOS pkg)
220+ - name : 打包( macOS pkg)
169221 if : runner.os == 'macOS'
170222 shell : bash
171223 run : |
@@ -225,34 +277,34 @@ jobs:
225277 --install-location "/" \
226278 "dist/SecRandom-${version_no_v}-${{ matrix.rid }}.pkg"
227279
228- - name : Upload artifact
280+ - name : 上传构建产物
229281 uses : actions/upload-artifact@v4
230282 with :
231283 name : SecRandom-${{ matrix.rid }}
232284 path : dist/*
233285
234286 notes :
235- name : Generate notes
287+ name : 生成发布说明
236288 needs : [version, publish]
237289 runs-on : ubuntu-latest
238290 steps :
239- - name : Checkout
291+ - name : 检出代码
240292 uses : actions/checkout@v4
241293
242- - name : Download artifacts
294+ - name : 下载产物
243295 uses : actions/download-artifact@v4
244296 with :
245297 path : dist
246298
247- - name : Collect files
299+ - name : 收集文件
248300 shell : bash
249301 run : |
250302 set -euo pipefail
251303 mkdir -p release
252304 find dist -type f \( -name '*.zip' -o -name '*.deb' -o -name '*.pkg' \) -print -exec cp -f {} release/ \;
253305 ls -la release
254306
255- - name : Generate release notes with SHA512
307+ - name : 生成说明与 SHA512
256308 shell : bash
257309 run : |
258310 set -euo pipefail
@@ -301,7 +353,7 @@ jobs:
301353 done
302354 fi
303355
304- - name : Upload notes artifact
356+ - name : 上传说明产物
305357 uses : actions/upload-artifact@v4
306358 with :
307359 name : release-notes
@@ -310,31 +362,31 @@ jobs:
310362 release/SHA512SUMS.txt
311363
312364 release :
313- name : Create GitHub Release
365+ name : 创建 GitHub Release
314366 if : needs.version.outputs.create_release == 'true'
315367 needs : [version, publish, notes]
316368 runs-on : ubuntu-latest
317369 steps :
318- - name : Download artifacts
370+ - name : 下载产物
319371 uses : actions/download-artifact@v4
320372 with :
321373 path : dist
322374
323- - name : Collect files
375+ - name : 收集文件
324376 shell : bash
325377 run : |
326378 set -euo pipefail
327379 mkdir -p release
328380 find dist -type f \( -name '*.zip' -o -name '*.deb' -o -name '*.pkg' -o -name 'SHA512SUMS.txt' \) -print -exec cp -f {} release/ \;
329381 ls -la release
330382
331- - name : Download release notes
383+ - name : 下载发布说明
332384 uses : actions/download-artifact@v4
333385 with :
334386 name : release-notes
335387 path : notes
336388
337- - name : Publish release
389+ - name : 发布 Release
338390 uses : softprops/action-gh-release@v2
339391 with :
340392 tag_name : ${{ needs.version.outputs.version }}
0 commit comments