-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (53 loc) · 1.67 KB
/
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# inspired by:
# https://www.meziantou.net/publishing-a-nuget-package-following-best-practices-using-github.htm
name: nuget
on:
release:
types:
- published
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NUGET_DIRECTORY: ${{ github.workspace }}/nuget
ASSEMBLY_NAME: "SWE1R.Assets.Blocks"
defaults:
run:
shell: pwsh
jobs:
create_nuget:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4 # see global.json for version
- run: |
cd src
dotnet pack ${{ env.ASSEMBLY_NAME }} --configuration Release --output ${{ env.NUGET_DIRECTORY }}
- uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: |
${{ env.NUGET_DIRECTORY }}/*.nupkg
${{ env.NUGET_DIRECTORY }}/*.snupkg
deploy:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ create_nuget ]
steps:
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NUGET_DIRECTORY }}
- name: Setup .NET
uses: actions/setup-dotnet@v4 # see global.json for version
- name: Publish NuGet package
run: |
$packages = Get-ChildItem "${{ env.NUGET_DIRECTORY }}" -Recurse -Include *.nupkg
foreach ($file in $packages) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json
}