Skip to content

Reset build patch on GitVersion.yml changes (keep GitVersion for Major.Minor)#90

Merged
mkrueger merged 2 commits into
mainfrom
dev/mkrueger/gitversion-patch-from-config-change
May 20, 2026
Merged

Reset build patch on GitVersion.yml changes (keep GitVersion for Major.Minor)#90
mkrueger merged 2 commits into
mainfrom
dev/mkrueger/gitversion-patch-from-config-change

Conversation

@mkrueger
Copy link
Copy Markdown
Contributor

Why

PR #89 made the build version independent of git tags by removing the TaggedCommit strategy from GitVersion.yml. That fixed the regression where tagging v1.0.273 reset the patch to 82. However, GitVersion's ConfiguredNextVersion strategy returns next-version from the config file but does not set a base version SHA, so CommitsSinceVersionSource falls back to counting all commits in the repository.

Result: after merging #89, builds show 1.1.357+ instead of starting at 1.1.0 after the next-version bump. The patch never resets when next-version is bumped, which makes a Major.Minor bump indistinguishable from any other commit.

What

Keep GitVersion responsible for parsing/validating Major.Minor from GitVersion.yml, but compute the patch in both pipelines from the commit history of GitVersion.yml itself:

$configCommit = (git log -n 1 --format=%H -- $configPath).Trim()
$patch = [int](git rev-list --count "$configCommit..HEAD")

Applied identically in:

  • .github/workflows/validate-and-package.yml
  • .pipelines/CosmosDB-Shell-Official.yml

