diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 19ce60a..df117d0 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -25,20 +25,52 @@ jobs: - name: Test run: | dotnet test -c Release -f net8 - pushNuGetPackageToGitHubPackageRegistry: - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 + pushNuGetPackageToGitHubPackageRegistry: + needs: test + runs-on: ubuntu-latest + steps: + # 1. Checkout the repository + - uses: actions/checkout@v3 + with: + submodules: true + + # 2. Setup .NET SDK + - name: Setup .NET + uses: actions/setup-dotnet@v3 with: - submodules: true - - uses: nuget/setup-nuget@v1 - - name: Publish NuGet package to GitHub Package Registry + dotnet-version: '8.0.x' # Specify your required .NET version + + # 3. Restore dependencies + - name: Restore dependencies + run: dotnet restore + + # 4. Build the project + - name: Build + run: dotnet build --configuration Release --no-restore + + # 5. Pack the project into a NuGet package + - name: Pack + run: dotnet pack --configuration Release --no-restore --output ./nupkgs + + # 6. Add GitHub Package Registry as a NuGet source + - name: Add GitHub Package Registry as NuGet Source + run: | + dotnet nuget add source "https://nuget.pkg.github.com/linksplatform/index.json" \ + --name "GitHub" \ + --username "linksplatform" \ + --password "${{ secrets.GITHUB_TOKEN }}" \ + --store-password-in-clear-text + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # 7. Push the NuGet package to GitHub Package Registry + - name: Push NuGet Package to GitHub Package Registry run: | - dotnet build -c Release - dotnet pack -c Release - nuget source Add -Name "GitHub" -Source "https://nuget.pkg.github.com/linksplatform/index.json" -UserName linksplatform -Password ${{ secrets.GITHUB_TOKEN }} - nuget push **/*.nupkg -Source "GitHub" -SkipDuplicate + dotnet nuget push ./nupkgs/*.nupkg \ + --source "GitHub" \ + --api-key "${{ secrets.GITHUB_TOKEN }}" + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} pusnToNuget: runs-on: ubuntu-latest needs: test