Skip to content

Commit 47498a2

Browse files
authored
Update csharp.yml
1 parent ba79f44 commit 47498a2

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

.github/workflows/csharp.yml

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,52 @@ jobs:
2727
run: |
2828
dotnet test -c Release -f net8
2929
30-
pushNuGetPackageToGitHubPackageRegistry:
31-
needs: test
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v4
30+
pushNuGetPackageToGitHubPackageRegistry:
31+
needs: test
32+
runs-on: ubuntu-latest
33+
steps:
34+
# 1. Checkout the repository
35+
- uses: actions/checkout@v4
36+
with:
37+
submodules: true
38+
39+
# 2. Setup .NET SDK
40+
- name: Setup .NET
41+
uses: actions/setup-dotnet@v3
3542
with:
36-
submodules: true
37-
- uses: nuget/setup-nuget@v1
38-
- name: Publish NuGet package to GitHub Package Registry
43+
dotnet-version: '8.0.x' # Specify your required .NET version
44+
45+
# 3. Restore dependencies
46+
- name: Restore dependencies
47+
run: dotnet restore
48+
49+
# 4. Build the project
50+
- name: Build
51+
run: dotnet build --configuration Release --no-restore
52+
53+
# 5. Pack the project into a NuGet package
54+
- name: Pack
55+
run: dotnet pack --configuration Release --no-restore --output ./nupkgs
56+
57+
# 6. Add GitHub Package Registry as a NuGet source
58+
- name: Add GitHub Package Registry as NuGet Source
59+
run: |
60+
dotnet nuget add source "https://nuget.pkg.github.com/linksplatform/index.json" \
61+
--name "GitHub" \
62+
--username "linksplatform" \
63+
--password "${{ secrets.GITHUB_TOKEN }}" \
64+
--store-password-in-clear-text
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
# 7. Push the NuGet package to GitHub Package Registry
69+
- name: Push NuGet Package to GitHub Package Registry
3970
run: |
40-
dotnet build -c Release
41-
dotnet pack -c Release
42-
nuget source Add -Name "GitHub" -Source "https://nuget.pkg.github.com/linksplatform/index.json" -UserName linksplatform -Password ${{ secrets.GITHUB_TOKEN }}
43-
nuget push **/*.nupkg -Source "GitHub" -SkipDuplicate
71+
dotnet nuget push ./nupkgs/*.nupkg \
72+
--source "GitHub" \
73+
--api-key "${{ secrets.GITHUB_TOKEN }}"
74+
env:
75+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4476

4577
pusnToNuget:
4678
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)