1- name : Build
1+ name : Build .NET and Publish to Nuget
22
3+ # This workflow will run when: 1) any commit is pushed to main, 2) any pull request is opened that will merge to main, and 3) whenever a new release is published.
34on :
45 push :
5- branches : [main]
6+ branches : [main] # 1) Generates a package on Github that is a pre-release package, and is typically named X.Y.Z-main-ci000, where X/Y/Z are the semantic version numbers, and ci000 is incremented for each action that is run, guaranteeing a unique package name
67 pull_request :
7- branches : [main]
8+ branches : [main] # 2) Does not generate a package, but does check that the semantic version number is increasing, and that the package builds correctly in all matrix configurations (Ubuntu / Windows and Release / Debug)
89 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 }}
10+ types : [published] # 3) Generates a package that is a full release package (X.Y.Z) that is published to Github and NuGet automatically
1911
2012jobs :
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- CiBuildVersionSuffix : ${{ 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 : ubuntu-latest
102- needs : [build]
103- if : github.event_name == 'release'
104-
105- steps :
106- - name : Setup .NET
107- uses : actions/setup-dotnet@v4
108- with :
109- dotnet-version : 8.x
110-
111- - name : Download packages
112- uses : actions/download-artifact@v4
113- with :
114- name : Packages
115- path : Packages
116-
117- - name : Publish NuGet Package
118- run : dotnet nuget push "Packages/*.nupkg" --skip-duplicate --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json
13+ build_and_publish :
14+ uses : open-ephys/github-actions/.github/workflows/build_dotnet_publish_nuget.yml@main
15+ secrets :
16+ NUGET_APIKEY : ${{ secrets.NUGET_APIKEY }}
0 commit comments