Summary
The fix for #213 (PR #215) restores the develop leg's prerelease tag by overriding GITHUB_REF in the nbgv step env:. This does not work. GITHUB_REF is a GitHub-reserved variable that a step-level env: cannot reliably override — the runner re-injects the dispatch ref. NBGV's GitHub Actions cloud-build provider reads GITHUB_REF for BuildingRef, so on a publish dispatched from main the develop leg is still classified as the public ref and publishes a clean (stable) version.
Evidence (CI)
First real publish after #215 landed in a derived repo — the develop leg's nbgv step:
GITHUB_REF: refs/heads/develop # the step-env override (as configured)
"BuildingRef": "refs/heads/main" # NBGV still saw the dispatch ref
"PublicRelease": true
"SemVer2": "1.4.2" # clean, no -g suffix
The validate-release gate correctly blocked the publish (so no bad package shipped), but the develop prerelease leg never publishes.
Root cause
GITHUB_REF is reserved; overriding it via step env: is unsupported (GitHub: "Setting an environment variable with the GITHUB_ prefix may result in unexpected behavior"). NBGV reads it for BuildingRef:
// src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs
private static string BuildingRef => IgnoreGitHubRef ? null : Environment.GetEnvironmentVariable("GITHUB_REF");
private static bool IgnoreGitHubRef => string.Equals(Environment.GetEnvironmentVariable("IGNORE_GITHUB_REF"), "true", StringComparison.OrdinalIgnoreCase);
Fix
NBGV versions from the checked-out branch; its cloud provider only overrides that with GITHUB_REF. Each matrix leg already checks out its own branch (Switched to a new branch 'develop'). Set NBGV's own IGNORE_GITHUB_REF=true so it ignores the CI ref and uses the checked-out branch:
- name: Run Nerdbank.GitVersioning tool step
id: nbgv
uses: dotnet/nbgv@master
env:
IGNORE_GITHUB_REF: true
Drop the branch input/threading added to get-version-task.yml and its callers for the (ineffective) GITHUB_REF override; the validate-release entry gate stays as the backstop.
Verified (CI probe, real dotnet/nbgv action)
| checkout |
IGNORE_GITHUB_REF |
PublicRelease |
SemVer2 |
| develop |
true |
False |
1.4.2-g14f645dfd9 |
| main |
true |
True |
1.4.3 |
| main |
false |
False |
1.4.3-g… (reproduces the bug) |
Supersedes #215. Found in a derived repo's first real publish + a CI probe.
Summary
The fix for #213 (PR #215) restores the develop leg's prerelease tag by overriding
GITHUB_REFin the nbgv stepenv:. This does not work.GITHUB_REFis a GitHub-reserved variable that a step-levelenv:cannot reliably override — the runner re-injects the dispatch ref. NBGV's GitHub Actions cloud-build provider readsGITHUB_REFforBuildingRef, so on a publish dispatched frommainthe develop leg is still classified as the public ref and publishes a clean (stable) version.Evidence (CI)
First real publish after #215 landed in a derived repo — the develop leg's nbgv step:
The
validate-releasegate correctly blocked the publish (so no bad package shipped), but the develop prerelease leg never publishes.Root cause
GITHUB_REFis reserved; overriding it via stepenv:is unsupported (GitHub: "Setting an environment variable with the GITHUB_ prefix may result in unexpected behavior"). NBGV reads it forBuildingRef:Fix
NBGV versions from the checked-out branch; its cloud provider only overrides that with
GITHUB_REF. Each matrix leg already checks out its own branch (Switched to a new branch 'develop'). Set NBGV's ownIGNORE_GITHUB_REF=trueso it ignores the CI ref and uses the checked-out branch:Drop the
branchinput/threading added toget-version-task.ymland its callers for the (ineffective)GITHUB_REFoverride; thevalidate-releaseentry gate stays as the backstop.Verified (CI probe, real dotnet/nbgv action)
Supersedes #215. Found in a derived repo's first real publish + a CI probe.