Skip to content

Commit f960de7

Browse files
committed
Break up build and NuGet publish to separate sections
- Introducing a separate job dedicated to NuGet publishing, triggered only for tagged builds. - Uploading the NuGet package as an artifact in the build job. - Downloading the artifact in the publish job. - Corrects the path to the NuGet package in the push command, using the output version from the build job.
1 parent 8dd9e57 commit f960de7

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ on:
99

1010
jobs:
1111
build:
12-
name: Build Job
12+
name: Build and Test
1313
runs-on: macos-15
14+
outputs:
15+
version: ${{ steps.gitversion.outputs.semVer }}
1416
defaults:
1517
run:
1618
working-directory: Source
@@ -20,8 +22,7 @@ jobs:
2022
uses: actions/checkout@v5
2123
with:
2224
fetch-depth: 0 # Required for Calculate Version step (e.g. GitVersion)
23-
24-
# Required by GitVersion
25+
2526
- name: Install .NET 8.0
2627
uses: actions/setup-dotnet@v5
2728
with:
@@ -42,21 +43,45 @@ jobs:
4243
useConfigFile: true
4344
updateProjectFiles: true
4445

45-
- name: NuGet
46+
- name: NuGet Restore
4647
run: dotnet restore
4748

4849
# Smoke test to make sure the Example Client builds. We don't do a release build
4950
# of the Example Client because it takes a long time and we don't publish it.
50-
- name: Debug Build of Solution to Smoke test Example Client
51+
- name: Debug Build of Solution to Smoke Test Example Client
5152
run: dotnet build -c Debug
5253

5354
- name: Create NuGet Package
5455
run: dotnet pack SaturdayMP.XPlugins.iOS.BEMCheckBox/SaturdayMP.XPlugins.iOS.BEMCheckBox.csproj -c Release
5556

57+
- name: Upload NuGet Package Artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: nuget-package
61+
path: Source/SaturdayMP.XPlugins.iOS.BEMCheckBox/bin/Release/SaturdayMP.XPlugins.iOS.BEMCheckBox.${{ steps.gitversion.outputs.semVer }}..nupkg
62+
retention-days: 90
63+
5664
- name: Publish to MyGet
5765
run: dotnet nuget push SaturdayMP.XPlugins.iOS.BEMCheckBox/bin/Release/SaturdayMP.XPlugins.iOS.BEMCheckBox.${{ steps.gitversion.outputs.semVer }}.nupkg -k ${{ secrets.MYGET_API_KEY }} -s https://www.myget.org/F/saturdaymp/api/v3/index.json
5866

59-
# Only push tagged builds to NuGet. These will be production or release candidates.
60-
- name: Upload to NuGet
61-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
62-
run: dotnet nuget push SaturdayMP.XPlugins.iOS.BEMCheckBox/bin/Release/SaturdayMP.XPlugins.iOS.BEMCheckBox.${{ steps.gitversion.outputs.semVer }}.nupkg -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate --no-symbols -s https://api.nuget.org/v3/index.json
67+
publish-nuget:
68+
name: Publish to NuGet
69+
runs-on: ubuntu-latest
70+
needs: build
71+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
72+
73+
steps:
74+
- name: Install .NET 8.0
75+
uses: actions/setup-dotnet@v5
76+
with:
77+
dotnet-version: 8.0
78+
79+
- name: Download NuGet Package Artifact
80+
uses: actions/download-artifact@v4
81+
with:
82+
name: nuget-package
83+
path: ./packages
84+
85+
# Only push tagged builds to NuGet. These will be production or release candidates.
86+
- name: Publish to NuGet
87+
run: dotnet nuget push ./packages/SaturdayMP.XPlugins.iOS.BEMCheckBox.${{ needs.build.outputs.version }}.nupkg -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate --no-symbols -s https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)