Skip to content

fix: publish stable release and deprecate betas on PR merge to main#10

Merged
hpractv merged 5 commits into
mainfrom
copilot/fix-cicd-non-beta-label-creation
May 15, 2026
Merged

fix: publish stable release and deprecate betas on PR merge to main#10
hpractv merged 5 commits into
mainfrom
copilot/fix-cicd-non-beta-label-creation

Conversation

Copilot AI commented May 15, 2026

Copy link
Copy Markdown
Contributor

Merging a PR to main never 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 on pull_request events only. On push (post-merge), packages were packed with the correct stable version but silently discarded.

ci.yml

  • deploy-stable job — new job, triggered on push to main after build-test-pack succeeds; uses environment: nuget-release to 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 with exit 1 when NUGET_API_KEY is absent so maintainers notice immediately if the release did not happen
  • "Deprecate beta packages" — step within deploy-stable, invokes NuGetMaintenance deprecate-betas to mark all prior CI prereleases as deprecated
  • Explicit permissions: contents: read on the new job

NuGetMaintenance/Program.cs

  • Added deprecate-betas command: 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.Excel is at 3.0.1 while others are at 2.0.0)

NuGetGalleryDeprecationApi.cs / SendDeprecationAsync

  • Made alternatePackageId/alternatePackageVersion nullable — only included in the deprecation request body when provided; enables the beta-only path to omit the alternate version hint
  • Added pair validation: both fields must be provided together or both omitted; passing only one throws ArgumentException
  • Three new tests cover the valid both-null case and both mixed-field invalid cases
deploy-stable:
  environment: nuget-release
  permissions:
    contents: read
  steps:
    - name: Publish stable packages
      run: |
        if [ -z "$NUGET_API_KEY" ]; then exit 1; fi
        for pkg in ./artifacts/*.nupkg; do
          if [[ "$pkg" == *"-beta.pr-"* ]]; then continue; fi
          dotnet nuget push "$pkg" --api-key "$NUGET_API_KEY" ...
        done
    - name: Deprecate beta packages
      run: dotnet run ... -- deprecate-betas

Copilot AI and others added 3 commits May 15, 2026 20:12
- 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>
Copilot AI review requested due to automatic review settings May 15, 2026 20:20
Copilot AI removed the request for review from Copilot May 15, 2026 20:20
@hpractv hpractv marked this pull request as ready for review May 15, 2026 20:20
Copilot AI review requested due to automatic review settings May 15, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown

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 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-betas maintenance 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.

Comment thread .github/workflows/ci.yml Outdated
--skip-duplicate

- name: Publish stable packages
if: github.event_name == 'push'
Comment on lines +49 to +56
if (!string.IsNullOrEmpty(alternatePackageId))
{
pairs.Add(new KeyValuePair<string, string>("alternatePackageId", alternatePackageId));
}

if (!string.IsNullOrEmpty(alternatePackageVersion))
{
pairs.Add(new KeyValuePair<string, string>("alternatePackageVersion", alternatePackageVersion));
Comment thread .github/workflows/ci.yml Outdated
Comment on lines +260 to +261
echo "NUGET_API_KEY is not set; skipping stable package publish."
exit 0
@hpractv

hpractv commented May 15, 2026

Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits May 15, 2026 20:29
…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>
Copilot AI requested review from Copilot and removed request for Copilot May 15, 2026 20:31

Copilot AI commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Applied all three changes in commit 35c1d96:

  1. Ungated deployment: Removed the stable publish and beta-deprecation steps from build-test-pack and moved them to a new deploy-stable job with environment: nuget-release, matching the protection level of the release workflow.

  2. Fail-fast on missing key: The stable publish step now exits 1 when NUGET_API_KEY is absent, preventing a silent success.

  3. Alternate-field pair validation: CreateDeprecationRequest now throws ArgumentException when only one of alternatePackageId/alternatePackageVersion is provided. Three new tests cover the valid both-null case and both mixed-field invalid cases.

Copilot AI requested a review from hpractv May 15, 2026 20:31
@hpractv hpractv merged commit 80c60a8 into main May 15, 2026
5 checks passed
@hpractv hpractv deleted the copilot/fix-cicd-non-beta-label-creation branch May 15, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants