Skip to content

Move NuGet publish stage after pushing tag in release pipeline#27316

Open
adityapatwardhan wants to merge 2 commits into
PowerShell:masterfrom
adityapatwardhan:moveNuGet
Open

Move NuGet publish stage after pushing tag in release pipeline#27316
adityapatwardhan wants to merge 2 commits into
PowerShell:masterfrom
adityapatwardhan:moveNuGet

Conversation

@adityapatwardhan
Copy link
Copy Markdown
Member

PR Summary

This pull request refactors the release pipeline by separating the publishing of GitHub releases and NuGet packages into distinct stages and templates. This modularization improves maintainability and clarity in the release process.

Pipeline modularization and separation:

  • Extracted the NuGet publishing logic from the combined GitHub/NuGet release template into a new, dedicated template file: .pipelines/templates/release-Nuget.yml. This includes all steps for preparing and pushing NuGet packages.
  • Removed the NuGet publishing job from .pipelines/templates/release-github.yml (previously release-githubNuget.yml), so it now only handles the GitHub release process.

Stage restructuring:

  • Renamed the PublishGitHubReleaseAndNuget stage to PublishGitHubRelease in PowerShell-Release-Stages.yml, so it only handles the GitHub release. The template used was updated accordingly.
  • Introduced a new stage, PublishNugetRelease, which is responsible solely for publishing to NuGet, using the new template.
  • Updated dependencies between stages to reflect this separation, ensuring each release step is clearly defined and independently managed. [1] [2]

PR Context

PR Checklist

Copilot AI review requested due to automatic review settings April 21, 2026 19:58
@adityapatwardhan adityapatwardhan requested a review from a team as a code owner April 21, 2026 19:58
@adityapatwardhan adityapatwardhan added Backport-7.4.x-Consider Backport-7.5.x-Consider Backport-7.6.x-Consider CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log labels Apr 21, 2026
@adityapatwardhan adityapatwardhan changed the title Move nu get Move NuGet publish stage after pushing tag in release pipeline Apr 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modularizes the Azure Pipelines release flow by separating GitHub Release publishing and NuGet publishing into distinct stages/templates under .pipelines/templates, improving readability and isolating responsibilities.

Changes:

  • Split NuGet publishing into a new dedicated template (release-Nuget.yml).
  • Updated release stages to publish GitHub releases and NuGet packages in separate stages.
  • Removed the NuGet publishing job from the GitHub release template.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
.pipelines/templates/stages/PowerShell-Release-Stages.yml Renames/splits stages and wires in a new NuGet publishing stage/template.
.pipelines/templates/release-github.yml Removes embedded NuGet publishing job so template focuses on GitHub release creation.
.pipelines/templates/release-Nuget.yml New template containing the NuGet publish job/steps extracted from the GitHub template.


- stage: PublishNugetRelease
displayName: Publish Nuget Release
dependsOn:
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-Nuget.yml reads stageDependencies.setReleaseTagAndChangelog...outputs[...], but the new PublishNugetRelease stage no longer depends on setReleaseTagAndChangelog. stageDependencies is scoped to the current stage's dependsOn, so this output reference can be undefined at runtime. Add setReleaseTagAndChangelog to PublishNugetRelease.dependsOn (or refactor to pass the version/tag into the template via parameters).

Suggested change
dependsOn:
dependsOn:
- setReleaseTagAndChangelog

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think copilot is right

variables:
- template: ./variables/release-shared.yml@self
parameters:
VERSION: $[ stageDependencies.setReleaseTagAndChangelog.SetTagAndChangelog.outputs['OutputVersion.Version'] ]
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output reference casing here doesn't match the producing job name. release-SetTagAndChangelog.yml defines the job as setTagAndChangelog, but this template uses SetTagAndChangelog in stageDependencies.setReleaseTagAndChangelog.SetTagAndChangelog.outputs[...]. Update the reference to use the correct job name to ensure the OutputVersion.Version value resolves reliably.

Suggested change
VERSION: $[ stageDependencies.setReleaseTagAndChangelog.SetTagAndChangelog.outputs['OutputVersion.Version'] ]
VERSION: $[ stageDependencies.setReleaseTagAndChangelog.setTagAndChangelog.outputs['OutputVersion.Version'] ]

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think copilot is right

Comment on lines +50 to +54
condition: and(ne('${{ parameters.skipPublish }}', 'true'), succeeded())

- task: NuGetCommand@2
displayName: 'NuGet push'
condition: and(ne('${{ parameters.skipPublish }}', 'true'), succeeded())
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipPublish is declared as a boolean parameter, but the job conditions compare it as a string: ne('${{ parameters.skipPublish }}', 'true'). Template booleans expand to True/False (or non-string), so this comparison can evaluate incorrectly (often always true) and unintentionally publish when skipPublish is set. Use a boolean-safe condition (for example, and(succeeded(), not(${{ parameters.skipPublish }})) or eq(${{ parameters.skipPublish }}, false)).

Suggested change
condition: and(ne('${{ parameters.skipPublish }}', 'true'), succeeded())
- task: NuGetCommand@2
displayName: 'NuGet push'
condition: and(ne('${{ parameters.skipPublish }}', 'true'), succeeded())
condition: and(succeeded(), not(${{ parameters.skipPublish }}))
- task: NuGetCommand@2
displayName: 'NuGet push'
condition: and(succeeded(), not(${{ parameters.skipPublish }}))

Copilot uses AI. Check for mistakes.
variables:
ob_release_environment: ${{ parameters.releaseEnvironment }}
jobs:
- template: /.pipelines/templates/release-nuget.yml@self
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PublishNugetRelease references a template path that doesn't exist in this PR: the repo adds .pipelines/templates/release-Nuget.yml, but the stage includes /.pipelines/templates/release-nuget.yml@self. On case-sensitive agents/template resolution this will fail to load. Rename the file or update the template reference so the casing/name matches exactly (and keep it consistent with other release-*.yml templates).

Suggested change
- template: /.pipelines/templates/release-nuget.yml@self
- template: /.pipelines/templates/release-Nuget.yml@self

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think copilot is right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.4.x-Consider Backport-7.5.x-Consider Backport-7.6.x-Consider CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants