Only allow a release to be dispatched from main - #17
Merged
Conversation
release.yaml can be triggered by a v* tag or by workflow_dispatch. The tag path is inherently reviewed, but a manual dispatch runs against whatever ref was selected in the UI, and that selector remembers the last branch used. An unreviewed branch could therefore be published to nuget.org, where a version can be unlisted but never removed. The check lives in the existing version-resolution step so a blocked dispatch fails with an explanation rather than skipping silently. Tag pushes are unaffected, since the guard only applies to workflow_dispatch. An explicit ref comparison is used rather than github.ref_protected so the guard does not quietly weaken if branch protection is ever reconfigured. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QPG3s4DPZZ6E4qJ6q8kSs
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.
release.yamlpublishes to nuget.org and can be triggered two ways:v*tag — inherently reviewed, since tags are cut from merged codeworkflow_dispatch— runs against whatever ref is selected in the UI, with no ref checkThe dispatch path meant an unreviewed branch could be published to nuget.org, where a version can be unlisted but never removed. The branch selector on a manual dispatch also remembers the last branch used, so this is an easy misfire rather than a theoretical one.
The check sits inside the existing version-resolution step, so a blocked dispatch fails with an explanation rather than skipping silently:
pushrefs/tags/v1.0.0pushrefs/tags/v1.0.0-rc9201workflow_dispatchmainworkflow_dispatchAn explicit ref comparison is used rather than
github.ref_protected, so the guard does not quietly weaken if branch protection is ever reconfigured.Follow-up to the publish-path audit: the GitHub Packages job in
build-package.yamlwas already correctly guarded bygithub.ref == 'refs/heads/main' && github.event_name == 'push', confirmed against every recent run. This was the one remaining unguarded path.🤖 Generated with Claude Code
https://claude.ai/code/session_012QPG3s4DPZZ6E4qJ6q8kSs