Skip to content

Fix detached-SHA versioning: branch input + git checkout -B (completes IGNORE_GITHUB_REF)#203

Merged
ptr727 merged 2 commits into
developfrom
fix/nbgv-detached-branch
Jun 27, 2026
Merged

Fix detached-SHA versioning: branch input + git checkout -B (completes IGNORE_GITHUB_REF)#203
ptr727 merged 2 commits into
developfrom
fix/nbgv-detached-branch

Conversation

@ptr727

@ptr727 ptr727 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Problem (caught by Copilot on #199)

#198 switched to IGNORE_GITHUB_REF=true (NBGV versions from the checked-out branch) and dropped the branch input. But build-nugetlibrary checks out a pinned commit SHA (detached HEAD) to recompute the package version. On a detached HEAD NBGV sees no branch → classifies as prerelease → the main leg builds a 1.4.x-g<sha> package mismatching its clean 1.4.x release tag.

Verified with the nbgv tool: detached at main's commit + IGNORE_GITHUB_REFPublicRelease=False, 1.4.3-gef05e9edc1.

Fix

Re-add the branch input and, after checkout, git checkout -B <branch> so NBGV sees the logical branch even from a detached SHA (keeping IGNORE_GITHUB_REF). Re-thread branch to both get-version callers.

Verified in CI (detached-SHA path via build-release-task smoke)

Built nupkg from the detached build-nugetlibrary checkout:

leg built package
main ptr727.LanguageTags.1.4.3.nupkg (clean ✅)
develop ptr727.LanguageTags.1.4.4-gf2560a8e4c.nupkg (prerelease ✅)

Both legs now version correctly from a detached checkout, matching the release tag.

🤖 Generated with Claude Code

ptr727 and others added 2 commits June 26, 2026 21:01
…probe

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 27, 2026 04:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the reusable GitHub Actions workflows to ensure Nerdbank.GitVersioning (NBGV) computes the correct public vs prerelease version even when a job checks out a pinned commit SHA (detached HEAD), which is critical for producing stable main packages that match release tags.

Changes:

  • Re-introduces a branch input to get-version-task.yml and creates a local branch at HEAD (git checkout -B <branch>) when provided, so NBGV can classify versions correctly under IGNORE_GITHUB_REF=true.
  • Threads the branch input through build-release-task.yml and build-nugetlibrary-task.yml when calling get-version-task.yml.

Reviewed changes

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

File Description
.github/workflows/get-version-task.yml Adds a branch input and pins a logical local branch in detached-SHA checkouts so NBGV version classification matches the intended branch.
.github/workflows/build-release-task.yml Passes inputs.branch through to get-version-task.yml to keep version computation consistent for release builds.
.github/workflows/build-nugetlibrary-task.yml Passes inputs.branch through to get-version-task.yml so pinned-SHA build jobs still version as main vs prerelease correctly.

@ptr727 ptr727 merged commit cf4d9dc into develop Jun 27, 2026
8 checks passed
@ptr727 ptr727 deleted the fix/nbgv-detached-branch branch June 27, 2026 04:06
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.

2 participants