From ac318a09a2d784525e2023c98f96e58a19d73e70 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Fri, 26 Jun 2026 21:01:06 -0700 Subject: [PATCH 1/2] Fix detached-SHA versioning: re-add branch input + git checkout -B + probe Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/build-nugetlibrary-task.yml | 1 + .github/workflows/build-release-task.yml | 1 + .github/workflows/get-version-task.yml | 17 ++++++++++ .github/workflows/zz-detached-probe.yml | 31 +++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 .github/workflows/zz-detached-probe.yml diff --git a/.github/workflows/build-nugetlibrary-task.yml b/.github/workflows/build-nugetlibrary-task.yml index cac4dd5..0fb70e2 100644 --- a/.github/workflows/build-nugetlibrary-task.yml +++ b/.github/workflows/build-nugetlibrary-task.yml @@ -37,6 +37,7 @@ jobs: secrets: inherit with: ref: ${{ inputs.ref }} + branch: ${{ inputs.branch }} build-nugetlibrary: name: Build NuGet library project job diff --git a/.github/workflows/build-release-task.yml b/.github/workflows/build-release-task.yml index f5b056a..21b2507 100644 --- a/.github/workflows/build-release-task.yml +++ b/.github/workflows/build-release-task.yml @@ -50,6 +50,7 @@ jobs: secrets: inherit with: ref: ${{ inputs.ref }} + branch: ${{ inputs.branch }} # Entry gate: validate branch<->version consistency once, before the build jobs, so an NBGV mis-classification fails # fast instead of after building and publishing. main must be a public release (no prerelease '-'); every other branch diff --git a/.github/workflows/get-version-task.yml b/.github/workflows/get-version-task.yml index c478dbb..0954cf5 100644 --- a/.github/workflows/get-version-task.yml +++ b/.github/workflows/get-version-task.yml @@ -9,6 +9,13 @@ on: required: false type: string default: '' + # Logical branch NBGV classifies public-vs-prerelease against. With IGNORE_GITHUB_REF, NBGV reads the + # checked-out git branch; callers that check out a pinned commit (detached HEAD - the build jobs) pass this + # so a local branch can be created at that commit, giving NBGV the right name. Empty leaves the checkout as-is. + branch: + required: false + type: string + default: '' outputs: SemVer2: value: ${{ jobs.get-version.outputs.SemVer2 }} @@ -47,6 +54,16 @@ jobs: ref: ${{ inputs.ref }} fetch-depth: 0 + # NBGV (with IGNORE_GITHUB_REF) classifies public-vs-prerelease from the checked-out branch. A pinned-SHA + # checkout is detached HEAD, where NBGV sees no branch and treats every leg as prerelease (the main leg would + # then build a prerelease package mismatching its clean release tag). Force a local branch at HEAD matching the + # logical branch so NBGV sees the right name while still versioning the intended commit. + - name: Pin logical branch step + if: ${{ inputs.branch != '' }} + env: + BRANCH: ${{ inputs.branch }} + run: git checkout -B "$BRANCH" + # nbgv is floated on @master: its tag stream lags master, so Dependabot tag-tracking would propose a downgrade. # Revisit if dotnet/nbgv resumes regular tagged releases. - name: Run Nerdbank.GitVersioning tool step diff --git a/.github/workflows/zz-detached-probe.yml b/.github/workflows/zz-detached-probe.yml new file mode 100644 index 0000000..c1b6516 --- /dev/null +++ b/.github/workflows/zz-detached-probe.yml @@ -0,0 +1,31 @@ +name: nbgv detached branch probe + +on: + push: + branches: [ fix/nbgv-detached-branch ] + +permissions: + contents: read + +jobs: + probe-main: + name: Probe main detached + uses: ./.github/workflows/build-release-task.yml + secrets: inherit + with: + smoke: true + github: false + nuget: false + ref: main + branch: main + + probe-develop: + name: Probe develop detached + uses: ./.github/workflows/build-release-task.yml + secrets: inherit + with: + smoke: true + github: false + nuget: false + ref: develop + branch: develop From b702d237978f8f4ca2441039fa532e2df099f2c2 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Fri, 26 Jun 2026 21:03:55 -0700 Subject: [PATCH 2/2] Remove probe (detached-SHA fix validated) Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/zz-detached-probe.yml | 31 ------------------------- 1 file changed, 31 deletions(-) delete mode 100644 .github/workflows/zz-detached-probe.yml diff --git a/.github/workflows/zz-detached-probe.yml b/.github/workflows/zz-detached-probe.yml deleted file mode 100644 index c1b6516..0000000 --- a/.github/workflows/zz-detached-probe.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: nbgv detached branch probe - -on: - push: - branches: [ fix/nbgv-detached-branch ] - -permissions: - contents: read - -jobs: - probe-main: - name: Probe main detached - uses: ./.github/workflows/build-release-task.yml - secrets: inherit - with: - smoke: true - github: false - nuget: false - ref: main - branch: main - - probe-develop: - name: Probe develop detached - uses: ./.github/workflows/build-release-task.yml - secrets: inherit - with: - smoke: true - github: false - nuget: false - ref: develop - branch: develop