1+ # GitHub Actions workflow for building, packing, and publishing the WaveLink.Client library.
2+ # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
3+
4+ name : Build and Publish WaveLink.Client
5+
6+ on :
7+ workflow_dispatch :
8+ push :
9+ branches : [ main ]
10+ pull_request :
11+ branches : [ main ]
12+ release :
13+ types :
14+ - published
15+
16+ env :
17+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : 1
18+ DOTNET_NOLOGO : true
19+ NuGetDirectory : ${{ github.workspace }}/nuget
20+
21+ defaults :
22+ run :
23+ shell : pwsh
24+
25+ jobs :
26+ build_and_pack :
27+ name : Build and Pack
28+ runs-on : ubuntu-latest
29+
30+ steps :
31+ - name : Checkout code
32+ uses : actions/checkout@v4
33+ with :
34+ fetch-depth : 0
35+
36+ - name : Setup .NET SDKs
37+ uses : actions/setup-dotnet@v4
38+ with :
39+ dotnet-version : |
40+ 9.0.x
41+ 10.0.x
42+
43+ - name : Restore dependencies
44+ run : dotnet restore WaveLink.Client.slnx
45+
46+ - name : Clean solution
47+ run : dotnet clean WaveLink.Client.slnx --configuration Release
48+
49+ - name : Build solution
50+ run : dotnet build WaveLink.Client.slnx --configuration Release --no-restore
51+
52+ # TODO: 'dotnet test' step removed since there is no test project in the .slnx yet.
53+
54+ - name : Pack library (on main push or release)
55+ if : (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release'
56+ run : >
57+ dotnet pack WaveLink.Client.slnx
58+ --configuration Release
59+ --no-build
60+ -p:IncludeSymbols=true
61+ -p:SymbolPackageFormat=snupkg
62+ --output ${{ env.NuGetDirectory }}
63+
64+ - name : Upload NuGet package artifact (on main push or release)
65+ if : (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release'
66+ uses : actions/upload-artifact@v4
67+ with :
68+ name : nuget-package
69+ if-no-files-found : error
70+ retention-days : 7
71+ # The *nupkg wildcard captures both .nupkg and .snupkg files
72+ path : ${{ env.NuGetDirectory }}/*nupkg
73+
74+ publish_nuget :
75+ name : Publish NuGet Package
76+ needs : [ build_and_pack ]
77+ if : github.event_name == 'release' && github.event.action == 'published'
78+ runs-on : ubuntu-latest
79+ permissions :
80+ contents : read
81+ id-token : write
82+
83+ steps :
84+ - name : Download NuGet package artifact
85+ uses : actions/download-artifact@v4
86+ with :
87+ name : nuget-package
88+ path : ${{ env.NuGetDirectory }}
89+
90+ - name : Setup .NET SDK
91+ uses : actions/setup-dotnet@v4
92+
93+ - name : Display package information
94+ run : Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *nupkg | ForEach-Object { $_.FullName }
95+
96+ - name : NuGet login (OIDC -> temp API key)
97+ uses : NuGet/login@v1
98+ with :
99+ user : Agash
100+
101+ - name : Publish NuGet package to NuGet.org
102+ # The dotnet nuget push command automatically pushes the .snupkg if it sits next to the .nupkg, so we only need to specify the .nupkg file here.
103+ run : |
104+ foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
105+ Write-Host "Pushing package: $($file.FullName)"
106+ dotnet nuget push $file --source https://api.nuget.org/v3/index.json --skip-duplicate
107+ }
0 commit comments