Skip to content

Commit c4caac7

Browse files
Copilotskarim
andauthored
fix: use = syntax in go_build_options ldflags to avoid word-splitting
The release workflow was passing `-ldflags '-X ...'` via `go_build_options`, which gets set as the `GO_BUILD_OPTIONS` environment variable. In `build_and_release.sh`, this variable is expanded unquoted (`${GO_BUILD_OPTIONS}`), so bash word-splits it on spaces. Single quotes inside an unquoted variable expansion are literal characters, not shell quotes - causing `'-X` (with the literal quote character) to be passed as the value for `-ldflags`, which is invalid. Fix: use `-ldflags=-X=path.Var=value` (no spaces, single token) so bash word splitting produces exactly one argument. The `=` syntax is supported by both the Go build tool (for `-ldflags`) and the Go linker (for `-X`). Co-authored-by: skarim <1701557+skarim@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-stack/sessions/7f8aece9-d05c-478e-8864-ff0b5e00b3a8
1 parent 5cb96cf commit c4caac7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
generate_attestations: true
2323
go_version_file: go.mod
2424
go_build_options: >-
25-
-ldflags '-X github.com/github/gh-stack/cmd.Version=${{ steps.version.outputs.version }}'
25+
-ldflags=-X=github.com/github/gh-stack/cmd.Version=${{ steps.version.outputs.version }}

0 commit comments

Comments
 (0)