Skip to content

Commit 0f059be

Browse files
committed
[GITHUB] Improve workflow and add automatically release workflow
1 parent c3e432b commit 0f059be

File tree

4 files changed

+81
-41
lines changed

4 files changed

+81
-41
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
Build:
13+
permissions:
14+
contents: read
15+
strategy:
16+
matrix:
17+
os: [windows-latest, windows-11-arm]
18+
platform: [x64, x86, ARM64, ARM64EC]
19+
config: [Debug, Release]
20+
fail-fast: false
21+
runs-on: ${{matrix.os}}
22+
steps:
23+
- name: Source checkout
24+
uses: actions/checkout@main
25+
with:
26+
submodules: recursive
27+
- name: Prepare MSBuild
28+
uses: microsoft/setup-msbuild@main
29+
- name: Build
30+
run: msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=${{matrix.config}} /p:Platform=${{matrix.platform}} /p:RestorePackagesConfig=true
31+
- name: Run Unit Test
32+
if: ${{(matrix.os == 'windows-latest' && (matrix.platform == 'x64' || matrix.platform == 'x86') || matrix.os == 'windows-11-arm')}}
33+
run: .\Source\OutDir\${{matrix.platform}}\${{matrix.config}}\UnitTest.exe -Run
34+
Publish:
35+
if: ${{github.base_ref == '' && startsWith(github.event.head_commit.message, '[VERSION] ')}}
36+
needs: Build
37+
permissions:
38+
contents: write
39+
runs-on: windows-latest
40+
steps:
41+
- name: Set release version
42+
id: relver
43+
shell: pwsh
44+
run: |
45+
$relver="${{github.event.head_commit.message}}".Substring(10)
46+
Write-Output "relver=$relver">>$env:GITHUB_OUTPUT
47+
- name: Source checkout
48+
uses: actions/checkout@main
49+
with:
50+
submodules: recursive
51+
- name: Prepare MSBuild
52+
uses: microsoft/setup-msbuild@main
53+
- name: Build
54+
run: |
55+
msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=Release /p:Platform=x64 /p:RestorePackagesConfig=true
56+
msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=Release /p:Platform=x86 /p:RestorePackagesConfig=true
57+
msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=Release /p:Platform=ARM64 /p:RestorePackagesConfig=true
58+
msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=Release /p:Platform=ARM64EC /p:RestorePackagesConfig=true
59+
- name: Run Unit Test
60+
run: |
61+
.\Source\OutDir\x64\Release\UnitTest.exe -Run
62+
.\Source\OutDir\x86\Release\UnitTest.exe -Run
63+
- name: Create NuGet package
64+
run: |
65+
cd .\Source
66+
nuget pack
67+
- name: Create release
68+
uses: softprops/action-gh-release@v2
69+
with:
70+
name: v${{steps.relver.outputs.relver}}
71+
tag_name: v${{steps.relver.outputs.relver}}
72+
body: "**NuGet Package**: https://www.nuget.org/packages/KNSoft.NDK/${{steps.relver.outputs.relver}}"
73+
prerelease: true
74+
preserve_order: true
75+
fail_on_unmatched_files: true
76+
generate_release_notes: true
77+
files: ./Source/KNSoft.NDK.${{steps.relver.outputs.relver}}.nupkg

.github/workflows/msbuild.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# KNSoft.NDK
77

