From c2bf9cb4ad7f6aeef32585cc727b37143440b73f Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Sat, 11 Jul 2026 19:34:04 +0200 Subject: [PATCH] Added NuGet publish Action --- .../workflows/{dotnetcore.yml => build.yml} | 0 .github/workflows/publish-nuget.yml | 48 +++++++++++++++++++ 2 files changed, 48 insertions(+) rename .github/workflows/{dotnetcore.yml => build.yml} (100%) create mode 100644 .github/workflows/publish-nuget.yml diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/build.yml similarity index 100% rename from .github/workflows/dotnetcore.yml rename to .github/workflows/build.yml diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml new file mode 100644 index 0000000..d278dc2 --- /dev/null +++ b/.github/workflows/publish-nuget.yml @@ -0,0 +1,48 @@ +name: Publish NuGet Package + +on: + workflow_dispatch: + inputs: + version: + description: 'Package version to publish (e.g. 3.0.1). Leave empty to use the version currently set in API.csproj' + required: false + type: string + +jobs: + publish: + + runs-on: windows-latest + + permissions: + id-token: write # enable GitHub OIDC token issuance, required for NuGet Trusted Publishing + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + + - name: Restore dependencies + run: dotnet restore Api\API.csproj + + - name: Build + run: dotnet build Api\API.csproj --configuration Release --no-restore + + - name: Pack (with specified version) + if: ${{ github.event.inputs.version != '' }} + run: dotnet pack Api\API.csproj --configuration Release --no-build --output ./nupkg /p:PackageVersion=${{ github.event.inputs.version }} /p:Version=${{ github.event.inputs.version }} + + - name: Pack (with version from csproj) + if: ${{ github.event.inputs.version == '' }} + run: dotnet pack Api\API.csproj --configuration Release --no-build --output ./nupkg + + - name: NuGet login (OIDC → temp API key) + uses: NuGet/login@v1 + id: login + with: + user: ${{ secrets.NUGET_USER }} + + - name: Publish to NuGet + run: dotnet nuget push ./nupkg/KoenZomers.OneDrive.Api.*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate