Skip to content

fix: only emit GH_AW_VERSION with real version in release builds, use "dev" otherwise#20433

Merged
pelikhan merged 3 commits intomainfrom
copilot/set-env-variable-for-release
Mar 10, 2026
Merged

fix: only emit GH_AW_VERSION with real version in release builds, use "dev" otherwise#20433
pelikhan merged 3 commits intomainfrom
copilot/set-env-variable-for-release

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Summary

In all four engine files (copilot_engine_execution.go, claude_engine.go, gemini_engine.go, codex_engine.go), the GH_AW_VERSION environment variable was unconditionally set to GetVersion(). This meant that dev builds would expose a git commit hash or other non-release string to agents at runtime.

Changes

  • In each engine's env-building function, guard the real version behind IsRelease():
    • Release builds: GH_AW_VERSION = GetVersion() (e.g. v1.2.3)
    • Dev/non-release builds: GH_AW_VERSION = "dev"

Copilot AI and others added 3 commits March 10, 2026 23:39
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… dev otherwise

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 10, 2026 23:57
Copilot AI review requested due to automatic review settings March 10, 2026 23:57
@pelikhan pelikhan merged commit e98c1aa into main Mar 10, 2026
77 checks passed
@pelikhan pelikhan deleted the copilot/set-env-variable-for-release branch March 10, 2026 23:57
Copy link
Contributor

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

This PR aims to prevent development builds from leaking non-release version strings (e.g., git commit hashes) to running agents via the GH_AW_VERSION environment variable by emitting the real version only for release builds and using "dev" otherwise.

Changes:

  • Update engine env construction to set GH_AW_VERSION to GetVersion() only when IsRelease() is true, otherwise "dev".
  • Regenerate compiled workflow lock files (.lock.yml) (currently still showing commit-hash values for GH_AW_VERSION).

Reviewed changes

Copilot reviewed 170 out of 170 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/workflow/copilot_engine_execution.go Gate GH_AW_VERSION behind IsRelease() in Copilot execution env.
pkg/workflow/claude_engine.go Gate GH_AW_VERSION behind IsRelease() in Claude execution env.
pkg/workflow/gemini_engine.go Gate GH_AW_VERSION behind IsRelease() in Gemini execution env.
pkg/workflow/codex_engine.go Gate GH_AW_VERSION behind IsRelease() in Codex execution env.
.github/workflows/*.lock.yml (many) Updates compiled workflow env blocks; should reflect "dev" for GH_AW_VERSION when compiled from non-release builds.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 680 to 682
GH_AW_SAFE_OUTPUTS: ${{ env.GH_AW_SAFE_OUTPUTS }}
GH_AW_VERSION: 0238dc8
GH_AW_VERSION: 0ffaddb
GITHUB_API_URL: ${{ github.api_url }}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The compiled workflow still hardcodes GH_AW_VERSION to a git hash. With the new engine logic, non-release builds should emit GH_AW_VERSION: dev, so the .lock.yml files should be regenerated with a non-release build of gh aw to reflect that behavior (and avoid continuing to leak commit hashes to agents at runtime).

Copilot uses AI. Check for mistakes.
Comment on lines +270 to +276
// Include the compiler version so agents can identify which gh-aw version generated the workflow.
// Only emit the real version in release builds; otherwise use "dev".
if IsRelease() {
env["GH_AW_VERSION"] = GetVersion()
} else {
env["GH_AW_VERSION"] = "dev"
}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

This introduces new branching behavior for GH_AW_VERSION (release -> real version, non-release -> "dev"), but there doesn’t appear to be a unit test asserting the rendered step env contains the expected value in both modes. Adding/adjusting engine tests to cover both IsRelease()==false and IsRelease()==true would prevent regressions (especially since this value is emitted into committed .lock.yml workflows).

Copilot uses AI. Check for mistakes.
Comment on lines +274 to +278
if IsRelease() {
env["GH_AW_VERSION"] = GetVersion()
} else {
env["GH_AW_VERSION"] = "dev"
}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The same IsRelease() / GetVersion() vs "dev" branching is now duplicated across multiple engines. Consider centralizing this into a small helper (e.g., a function that returns the value for GH_AW_VERSION, or a helper that sets it on an env map) to reduce repetition and the chance of future engines diverging.

Copilot uses AI. Check for mistakes.
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