Skip to content

Resolve release's baseline from NuGet.config, and let a first release pass - #76

Merged
Mpdreamz merged 1 commit into
mainfrom
baseline
Nov 14, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
baseline

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

release now finds the version it compares with on the feeds NuGet.config lists, says which one it is, and succeeds on a package that has no earlier release.

Prompt summary: The tool is being dusted off. It often failed on new packages, because of a chicken-and-egg problem, especially in CI. A release check has to work from a package's very first version, on private feeds as well as nuget.org.

Why

previous-nuget asked nuget.org alone, so a package on a private feed had no baseline (#24). A package without an earlier release failed the comparison with "Unable to create diff!" and exit code 1, so a new package could not run the check in CI. The only way out was --allow-empty-previous-nuget, which printed a warning but no report.

What

The baseline comes first

release looks up the newest stable version before the one being released on every enabled NuGet.config source. It prints [diff] Comparing with MyLib 1.1.0, the release before 1.2.0, then compares that exact version. Prereleases and later versions are skipped. The nuget provider and the hidden diff's previous-nuget read NuGet.config from the current directory as well, the way dotnet restore does.

A first release passes

With no earlier release, release prints that this is a first release and exits 0 with a suggested change of None. --require-baseline makes it fail instead. --format json writes "firstRelease": true, and --format github-comment writes a comment that says so. When a baseline was resolved, the json report names it in "baseline".

Tests without nuget.org

ReleaseTests gives each test a local folder feed, a NuGet.config that clears every other source, and its own NUGET_PACKAGES, so they never touch nuget.org or the user's package cache. The tests cover the version picked among prereleases and later versions, a first release with and without --require-baseline, and a first release in github-comment. Allowing prereleases on purpose fails the first of them.

Verify

mise run test

Out of scope: A baseline from a committed API snapshot comes with the snapshot package.

🤖 Generated with Claude Code

… pass

release asked nuget.org alone for the version before, and failed when
there was none, so a new package could not run it in CI. It now finds the
newest stable release before the version on the feeds NuGet.config lists,
says which one it compares with, and compares that exact version. With no
earlier release it reports a first release and succeeds, unless
--require-baseline is set; json and github-comment say so too. The NuGet
providers read NuGet.config from the current directory.

Fixes #24.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Mpdreamz Mpdreamz added the feature A new capability (minor bump) label Nov 14, 2026
@Mpdreamz
Mpdreamz merged commit 09da78c into main Nov 14, 2026
6 of 7 checks passed
@Mpdreamz
Mpdreamz deleted the baseline branch November 14, 2026 08:19
Mpdreamz added a commit that referenced this pull request Nov 14, 2026
A new `pull-request` command reads `api-changes.json` and puts it on the
pull request a GitHub Actions run is for. It writes the job summary,
keeps one comment up to date, and sets the release label the suggested
change calls for.

**Prompt summary:** The tool is being dusted off. It needs a clear path
to hooking it up to pull requests, and it should set labels. The label
it sets is the one release-drafter turns into the next version, which
closes the loop between an API change and its release.

## Why
The GitHub Action ran the diff and stopped. Posting the `github-comment`
file, finding the old comment and choosing a label was left to each
repository's workflow, and nothing set a label from the suggested
change.

## What

#### One comment, kept up to date
The comment opens with a hidden marker, `<!-- assembly-differ -->`. A
later run finds it and edits it, so a pull request never collects one
comment per push. It shows the suggested change, the baseline when there
is one, the number of breaking changes, and each assembly's changes as a
nested list in a collapsed block. Past 60,000 characters it stops and
says how many changes did not fit. The same text goes to
`GITHUB_STEP_SUMMARY`.

#### Labels it owns, and only those
`Major` sets `breaking`, `Minor` sets `feature`, and `Patch` sets none.
`--major-label`, `--minor-label` and `--patch-label` change that. The
comment records which labels this tool set. A later run removes only
those, so a label a person added stays, and a change that drops from
`Major` to `Minor` swaps `breaking` for `feature`.

#### Forks and other runs
A read-only token, as on a pull request from a fork, gets 403 or 404.
The command then writes the job summary, prints a warning and exits `0`.
Outside a pull request, with no number in `GITHUB_EVENT_PATH` and no
`--pull-request`, it writes the summary only. If GitHub cannot be
reached, it prints why and exits `1`. Requests and responses use
`HttpClient` and `Utf8JsonWriter`, so the native-AOT binary runs it.

## Verify
```bash
mise run test
# PullRequestTests run the command against FakeGitHub, an in-memory GitHub API on localhost
```

**Stack:** 2 of 2, on top of
[#76](#76).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A new capability (minor bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant