-
Notifications
You must be signed in to change notification settings - Fork 215
169 lines (143 loc) · 5.21 KB
/
CI.yaml
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI
on: [push, pull_request, workflow_dispatch]
env:
ProjectName: ${{ github.event.repository.name }}
NET_TFM: net8.0-windows10.0.22621.0
Configuration: Release
jobs:
check_format:
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Checkout code
uses: actions/checkout@v4
- name: Run dotnet format check
run: dotnet format -v diag --verify-no-changes
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Run tests
working-directory: UnitTest
run: dotnet test -c Release
build:
needs: [test, check_format]
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
shell: pwsh
run: |
.\build.ps1
.\build.WinUI.ps1 x64
.\build.WinUI.ps1 arm64
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ env.ProjectName }}
path: ${{ env.ProjectName }}\bin\${{ env.Configuration }}\${{ env.NET_TFM }}\generic\publish\
- name: Upload WinUI x64
uses: actions/upload-artifact@v4
with:
name: ${{ env.ProjectName }}.WinUI.x64
path: ${{ env.ProjectName }}.WinUI\bin\x64\${{ env.Configuration }}\${{ env.NET_TFM }}\win-x64\publish\
- name: Upload WinUI arm64
uses: actions/upload-artifact@v4
with:
name: ${{ env.ProjectName }}.WinUI.arm64
path: ${{ env.ProjectName }}.WinUI\bin\arm64\${{ env.Configuration }}\${{ env.NET_TFM }}\win-arm64\publish\
nuget:
needs: [test, check_format]
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
matrix:
PackageName:
- STUN
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
working-directory: ${{ matrix.PackageName }}
run: dotnet build -c Release
- name: Push nuget packages
working-directory: ${{ matrix.PackageName }}/bin/Release
run: |
dotnet nuget push *.nupkg -s https://nuget.pkg.github.com/HMBSbige -k ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NuGetAPIKey }} --skip-duplicate
release:
needs: [build, nuget]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ env.ProjectName }}
path: ${{ env.ProjectName }}
- uses: actions/download-artifact@v4
with:
name: ${{ env.ProjectName }}.WinUI.x64
path: ${{ env.ProjectName }}.WinUI.x64
- uses: actions/download-artifact@v4
with:
name: ${{ env.ProjectName }}.WinUI.arm64
path: ${{ env.ProjectName }}.WinUI.arm64
- name: Package
shell: pwsh
run: |
New-Item -ItemType Directory -Path builtfiles -Force > $null
$zip_path = "builtfiles/$env:ProjectName-${{ github.ref_name }}.7z"
7z a -mx9 "$zip_path" ${{ env.ProjectName }}
echo "GENERIC_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Package WinUI x64
shell: pwsh
run: |
$zip_path = "builtfiles/$env:ProjectName-${{ github.ref_name }}-x64.7z"
7z a -mx9 "$zip_path" ${{ env.ProjectName }}.WinUI.x64
echo "X64_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Package WinUI arm64
shell: pwsh
run: |
$zip_path = "builtfiles/$env:ProjectName-${{ github.ref_name }}-arm64.7z"
7z a -mx9 "$zip_path" ${{ env.ProjectName }}.WinUI.arm64
echo "ARM64_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Create a new GitHub release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
draft: false
artifacts: builtfiles/*
body: |
## Hash
| Filename | SHA-256 |
| :- | :- |
| <sub>${{ env.ProjectName }}-${{ github.ref_name }}.7z</sub> | <sub>${{ env.GENERIC_SHA256 }}</sub> |
| <sub>${{ env.ProjectName }}-${{ github.ref_name }}-x64.7z</sub> | <sub>${{ env.X64_SHA256 }}</sub> |
| <sub>${{ env.ProjectName }}-${{ github.ref_name }}-arm64.7z</sub> | <sub>${{ env.ARM64_SHA256 }}</sub> |