Skip to content

Use NBGV IGNORE_GITHUB_REF instead of the ineffective GITHUB_REF override - #222

Merged
ptr727 merged 2 commits into
developfrom
feature/nbgv-ignore-github-ref-221
Jun 27, 2026
Merged

Use NBGV IGNORE_GITHUB_REF instead of the ineffective GITHUB_REF override#222
ptr727 merged 2 commits into
developfrom
feature/nbgv-ignore-github-ref-221

Conversation

@ptr727

@ptr727 ptr727 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Problem

Closes #221; supersedes the mechanism from #215. The #213 fix (PR #215) restored the develop leg's prerelease tag by overriding GITHUB_REF in the nbgv step env:. It doesn't work. GITHUB_REF is GitHub-reserved — a step-level env: can't reliably override it (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 was still classified public and would publish a clean (stable) version.

CI evidence from the first real publish after #215:

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 bad publish, so nothing shipped — but the develop prerelease leg never publishes.)

Fix

NBGV versions from the checked-out branch unless its cloud provider overrides with GITHUB_REF. Each matrix leg already checks out its own branch, so set NBGV's own IGNORE_GITHUB_REF=true to make it ignore the CI ref:

      - name: Run Nerdbank.GitVersioning tool step
        id: nbgv
        uses: dotnet/nbgv@master
        env:
          IGNORE_GITHUB_REF: true

NBGV source confirms the knob: BuildingRef => IgnoreGitHubRef ? null : env GITHUB_REF.

Verification

  • actionlint (Docker) clean on all six changed workflows; CRLF preserved.
  • Per the issue's CI probe (real dotnet/nbgv): develop checkout + IGNORE_GITHUB_REF=truePublicRelease=False, 1.4.2-g…; mainTrue, 1.4.3; main without the flag reproduces the bug.

🤖 Generated with Claude Code

…ride

Fixes #221, supersedes the #215 mechanism. #215 tried to restore the develop
leg's prerelease tag by overriding GITHUB_REF in the nbgv step env. That does
not work: GITHUB_REF is a GitHub-reserved variable a step env cannot reliably
override (the runner re-injects the dispatch ref), so NBGV's GitHub Actions
provider still read refs/heads/main for every leg on a main-dispatched publish
and classified the develop leg as a public release (clean, stable version).

NBGV versions from the checked-out branch unless its cloud provider overrides
with GITHUB_REF. Set IGNORE_GITHUB_REF=true so NBGV ignores the CI ref and uses
the checked-out branch, which each matrix leg already is. Drop the now-useless
`branch` input from get-version-task.yml and its threading from all five
callers. The validate-release entry gate stays as the backstop.

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

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

This PR fixes NBGV branch classification in the publish matrix by using NBGV's supported IGNORE_GITHUB_REF switch (so versioning follows the checked-out ref per leg) and removes the prior, ineffective GITHUB_REF override mechanism.

Changes:

  • Set IGNORE_GITHUB_REF=true for the dotnet/nbgv@master step so NBGV ignores the workflow dispatch ref.
  • Remove the now-unused branch input from get-version-task.yml.
  • Remove branch: threading into get-version-task.yml from all reusable workflow callers.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/get-version-task.yml Drop branch input and switch NBGV to IGNORE_GITHUB_REF for correct per-checkout versioning.
.github/workflows/build-release-task.yml Stop passing branch into get-version-task.yml (versioning no longer relies on env overrides).
.github/workflows/build-pypilibrary-task.yml Remove branch passthrough to get-version-task.yml.
.github/workflows/build-nugetlibrary-task.yml Remove branch passthrough to get-version-task.yml.
.github/workflows/build-executable-task.yml Remove branch passthrough to get-version-task.yml.
.github/workflows/build-docker-task.yml Remove branch passthrough to get-version-task.yml.

Comment thread .github/workflows/get-version-task.yml Outdated
NBGV string-compares the value to "true"; env values are strings, so quoting
makes the intent explicit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ptr727
ptr727 merged commit 36f7eeb into develop Jun 27, 2026
8 checks passed
@ptr727
ptr727 deleted the feature/nbgv-ignore-github-ref-221 branch June 27, 2026 00:28
ptr727 added a commit that referenced this pull request Jul 4, 2026
Promote the accumulated `develop` work to `main`. Twelve changes since
the last promotion:

- Add `WORKFLOW.md`: workflow style, architecture, behavioral contract,
test methodology (#223)
- Use NBGV `IGNORE_GITHUB_REF` instead of the ineffective `GITHUB_REF`
override (#222)
- Skip validate-release on smoke builds (#220)
- Gate asset delete on the release create/refresh condition (#218)
- Ship branch rulesets as versioned JSON in the re-sync / drift loop
(#212)
- Clean up transfer artifacts surgically at consumption, not
blanket-delete (#216)
- Version each publish leg against its own branch; validate at entry
(#215)
- Consolidate workspace configurations into a unified ProjectTemplate
workspace (#210)
- Template convergence barrier: absorb pins, generic release +
docker-readme, carry-whole-file (#207)
- Key merge-bot concurrency on PR number, not `github.ref` (#206)
- Codify orchestrated re-sync personas and full-replacement rule (#205)
- Lead action pins; affirm pattern-based artifact handoff (#204)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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