Skip to content

fix: correct ldflags quoting in release workflow#3

Merged
skarim merged 2 commits intomainfrom
copilot/fix-github-actions-workflow-release
Mar 25, 2026
Merged

fix: correct ldflags quoting in release workflow#3
skarim merged 2 commits intomainfrom
copilot/fix-github-actions-workflow-release

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

The release workflow was failing because go_build_options used single quotes around the -X flag value. The cli/gh-extension-precompile@v2 action expands ${GO_BUILD_OPTIONS} unquoted in build_and_release.sh, so single quotes become literal characters rather than shell quotes — bash word-splits the value and passes '-X as the -ldflags argument, which Go rejects.

Change

Replaced quoted space-separated form with =-only syntax, producing a single whitespace-free token that survives unquoted expansion:

- go_build_options: >-
-   -ldflags '-X github.com/github/gh-stack/cmd.Version=${{ steps.version.outputs.version }}'
+ go_build_options: >-
+   -ldflags=-X=github.com/github/gh-stack/cmd.Version=${{ steps.version.outputs.version }}

Both = forms are standard: -ldflags=VALUE is Go flag package syntax; -X=importpath.name=value is valid linker syntax. Go also concatenates multiple -ldflags arguments, so the existing -s -w in the build script is preserved.

Original prompt

Fix the failing GitHub Actions workflow release
Analyze the workflow logs, identify the root cause of the failure, and implement a fix.
Job ID: 68472022017
Job URL: https://github.com/github/gh-stack/actions/runs/23523615937/job/68472022017


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

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
Copilot AI changed the title [WIP] Fix the failing GitHub Actions workflow release fix: correct ldflags quoting in release workflow Mar 25, 2026
Copilot AI requested a review from skarim March 25, 2026 03:45
@skarim skarim marked this pull request as ready for review March 25, 2026 04:05
Copilot AI review requested due to automatic review settings March 25, 2026 04:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the GitHub release workflow to pass Go linker flags in a space-free form, ensuring the cmd.Version variable is injected reliably during extension precompilation.

Changes:

  • Adjust go_build_options to use -ldflags=-X=... format (no embedded spaces/quotes) when setting github.com/github/gh-stack/cmd.Version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

Warning

This is an internal experiment to assess Copilot's ability to auto-approve PRs. Please 👍 this comment if the assessment below is correct and 👎 if not. Feedback in #f-ccr-auto-approve is appreciated!

Copilot thinks this PR is ready to approve and merge.

@skarim skarim merged commit 4e0263f into main Mar 25, 2026
8 checks passed
@skarim skarim deleted the copilot/fix-github-actions-workflow-release branch March 25, 2026 21:57
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.

3 participants