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