-
Notifications
You must be signed in to change notification settings - Fork 51
143 lines (124 loc) · 5.45 KB
/
CI.yml
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
name: CI
on: [push, pull_request, workflow_dispatch]
env:
ProjectName: BilibiliLiveRecordDownLoader
NET_TFM: net8.0-windows10.0.22621.0
Configuration: Release
jobs:
build:
name: Build
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
runs-on: windows-latest
strategy:
matrix:
Rid: [generic, win-x64, win-x86, win-arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build ${{ matrix.Rid }}
shell: pwsh
run: .\build.ps1 ${{ matrix.Rid }}
- name: Upload ${{ matrix.Rid }}
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ${{ env.ProjectName }}-${{ matrix.Rid }}
path: ${{ env.ProjectName }}\bin\${{ env.Configuration }}\${{ env.NET_TFM }}\${{ matrix.Rid }}\publish\
nuget:
name: Nuget
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
strategy:
matrix:
PackageName:
[
BilibiliLiveRecordDownLoader.Shared,
BilibiliLiveRecordDownLoader.BilibiliApi,
]
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: dotnet build -c Release ${{ matrix.PackageName }}\${{ matrix.PackageName }}.csproj
- name: Push nuget packages
shell: pwsh
run: |
dotnet nuget push ${{ matrix.PackageName }}\bin\Release\*.nupkg -s https://nuget.pkg.github.com/HMBSbige -k ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
dotnet nuget push ${{ matrix.PackageName }}\bin\Release\*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NuGetAPIKey }} --skip-duplicate
release:
name: Release
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
shell: pwsh
run: .\build.ps1
- name: Package generic
shell: pwsh
run: |
New-Item -ItemType Directory -Path C:\builtfiles -Force > $null
$zip_path = "C:\builtfiles\$env:ProjectName-generic-${{ github.ref_name }}.7z"
7z a -mx9 "$zip_path" ".\$env:ProjectName\bin\$env:Configuration\$env:NET_TFM\generic\publish\"
7z rn "$zip_path" publish $env:ProjectName
echo "GENERIC_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Package win-x64
shell: pwsh
run: |
New-Item -ItemType Directory -Path C:\builtfiles -Force > $null
$zip_path = "C:\builtfiles\$env:ProjectName-win-x64-${{ github.ref_name }}.7z"
7z a -mx9 "$zip_path" ".\$env:ProjectName\bin\$env:Configuration\$env:NET_TFM\win-x64\publish\"
7z rn "$zip_path" publish $env:ProjectName
echo "WINX64_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Package win-arm64
shell: pwsh
run: |
New-Item -ItemType Directory -Path C:\builtfiles -Force > $null
$zip_path = "C:\builtfiles\$env:ProjectName-win-arm64-${{ github.ref_name }}.7z"
7z a -mx9 "$zip_path" ".\$env:ProjectName\bin\$env:Configuration\$env:NET_TFM\win-arm64\publish\"
7z rn "$zip_path" publish $env:ProjectName
echo "WINARM64_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Package win-x86
shell: pwsh
run: |
New-Item -ItemType Directory -Path C:\builtfiles -Force > $null
$zip_path = "C:\builtfiles\$env:ProjectName-win-x86-${{ github.ref_name }}.7z"
7z a -mx9 "$zip_path" ".\$env:ProjectName\bin\$env:Configuration\$env:NET_TFM\win-x86\publish\"
7z rn "$zip_path" publish $env:ProjectName
echo "WINX86_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Create a new GitHub release if a new tag is pushed
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: v${{ github.ref_name }}
prerelease: true
draft: false
artifacts: C:\builtfiles\*
body: |
## 更新日志:
* 这是 GitHub Actions 自动化部署,更新日志应该很快会手动更新
## 文件校验
| 文件名 | SHA256 |
| :- | :- |
| <sub>${{ env.ProjectName }}-generic-${{ github.ref_name }}.7z</sub> | <sub>${{ env.GENERIC_SHA256 }}</sub> |
| <sub>${{ env.ProjectName }}-win-x64-${{ github.ref_name }}.7z</sub> | <sub>${{ env.WINX64_SHA256 }}</sub> |
| <sub>${{ env.ProjectName }}-win-arm64-${{ github.ref_name }}.7z</sub> | <sub>${{ env.WINARM64_SHA256 }}</sub> |
| <sub>${{ env.ProjectName }}-win-x86-${{ github.ref_name }}.7z</sub> | <sub>${{ env.WINX86_SHA256 }}</sub> |