-
Notifications
You must be signed in to change notification settings - Fork 5
77 lines (74 loc) · 2.17 KB
/
main.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
name: Package nuget
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
RESULT_DIR: result
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
source-url: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Restore dotnet tools
run: dotnet tool restore
- name: Restore dependencies
run: msbuild -r
- name: Build package
run:
./pack.ps1 -PackageOutputPath="${{ env.RESULT_DIR }}"
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages
path: ${{ env.RESULT_DIR }}
publish_to_github:
runs-on: ubuntu-latest
needs: [ build ]
environment: nuget
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: packages
path: ${{ env.RESULT_DIR }}
- name: Publish to github
run: |
dotnet nuget push "result/*.nupkg" \
--source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
--no-symbols \
--skip-duplicate \
--api-key ${GITHUB_TOKEN}
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
publish_to_nuget:
runs-on: ubuntu-latest
needs: [ build ]
environment: nuget
if: github.base_ref == '' # this would be set only on pull_request builds
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: packages
path: ${{ env.RESULT_DIR }}
- name: Publish to nuget.org
run: |
dotnet nuget push "result/*.nupkg" \
--source "nuget.org" \
--skip-duplicate \
--api-key ${NUGET_TOKEN}
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}