-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (43 loc) · 1.35 KB
/
nuget-publish.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
name: Publish NuGet Package
on:
push:
branches:
- main # 触发工作流的分支
jobs:
build:
runs-on: ubuntu-latest
env:
PROJECT_DIR: EfCore.NamingConverter # 工作目录
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET 8.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup .NET 9.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: ${{ env.PROJECT_DIR }}
- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: ${{ env.PROJECT_DIR }}
- name: Pack
run: dotnet pack --configuration Release --no-build --output ./nupkg
working-directory: ${{ env.PROJECT_DIR }}
- name: Upload NuGet package
uses: actions/upload-artifact@v3
with:
name: nuget-package
path: ${{ env.PROJECT_DIR }}/nupkg/*.nupkg
- name: Publish to NuGet
if: github.ref == 'refs/heads/main'
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./nupkg/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate
working-directory: ${{ env.PROJECT_DIR }}