-
Notifications
You must be signed in to change notification settings - Fork 5
82 lines (79 loc) · 2.46 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
78
79
80
81
82
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}}
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Restore dotnet tools
run: dotnet tool restore
- name: Build package
run: |
$packageOutputPath = Join-Path -Path $(pwd) -ChildPath ${{ env.RESULT_DIR }}
New-Item -Path $packageOutputPath -ItemType Directory -Force
msbuild -t:Restore -p:Configuration=Release
./pack.ps1 -PackageOutputPath $packageOutputPath
- 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 "${{ env.RESULT_DIR }}/*.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 "${{ env.RESULT_DIR }}/*.nupkg" \
--source "nuget.org" \
--skip-duplicate \
--api-key ${NUGET_TOKEN}
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}