From 4c2a6df3f1cc561c4a36f4523450e68cf55c546d Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <5808377+304NotModified@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:02:36 +0200 Subject: [PATCH 1/4] Update nuget.yml --- .github/workflows/nuget.yml | 57 ++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index c803dd1..0190433 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -8,6 +8,15 @@ on: branches: - master workflow_dispatch: + inputs: + force_nuget_publish: + description: Force NuGet publish + type: boolean + default: false + +env: + SOLUTION: src/NLog.MailKit.sln + DOTNET_VERSION: '8.0.x' jobs: pack: @@ -23,26 +32,31 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v6 with: - dotnet-version: '8.0.x' + dotnet-version: ${{ env.DOTNET_VERSION }} - name: Restore - run: dotnet restore src/NLog.MailKit.sln + run: dotnet restore ${{ env.SOLUTION }} - name: Build - run: dotnet build src/NLog.MailKit.sln --configuration Release --no-restore + run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore - name: Determine version suffix id: version shell: pwsh + env: + REF: ${{ github.ref }} + HEAD_REF: ${{ github.head_ref }} + REF_NAME: ${{ github.ref_name }} + PR_NUMBER: ${{ github.event.pull_request.number }} + RUN_NUMBER: ${{ github.run_number }} run: | - $ref = "${{ github.ref }}" - if ($ref -eq "refs/heads/master") { + if ($env:REF -eq "refs/heads/master") { echo "suffix=" >> $env:GITHUB_OUTPUT } else { # For a PR: use head_ref (actual branch name), otherwise the ref name - $branchName = "${{ github.head_ref }}" + $branchName = $env:HEAD_REF if ([string]::IsNullOrEmpty($branchName)) { - $branchName = "${{ github.ref_name }}" + $branchName = $env:REF_NAME } # Sanitize: non-alphanumeric -> '-', multiple '-' -> one, trim '-' @@ -53,24 +67,21 @@ jobs: $short = if ($clean.Length -gt 0) { $clean.Substring(0, [Math]::Min(40, $clean.Length)).TrimEnd('-') } else { "" } # PR number prefix - $prNumber = "${{ github.event.pull_request.number }}" - $prPrefix = if ($prNumber) { "pr${prNumber}-" } else { "" } - - # Build number - $build = "${{ github.run_number }}" + $prPrefix = if ($env:PR_NUMBER) { "pr$($env:PR_NUMBER)-" } else { "" } - $suffix = "${prPrefix}${short}.${build}" + $suffix = "${prPrefix}${short}.$($env:RUN_NUMBER)" echo "suffix=$suffix" >> $env:GITHUB_OUTPUT } - name: Pack shell: pwsh + env: + VERSION_SUFFIX: ${{ steps.version.outputs.suffix }} run: | - $versionSuffix = "${{ steps.version.outputs.suffix }}" - if ($versionSuffix) { - dotnet pack src/NLog.MailKit.sln --no-build --configuration Release --output artifacts --version-suffix "$versionSuffix" + if ($env:VERSION_SUFFIX) { + dotnet pack $env:SOLUTION --no-build --configuration Release --output artifacts --version-suffix "$env:VERSION_SUFFIX" } else { - dotnet pack src/NLog.MailKit.sln --no-build --configuration Release --output artifacts + dotnet pack $env:SOLUTION --no-build --configuration Release --output artifacts } - name: Upload nuget package @@ -80,13 +91,19 @@ jobs: path: artifacts/*pkg - name: NuGet login - if: github.ref == 'refs/heads/master' + if: >- + (github.event_name == 'workflow_run' && github.ref == 'refs/heads/master') || + (github.event_name == 'workflow_dispatch' && inputs.force_nuget_publish) uses: NuGet/login@v1 id: login with: user: ${{ secrets.NUGET_USER }} - name: Push to NuGet.org - if: github.ref == 'refs/heads/master' + if: >- + (github.event_name == 'workflow_run' && github.ref == 'refs/heads/master') || + (github.event_name == 'workflow_dispatch' && inputs.force_nuget_publish) shell: pwsh - run: dotnet nuget push artifacts\*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + env: + NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }} + run: dotnet nuget push artifacts\*.nupkg --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate From 9765a76c2ba3843735998abcde4460c6f7d0e849 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <5808377+304NotModified@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:04:17 +0200 Subject: [PATCH 2/4] Update build-and-test.yml --- .github/workflows/build-and-test.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f0a0194..efca1db 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -7,6 +7,10 @@ on: pull_request: workflow_dispatch: +env: + SOLUTION: src/NLog.MailKit.sln + DOTNET_VERSION: '8.0.x' + jobs: build: strategy: @@ -22,13 +26,13 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v6 with: - dotnet-version: '8.0.x' + dotnet-version: ${{ env.DOTNET_VERSION }} - name: Restore - run: dotnet restore src/NLog.MailKit.sln + run: dotnet restore ${{ env.SOLUTION }} - name: Build - run: dotnet build src/NLog.MailKit.sln --configuration Release --no-restore + run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore - name: Test - run: dotnet test src/NLog.MailKit.sln --configuration Release --no-build --logger "console;verbosity=normal" + run: dotnet test ${{ env.SOLUTION }} --configuration Release --no-build --logger "console;verbosity=normal" From 38aacbdf9716842399995f4f579499697526df49 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <5808377+304NotModified@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:06:39 +0200 Subject: [PATCH 3/4] Update build-and-test.yml --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index efca1db..8f4086e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -9,7 +9,7 @@ on: env: SOLUTION: src/NLog.MailKit.sln - DOTNET_VERSION: '8.0.x' + DOTNET_SDK_VERSION: '8.0.x' jobs: build: @@ -26,7 +26,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v6 with: - dotnet-version: ${{ env.DOTNET_VERSION }} + dotnet-version: ${{ env.DOTNET_SDK_VERSION }} - name: Restore run: dotnet restore ${{ env.SOLUTION }} From aa8805d7df7686c61f026409a7828a167e7ae537 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <5808377+304NotModified@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:06:56 +0200 Subject: [PATCH 4/4] Update nuget.yml --- .github/workflows/nuget.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 0190433..6a99c4a 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -16,7 +16,7 @@ on: env: SOLUTION: src/NLog.MailKit.sln - DOTNET_VERSION: '8.0.x' + DOTNET_SDK_VERSION: '8.0.x' jobs: pack: @@ -32,7 +32,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v6 with: - dotnet-version: ${{ env.DOTNET_VERSION }} + dotnet-version: ${{ env.DOTNET_SDK_VERSION }} - name: Restore run: dotnet restore ${{ env.SOLUTION }}