-
Notifications
You must be signed in to change notification settings - Fork 6
78 lines (62 loc) · 2.12 KB
/
publish-nuget.yml
File metadata and controls
78 lines (62 loc) · 2.12 KB
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
name: Publish NuGet
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
publish:
name: Pack and Publish
runs-on: windows-latest
permissions:
contents: read
env:
Solution_Name: MAS.Database.slnx
Project_Path: src/MAS.Database.csproj
Package_Output_Directory: build/NuGet
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
10.0.x
- name: Restore dependencies
shell: pwsh
run: dotnet restore $env:Solution_Name
- name: Build
shell: pwsh
run: dotnet build $env:Solution_Name --configuration Release --no-restore
- name: Test
shell: pwsh
run: dotnet test $env:Solution_Name --configuration Release --no-build
- name: Pack
shell: pwsh
run: dotnet pack $env:Project_Path --configuration Release --no-build --output $env:Package_Output_Directory
- name: List package output
shell: pwsh
run: |
Write-Host "Package output directory: $env:Package_Output_Directory"
if (-not (Test-Path $env:Package_Output_Directory)) {
throw "Package output directory does not exist: $env:Package_Output_Directory"
}
Get-ChildItem -Path $env:Package_Output_Directory -Force
- name: Publish to NuGet.org
shell: pwsh
run: |
$packages = Get-ChildItem -Path $env:Package_Output_Directory -Filter "*.nupkg" |
Where-Object { $_.Name -notlike "*.symbols.nupkg" -and $_.Name -notlike "*.snupkg" }
if (-not $packages) {
throw "No .nupkg files found in $env:Package_Output_Directory"
}
foreach ($package in $packages) {
Write-Host "Pushing package: $($package.FullName)"
dotnet nuget push $package.FullName `
--api-key "${{ secrets.NUGET_API_KEY }}" `
--source "https://api.nuget.org/v3/index.json" `
--skip-duplicate
}