ci: build VERSION from env vars instead of interpolating into the shell - #4632
Open
kobihikri wants to merge 1 commit into
Open
ci: build VERSION from env vars instead of interpolating into the shell#4632kobihikri wants to merge 1 commit into
kobihikri wants to merge 1 commit into
Conversation
|
|
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.
Hi, and thanks for buf.
In
.github/workflows/build-and-draft-release.yaml, the version is assembled by interpolating two values into the shell:Actions expands
${{ ... }}into the script text before bash runs, so both arrive as script rather than as values. Git allows$,(,)and backticks in branch names, theworkflow_dispatchinput is free text, and$(...)executes inside double quotes.The job's guard is real and I want to credit it rather than talk around it:
So a maintainer has to merge the PR, and the branch has to start with
release. But everything after that prefix is unconstrained, which is what leaves the gap — and the step immediately after this one mints a GitHub App token.The change binds both to environment variables and keeps the existing precedence:
${INPUT_VERSION:-$HEAD_REF}reproduces the||fallback — the dispatch input wins when set and non-empty, otherwise the head ref — and the${VERSION##*/v}trim is untouched, sorelease/v1.0.0still yields1.0.0.Disclosure: I used AI assistance to help spot this and prepare the change, and I read the workflow and its
if:condition myself.