fix: publish stable release and deprecate betas on PR merge to main#10
Conversation
- Add 'Publish stable packages' step to ci.yml that runs on push to main (triggered when a PR is merged), pushing the non-beta .nupkg artifacts to NuGet.org with --skip-duplicate - Add 'Deprecate beta packages' step to ci.yml that runs after stable publish, invoking the NuGetMaintenance tool with the new deprecate-betas command - Add 'deprecate-betas' command to NuGetMaintenance Program.cs that deprecates only CI beta prereleases without requiring a release version (avoids the multi-package-version complexity of apply-deprecations) - Make NuGetGalleryDeprecationApi.CreateDeprecationRequest accept nullable alternatePackageId/alternatePackageVersion so the alternate package hint is optional when no specific release version is known - Make SendDeprecationAsync accept NuGetVersion? so the beta-only path can omit the alternate version hint Agent-Logs-Url: https://github.com/hpractv/analyticsLibrary/sessions/f46401a1-ad40-4914-8977-4c6bf124bf38 Co-authored-by: hpractv <13870231+hpractv@users.noreply.github.com>
…ents Agent-Logs-Url: https://github.com/hpractv/analyticsLibrary/sessions/f46401a1-ad40-4914-8977-4c6bf124bf38 Co-authored-by: hpractv <13870231+hpractv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/hpractv/analyticsLibrary/sessions/f46401a1-ad40-4914-8977-4c6bf124bf38 Co-authored-by: hpractv <13870231+hpractv@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates CI release automation so merges to main publish stable NuGet packages and deprecate PR beta packages.
Changes:
- Adds push-to-main stable package publishing in CI.
- Adds a
deprecate-betasmaintenance command. - Allows NuGet deprecation requests to omit alternate package metadata.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
.github/workflows/ci.yml |
Adds stable publish and beta deprecation steps for push events. |
tools/analyticsLibrary.NuGetMaintenance/Program.cs |
Adds command dispatch and beta-only deprecation flow. |
src/analyticsLibrary.ReleaseTooling/NuGetGalleryDeprecationApi.cs |
Makes alternate package fields optional in deprecation requests. |
Comments suppressed due to low confidence (1)
src/analyticsLibrary.ReleaseTooling/NuGetGalleryDeprecationApi.cs:56
- The new nullable alternate-package path is not covered by the existing ReleaseTooling tests, which only exercise the case where both alternate fields are present. Add a test that passes null alternate values and asserts the form body omits both fields so the beta-deprecation request shape is protected from regressions.
if (!string.IsNullOrEmpty(alternatePackageId))
{
pairs.Add(new KeyValuePair<string, string>("alternatePackageId", alternatePackageId));
}
if (!string.IsNullOrEmpty(alternatePackageVersion))
{
pairs.Add(new KeyValuePair<string, string>("alternatePackageVersion", alternatePackageVersion));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| --skip-duplicate | ||
|
|
||
| - name: Publish stable packages | ||
| if: github.event_name == 'push' |
| if (!string.IsNullOrEmpty(alternatePackageId)) | ||
| { | ||
| pairs.Add(new KeyValuePair<string, string>("alternatePackageId", alternatePackageId)); | ||
| } | ||
|
|
||
| if (!string.IsNullOrEmpty(alternatePackageVersion)) | ||
| { | ||
| pairs.Add(new KeyValuePair<string, string>("alternatePackageVersion", alternatePackageVersion)); |
| echo "NUGET_API_KEY is not set; skipping stable package publish." | ||
| exit 0 |
|
@copilot apply changes based on the comments in this thread |
…lternate-field validation - Move stable publish + deprecation to a new `deploy-stable` job with `environment: nuget-release`, gating production NuGet deployments the same way the release workflow does (addresses ungated deployment concern) - Stable publish now exits 1 (fail-fast) when NUGET_API_KEY is missing, preventing a silent success on a missing secret - Add pair-validation to CreateDeprecationRequest: alternatePackageId and alternatePackageVersion must both be provided or both omitted; add 3 new tests covering both-omitted (allowed) and mixed cases (throw) Agent-Logs-Url: https://github.com/hpractv/analyticsLibrary/sessions/29c45d70-4b75-4ec2-8814-3a9e8620563a Co-authored-by: hpractv <13870231+hpractv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/hpractv/analyticsLibrary/sessions/29c45d70-4b75-4ec2-8814-3a9e8620563a Co-authored-by: hpractv <13870231+hpractv@users.noreply.github.com>
Applied all three changes in commit
|
Merging a PR to
mainnever published the stable NuGet packages or deprecated the accumulated*-beta.pr-*builds — leaving NuGet.org showing only prerelease versions with no stable counterpart.The root cause:
ci.yml's publish step was gated onpull_requestevents only. Onpush(post-merge), packages were packed with the correct stable version but silently discarded.ci.ymldeploy-stablejob — new job, triggered onpushtomainafterbuild-test-packsucceeds; usesenvironment: nuget-releaseto apply the same approval gate as the existing release workflow; iterates artifacts and skips any*-beta.pr-*filenames before pushing stable packages to NuGet.org; fails fast withexit 1whenNUGET_API_KEYis absent so maintainers notice immediately if the release did not happendeploy-stable, invokesNuGetMaintenance deprecate-betasto mark all prior CI prereleases as deprecatedpermissions: contents: readon the new jobNuGetMaintenance/Program.csdeprecate-betascommand: queries NuGet for each package ID, deprecates all-beta.pr-versions with the prerelease-testing message — no release version argument needed, avoiding the complexity of per-package version resolution (packages have independent versions, e.g.analyticsLibrary.Excelis at3.0.1while others are at2.0.0)NuGetGalleryDeprecationApi.cs/SendDeprecationAsyncalternatePackageId/alternatePackageVersionnullable — only included in the deprecation request body when provided; enables the beta-only path to omit the alternate version hintArgumentException