-
Notifications
You must be signed in to change notification settings - Fork 5
76 lines (61 loc) · 1.94 KB
/
publish_nuget.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
name: "Deploy to NuGet"
on:
push:
branches: [ master ]
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+'
- 'v[0-9]+\.[0-9]+\.[0-9]+-beta[0-9][0-9]'
pull_request:
branches: [ master ]
env:
PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}\output
NUGET_SOURCE_URL: 'https://api.nuget.org/v3/index.json'
permissions:
contents: read
statuses: write
checks: write
jobs:
build:
name: 'Build'
runs-on: 'windows-latest'
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Install dotnet'
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: 'Restore packages'
run: dotnet restore
- name: 'Build project'
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --logger "trx;LogFileName=test-results.trx" --no-restore || true
- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true
deploy:
name: 'Nuget Push'
runs-on: 'windows-latest'
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Install dotnet'
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: 'Get Version'
id: version
uses: battila7/get-version-action@v2
- name: 'Pack project'
run: dotnet pack --configuration Release --include-symbols -p:Version=${{ steps.version.outputs.version-without-v }} --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }}
# --no-build somehow cannot be used due to being needed:
- name: 'Push package'
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIRECTORY }}\*.nupkg -k ${{ secrets.NUGET_AUTH_TOKEN }} -s ${{ env.NUGET_SOURCE_URL }}