8-
[![NuGet Downloads](https://img.shields.io/nuget/dt/KNSoft.NDK)](https://www.nuget.org/packages/KNSoft.NDK) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KNSoft/KNSoft.NDK/msbuild.yml)](https://github.com/KNSoft/KNSoft.NDK/actions/workflows/msbuild.yml) ![PR Welcome](https://img.shields.io/badge/PR-welcome-0688CB.svg) [![GitHub License](https://img.shields.io/github/license/KNSoft/KNSoft.NDK)](https://github.com/KNSoft/KNSoft.NDK/blob/main/LICENSE)
8+
[![NuGet Downloads](https://img.shields.io/nuget/dt/KNSoft.NDK)](https://www.nuget.org/packages/KNSoft.NDK) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KNSoft/KNSoft.NDK/Build_Publish.yml)](https://github.com/KNSoft/KNSoft.NDK/actions/workflows/Build_Publish.yml) ![PR Welcome](https://img.shields.io/badge/PR-welcome-0688CB.svg) [![GitHub License](https://img.shields.io/github/license/KNSoft/KNSoft.NDK)](https://github.com/KNSoft/KNSoft.NDK/blob/main/LICENSE)
99

1010
[KNSoft.NDK](https://github.com/KNSoft/KNSoft.NDK) provides native C/C++ definitions and import libraries for Windows NT development.
1111

@@ -61,7 +61,7 @@ The following features **are enabled by default**, can be excluded by defining c
6161

6262
## Compatibility
6363

64-
![PR Welcome](https://img.shields.io/badge/PR-welcome-0688CB.svg) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KNSoft/KNSoft.NDK/msbuild.yml)](https://github.com/KNSoft/KNSoft.NDK/actions/workflows/msbuild.yml)
64+
![PR Welcome](https://img.shields.io/badge/PR-welcome-0688CB.svg) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KNSoft/KNSoft.NDK/Build_Publish.yml)](https://github.com/KNSoft/KNSoft.NDK/actions/workflows/Build_Publish.yml)
6565

6666
[KNSoft.NDK](https://github.com/KNSoft/KNSoft.NDK) always follow up the latest Windows NT and specifications, targets to x86, x64, ARM64, and ARM64EC platforms.
6767

README.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# KNSoft.NDK
77

8-
[![NuGet Downloads](https://img.shields.io/nuget/dt/KNSoft.NDK)](https://www.nuget.org/packages/KNSoft.NDK) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KNSoft/KNSoft.NDK/msbuild.yml)](https://github.com/KNSoft/KNSoft.NDK/actions/workflows/msbuild.yml) ![PR Welcome](https://img.shields.io/badge/PR-welcome-0688CB.svg) [![GitHub License](https://img.shields.io/github/license/KNSoft/KNSoft.NDK)](https://github.com/KNSoft/KNSoft.NDK/blob/main/LICENSE)
8+
[![NuGet Downloads](https://img.shields.io/nuget/dt/KNSoft.NDK)](https://www.nuget.org/packages/KNSoft.NDK) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KNSoft/KNSoft.NDK/Build_Publish.yml)](https://github.com/KNSoft/KNSoft.NDK/actions/workflows/Build_Publish.yml) ![PR Welcome](https://img.shields.io/badge/PR-welcome-0688CB.svg) [![GitHub License](https://img.shields.io/github/license/KNSoft/KNSoft.NDK)](https://github.com/KNSoft/KNSoft.NDK/blob/main/LICENSE)
99

1010
[KNSoft.NDK](https://github.com/KNSoft/KNSoft.NDK)提供了原始C/C++定义和引入库供Windows NT开发。
1111

@@ -61,7 +61,7 @@ NuGet包[KNSoft.NDK](https://www.nuget.org/packages/KNSoft.NDK)包含所有头
6161

6262
## 兼容性
6363

64-
![PR Welcome](https://img.shields.io/badge/PR-welcome-0688CB.svg) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KNSoft/KNSoft.NDK/msbuild.yml)](https://github.com/KNSoft/KNSoft.NDK/actions/workflows/msbuild.yml)
64+
![PR Welcome](https://img.shields.io/badge/PR-welcome-0688CB.svg) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/KNSoft/KNSoft.NDK/Build_Publish.yml)](https://github.com/KNSoft/KNSoft.NDK/actions/workflows/Build_Publish.yml)
6565

6666
[KNSoft.NDK](https://github.com/KNSoft/KNSoft.NDK)始终跟进最新的Windows NT和规范,目标x86、x64、ARM64和ARM64EC平台。
6767

0 commit comments

Comments
 (0)