Fix genrule variable syntax for manifest public key (#5542)

* Fix genrule variable syntax for manifest public key

Genrules use Make variable syntax $(VAR), not curly brace syntax {VAR}.
The curly brace syntax only works in x_defs for go_binary rules.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Use --action_env to pass MANIFEST_PUBLIC_KEY to genrule

Bazel genrules don't support workspace status variable substitution
in cmd strings. Instead, use --action_env to pass the environment
variable into the sandbox, where it can be referenced as a regular
shell variable ($$MANIFEST_PUBLIC_KEY in the genrule cmd).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Handle missing MANIFEST_PUBLIC_KEY env var in genrule

When building via 'bazel test //src/main/go/...', the genrule runs
without --action_env=MANIFEST_PUBLIC_KEY set. Use bash default value
syntax ${VAR:-} to default to empty string when the env var isn't set,
allowing the build to succeed with an empty public key.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Simplify public key handling - let empty var expand naturally

Bazel doesn't support ${VAR:-} syntax in genrule cmd. Instead, just
use $MANIFEST_PUBLIC_KEY directly - if not set, it expands to empty
string which the installer handles gracefully.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add manual tag to exclude webview installer from wildcard builds

The webview installer genrule requires --action_env=MANIFEST_PUBLIC_KEY
to be set. Adding tags = ["manual"] excludes it from wildcard patterns
like "bazel test //src/main/go/..." so it won't fail in the test workflow.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-21 21:12:47 -08:00
committed by GitHub
co-authored by Claude Opus 4.5
parent 8436106c7b
commit 63f0119a02
2 changed files with 7 additions and 2 deletions
+2 -1
View File
@@ -38,7 +38,8 @@ jobs:
fi
# Build Windows installer with WebView GUI (uses CGO cross-compilation)
bazel build //src/main/go/net/eagle0/clients/win/installer:eagle_installer_windows_amd64_webview --stamp
# Use --action_env to pass the signing key into the genrule sandbox
bazel build //src/main/go/net/eagle0/clients/win/installer:eagle_installer_windows_amd64_webview --stamp --action_env=MANIFEST_PUBLIC_KEY
# Copy to output directory
rm -rf ./installer-output
@@ -161,10 +161,12 @@ GOSUM
$$GO mod download
# Build with GUI subsystem flag
# MANIFEST_PUBLIC_KEY will be empty if not set via --action_env, which is fine
# (installer handles empty public key gracefully by skipping signature verification)
echo "Building Windows installer with WebView..."
OUTPUT_EXE="$$SANDBOX_ROOT/$@"
$$GO build -v \\
-ldflags="-H windowsgui -X main.manifestPublicKey={STABLE_MANIFEST_PUBLIC_KEY}" \\
-ldflags="-H windowsgui -X 'main.manifestPublicKey=$$MANIFEST_PUBLIC_KEY'" \\
-o "$$OUTPUT_EXE" \\
.
@@ -172,6 +174,8 @@ GOSUM
ls -la "$$OUTPUT_EXE"
""",
stamp = 1,
# Exclude from wildcard patterns - this target requires --action_env=MANIFEST_PUBLIC_KEY
tags = ["manual"],
visibility = ["//visibility:public"],
)