1+ name : Build
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+ release :
9+ types : [published]
10+
11+ env :
12+ DOTNET_NOLOGO : true
13+ DOTNET_CLI_TELEMETRY_OPTOUT : true
14+ DOTNET_GENERATE_ASPNET_CERTIFICATE : false
15+ ContinuousIntegrationBuild : true
16+ CiRunNumber : ${{ github.run_number }}
17+ CiRunPushSuffix : ${{ github.ref_name }}-ci${{ github.run_number }}
18+ CiRunPullSuffix : pull-${{ github.event.number }}-ci${{ github.run_number }}
19+
20+ jobs :
21+ setup :
22+ runs-on : ubuntu-latest
23+ outputs :
24+ build-suffix : ${{ steps.setup-build.outputs.build-suffix }}
25+ steps :
26+ - name : Setup Build
27+ id : setup-build
28+ run : echo "build-suffix=${{ github.event_name == 'push' && env.CiRunPushSuffix || github.event_name == 'pull_request' && env.CiRunPullSuffix || null }}" >> "$GITHUB_OUTPUT"
29+
30+ build :
31+ needs : setup
32+ name : Build Package
33+ strategy :
34+ fail-fast : false
35+ matrix :
36+ configuration : [debug, release]
37+ os : [ubuntu-latest, windows-latest]
38+ include :
39+ - os : windows-latest
40+ configuration : release
41+ collect-packages : true
42+ runs-on : ${{ matrix.os }}
43+ env :
44+ CiBuildVersionSuffic : ${{ needs.setup.outputs.build-suffix }}
45+
46+ steps :
47+ - name : Checkout
48+ uses : actions/checkout@v4
49+
50+ - name : Setup .NET
51+ uses : actions/setup-dotnet@v4
52+ with :
53+ dotnet-version : 8.x
54+
55+ - name : Restore NuGet Packages
56+ run : dotnet restore
57+
58+ - name : Build Project
59+ run : dotnet build --no-restore --configuration ${{ matrix.configuration }}
60+
61+ - name : Pack
62+ id : pack
63+ if : matrix.collect-packages
64+ run : dotnet pack --no-build --configuration ${{ matrix.configuration }}
65+
66+ - name : Upload Artifacts
67+ uses : actions/upload-artifact@v4
68+ if : matrix.collect-packages && steps.pack.outcome == 'success' && always()
69+ with :
70+ name : Packages
71+ if-no-files-found : error
72+ path : artifacts/package/${{ matrix.configuration }}/**
73+
74+ publish-github :
75+ runs-on : ubuntu-latest
76+ permissions :
77+ packages : write
78+ needs : [build]
79+ if : github.event_name == 'push' || github.event_name == 'release'
80+
81+ steps :
82+ - name : Setup .NET
83+ uses : actions/setup-dotnet@v4
84+ with :
85+ dotnet-version : 8.x
86+
87+ - name : Download packages
88+ uses : actions/download-artifact@v4
89+ with :
90+ name : Packages
91+ path : Packages
92+
93+ - name : Push to GitHub Packages
94+ run : dotnet nuget push "Packages/*.nupkg" --skip-duplicate --no-symbols --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}
95+ env :
96+ # This is a workaround for https://github.com/NuGet/Home/issues/9775
97+ DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER : 0
98+
99+ deploy :
100+ name : Deploy Package
101+ runs-on : windows-latest
102+ needs : [build, publish-github]
103+ if : github.event_name == 'release'
104+
105+ steps :
106+ - name : Download packages
107+ uses : actions/download-artifact@v4
108+ with :
109+ name : Packages
110+ path : Packages
111+
112+ - name : Setup .NET Core
113+ uses : actions/setup-dotnet@v4
114+
115+ - name : Publish NuGet Package
116+ run : dotnet nuget push *nupkg --skip-duplicate --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json
0 commit comments