Behavior

  • Tag-independent (matches the goal of Make GitVersion ignore tags; bump next-version to 1.1.0 #89).
  • Patch resets to 0 whenever GitVersion.yml is edited (e.g. when bumping next-version).
  • Subsequent commits after a bump produce 1.1.1, 1.1.2, … in order.
  • The next bump (say to 1.2.0) automatically resets the counter back to 0.

Note: the very first build after this PR merges will be 1.1.<small> rather than literally 1.1.0, because the merge commit and any commits between #89 and this PR are counted from GitVersion.yml's last edit (commit 319b304 from #89). Future next-version bumps will reset cleanly because they touch GitVersion.yml.

Validation

GitVersion Major.Minor: 1.1
Config commit: 319b30417c16cf56864f3ae460e0ac279a6d0533
Final version: 1.1.<commits-since-bump>

dotnet build CosmosDBShell/CosmosDBShell.csproj succeeds locally.

… to .0

GitVersion's ConfiguredNextVersion strategy returns next-version from the config file but does not set a base version SHA, so CommitsSinceVersionSource falls back to counting all commits in the repository (357 on main). That keeps the version monotonic but means a next-version bump never resets the patch back to .0.

Keep GitVersion responsible for parsing/validating Major.Minor and override the patch in both pipelines with 'git rev-list --count <GitVersion.yml-commit>..HEAD'. The first build after merging this branch will be 1.1.0; subsequent commits become 1.1.1, 1.1.2, ... and the next bump (e.g. 1.2.0) automatically resets the counter.
@mkrueger mkrueger requested review from a team and Copilot May 20, 2026 15:00
ob_sdl_binskim_scanOutputDirectoryOnly limits BinSkim to ob_outputDirectory (= out\). The pre-SDL cleanup whitelisted only zip/nupkg/_manifest, but BinSkim does not look inside .zip/.nupkg archives, so it found no scannable PE files and logged: 'No files found to upload for tool: binskim. Skipping...'.

Add win-x64 and win-arm64 (the only RID outputs that contain Windows PE binaries) to the keep list. The bytes are duplicates of what is already inside the zips, but they're needed loose for SDL scanning.
@mkrueger mkrueger enabled auto-merge May 20, 2026 15:07
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mkrueger mkrueger merged commit 808048f into main May 20, 2026
9 checks passed
@mkrueger mkrueger deleted the dev/mkrueger/gitversion-patch-from-config-change branch May 20, 2026 19:26
mkrueger added a commit that referenced this pull request May 21, 2026
… versioning (#91)

## Summary

Adopt
[Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning)
(NBGV) as the single source of truth for version computation, replacing
both the abandoned GitVersion tool and the CI-only patch-bump script
introduced in #90.

NBGV is a Microsoft / .NET Foundation project (MIT-licensed) that
derives the patch component from git history (commit count since
`version.json` last changed) at MSBuild time. This means **local
developer builds and CI builds now produce identical, deterministic
versions** — no more `1.0.0` placeholders when building outside the
pipeline.

## Why

#90 dropped GitVersion in favor of a custom patch-bump script that runs
only in CI. Local builds therefore lost meaningful versioning. We needed
a replacement that:

- Computes the patch automatically from git history starting at the last
major/minor bump.
- Lets us pin a baseline `major.minor` in source.
- Works the same way locally and in CI.
- Is maintained by a trustworthy upstream (we ruled out
devlooped/GitInfo for OSMF license reasons).

NBGV satisfies all of the above and is already widely used across .NET
Foundation repos.

## Changes

### New: `version.json`
- Baseline `1.1-preview` — bumping major/minor is a one-line edit; patch
resets automatically because the file changed.
- `publicReleaseRefSpec` covers `main`, `rel/*`, and PR merge refs.
Other branches (including `dev/*`) get a `-g<sha>` suffix to prevent
collisions on feeds.
- `nugetPackageVersion.semVer = 2`.
- `cloudBuild.*` variable injection disabled — we emit the version
explicitly in our pipelines instead.

### Removed: `GitVersion.yml`

### Build infrastructure
- `Directory.Build.props`: replaced the old `VersionSuffix` block with a
single `<PackageReference Include="Nerdbank.GitVersioning"
PrivateAssets="all" VersionOverride="3.9.50" />`. `VersionOverride` is
required because `CosmosDBShell.Fuzzer` opts out of central package
management.
- `Directory.Packages.props`: added `Nerdbank.GitVersioning 3.9.50` for
the central-PM consumers.
- `.config/dotnet-tools.json`: `gitversion.tool` → `nbgv` 3.9.50.

### CI
Both pipelines now fetch full git history (already required by NBGV),
restore tools, and call `nbgv get-version` once for the package version.
The redundant `/p:Version`, `/p:FileVersion`, `/p:InformationalVersion`,
and `/p:PackageVersion` overrides on `dotnet build`, the per-RID `dotnet
publish` loop, and `dotnet pack` were removed — NBGV stamps those
automatically.

- `.github/workflows/validate-and-package.yml`
- `.pipelines/CosmosDB-Shell-Official.yml`

## Verification

- `dotnet restore`, `dotnet build CosmosDBShell.sln -c Release`, and
`dotnet test CosmosDBShell.sln -c Release` all pass (1074/1074).
- The built `CosmosDBShell.dll` carries the expected attributes:
  - `AssemblyVersion = 1.1.0.0`
- `FileVersion = 1.1.0.<commit-hash-short>` (NBGV embeds the first 16
bits of the commit SHA into the revision component for per-commit
uniqueness)
  - `AssemblyInformationalVersion = 1.1.0-preview+808048fc14`
  - `NuGetPackageVersion = 1.1.0-preview`
- `CosmosDBShell --version` → `CosmosDBShell 1.1.0-preview (808048f)`
- `version` shell command → `1.1.0-preview` (existing parser splits on
`+`, unchanged).
- Existing `VersionCommand_UsesInformationalVersion` test still passes.

## Operational notes

- Bumping major/minor: edit `version.json` and commit. Patch resets to
`0` and increments per commit afterwards.
- Cutting a stable release: drop `-preview` from `version.json`'s
`version` (or branch to `rel/1.1`).
- Feature/PR branches that don't match `publicReleaseRefSpec` get a
`-g<sha>` suffix on the package version, so they cannot collide with
official packages on a feed.
mkrueger added a commit that referenced this pull request May 21, 2026
Converts the `Unreleased — since v1.0.273` section to `1.1.4 —
2026-05-21` (first release on the 1.1 line) and adds entries for the PRs
that landed after #86 (the last CHANGELOG update):

- **Highlights / New features:** multi-line REPL input with `\`
continuation and parser-driven incomplete-input detection
([#88](#88)); parser & query
diagnostics with line, column, source caret, and "Did you mean…"
suggestions ([#87](#87)).
- **Documentation:** notes that [docs/navigation.md](docs/navigation.md)
and [README](README.md) now document multi-line input.
- **Build & pipeline:** versioning moved to
[Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning);
local builds now produce the same versions as CI
([#90](#90),
[#91](#91)).

PR #89 was a stepping stone superseded by the NBGV migration, so it
isn't called out separately.

Docs-only change — no code touched.
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