-
Notifications
You must be signed in to change notification settings - Fork 215
128 lines (107 loc) · 3.42 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
name: CI
on: [push, pull_request, workflow_dispatch]
env:
ProjectName: ${{ github.event.repository.name }}
NET_TFM: net6.0-windows10.0.22621.0
Configuration: Release
jobs:
check_format:
runs-on: windows-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Checkout code
uses: actions/checkout@v3
- 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@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.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@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Build
shell: pwsh
run: .\build.ps1
- name: Upload
uses: actions/upload-artifact@v3
with:
name: ${{ env.ProjectName }}
path: ${{ env.ProjectName }}\bin\${{ env.Configuration }}\${{ env.NET_TFM }}\generic\publish\
nuget:
needs: [test, check_format]
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
strategy:
matrix:
PackageName:
- STUN
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.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
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ env.ProjectName }}
path: ${{ env.ProjectName }}
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
- name: Package
shell: pwsh
run: |
New-Item -ItemType Directory -Path builtfiles -Force > $null
$zip_path = "builtfiles/$env:ProjectName-${{ steps.tag.outputs.tag }}.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: 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 }}-${{ steps.tag.outputs.tag }}.7z</sub> | <sub>${{ env.GENERIC_SHA256 }}</sub> |