Fix detached-SHA versioning: branch input + git checkout -B (completes IGNORE_GITHUB_REF)#203
Merged
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
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
branchinput toget-version-task.ymland creates a local branch atHEAD(git checkout -B <branch>) when provided, so NBGV can classify versions correctly underIGNORE_GITHUB_REF=true. - Threads the
branchinput throughbuild-release-task.ymlandbuild-nugetlibrary-task.ymlwhen callingget-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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (caught by Copilot on #199)
#198 switched to
IGNORE_GITHUB_REF=true(NBGV versions from the checked-out branch) and dropped thebranchinput. Butbuild-nugetlibrarychecks 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 a1.4.x-g<sha>package mismatching its clean1.4.xrelease tag.Verified with the nbgv tool: detached at main's commit +
IGNORE_GITHUB_REF→PublicRelease=False, 1.4.3-gef05e9edc1.Fix
Re-add the
branchinput and, after checkout,git checkout -B <branch>so NBGV sees the logical branch even from a detached SHA (keepingIGNORE_GITHUB_REF). Re-threadbranchto both get-version callers.Verified in CI (detached-SHA path via build-release-task smoke)
Built nupkg from the detached
build-nugetlibrarycheckout:ptr727.LanguageTags.1.4.3.nupkg(clean ✅)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