Move NuGet publish stage after pushing tag in release pipeline#27316
Move NuGet publish stage after pushing tag in release pipeline#27316adityapatwardhan wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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).
| dependsOn: | |
| dependsOn: | |
| - setReleaseTagAndChangelog |
There was a problem hiding this comment.
I think copilot is right
| variables: | ||
| - template: ./variables/release-shared.yml@self | ||
| parameters: | ||
| VERSION: $[ stageDependencies.setReleaseTagAndChangelog.SetTagAndChangelog.outputs['OutputVersion.Version'] ] |
There was a problem hiding this comment.
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.
| VERSION: $[ stageDependencies.setReleaseTagAndChangelog.SetTagAndChangelog.outputs['OutputVersion.Version'] ] | |
| VERSION: $[ stageDependencies.setReleaseTagAndChangelog.setTagAndChangelog.outputs['OutputVersion.Version'] ] |
There was a problem hiding this comment.
I think copilot is right
| condition: and(ne('${{ parameters.skipPublish }}', 'true'), succeeded()) | ||
|
|
||
| - task: NuGetCommand@2 | ||
| displayName: 'NuGet push' | ||
| condition: and(ne('${{ parameters.skipPublish }}', 'true'), succeeded()) |
There was a problem hiding this comment.
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)).
| 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 }})) |
| variables: | ||
| ob_release_environment: ${{ parameters.releaseEnvironment }} | ||
| jobs: | ||
| - template: /.pipelines/templates/release-nuget.yml@self |
There was a problem hiding this comment.
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).
| - template: /.pipelines/templates/release-nuget.yml@self | |
| - template: /.pipelines/templates/release-Nuget.yml@self |
There was a problem hiding this comment.
I think copilot is right
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:
.pipelines/templates/release-Nuget.yml. This includes all steps for preparing and pushing NuGet packages..pipelines/templates/release-github.yml(previouslyrelease-githubNuget.yml), so it now only handles the GitHub release process.Stage restructuring:
PublishGitHubReleaseAndNugetstage toPublishGitHubReleaseinPowerShell-Release-Stages.yml, so it only handles the GitHub release. The template used was updated accordingly.PublishNugetRelease, which is responsible solely for publishing to NuGet, using the new template.PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header