From e29332a09f75598bf0a4f33971699e708c4a7c75 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 03:55:14 +0000 Subject: [PATCH 1/2] Initial plan From 8af0cebaa722de7c84486a5b2656993d8ea72df3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 03:57:14 +0000 Subject: [PATCH 2/2] Update nuget.yml: use pwsh, fix PR branch name, add PR number and run number to version suffix Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com> --- .github/workflows/nuget.yml | 49 ++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 8d84fc3..17deb2d 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -30,24 +30,45 @@ jobs: - name: Determine version suffix id: version - shell: bash + shell: pwsh run: | - if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then - echo "suffix=" >> $GITHUB_OUTPUT - else - CLEAN=$(echo "$GITHUB_REF_NAME" | sed 's/[^a-zA-Z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//;s/-$//') - echo "suffix=$CLEAN" >> $GITHUB_OUTPUT - fi + $ref = "${{ github.ref }}" + if ($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 }}" + if ([string]::IsNullOrEmpty($branchName)) { + $branchName = "${{ github.ref_name }}" + } + + # Sanitize: non-alphanumeric -> '-', multiple '-' -> one, trim '-' + $clean = $branchName -replace '[^a-zA-Z0-9]', '-' ` + -replace '-+', '-' ` + -replace '^-|-$', '' + # Truncate to max 40 characters and remove trailing '-' + $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 }}" + + $suffix = "${prPrefix}${short}.${build}" + echo "suffix=$suffix" >> $env:GITHUB_OUTPUT + } - name: Pack - shell: bash + shell: pwsh run: | - VERSION_SUFFIX="${{ steps.version.outputs.suffix }}" - if [ -n "$VERSION_SUFFIX" ]; then - dotnet pack src/NLog.MailKit.sln --no-build --configuration Release --output artifacts --version-suffix "$VERSION_SUFFIX" - else + $versionSuffix = "${{ steps.version.outputs.suffix }}" + if ($versionSuffix) { + dotnet pack src/NLog.MailKit.sln --no-build --configuration Release --output artifacts --version-suffix "$versionSuffix" + } else { dotnet pack src/NLog.MailKit.sln --no-build --configuration Release --output artifacts - fi + } - name: Upload nuget package uses: actions/upload-artifact@v4 @@ -64,5 +85,5 @@ jobs: - name: Push to NuGet.org if: github.ref == 'refs/heads/master' - shell: bash + 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