diff --git a/.gitignore b/.gitignore index c4660c508d..ab9c6a2d37 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ man # generated when running local website build docs/website/.hugo_build.lock docs/website/data/versions + +# generated when building windows binary to add icon and product version +resource.syso \ No newline at end of file diff --git a/Makefile b/Makefile index 1f7d535c48..8a045a8edc 100644 --- a/Makefile +++ b/Makefile @@ -97,6 +97,9 @@ release-dir: .PHONY: generate generate: wasm-lib-build +ifeq ($(GOOS),windows) + GOOS=$(shell go env GOOS) GOARCH=$(shell go env GOARCH) go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.5.0 +endif $(GO) generate .PHONY: build diff --git a/build/gen-windows-versioninfo.sh b/build/gen-windows-versioninfo.sh new file mode 100755 index 0000000000..17a894d878 --- /dev/null +++ b/build/gen-windows-versioninfo.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Run goversioninfo to generate the resource.syso to embed version info. +set -eux + +NAME="Open Policy Agent (OPA)" +VERSION=$(./build/get-build-version.sh) +FLAGS=() + +# If building for arm64, then include the extra flags required. +if [ -n "${1+x}" ] && [ "$1" = "arm64" ]; then + FLAGS=(-arm -64) +fi + +if ! command -v goversioninfo &> /dev/null; then + # If goversioninfo isn't on the path, print an error message + echo "Error: goversioninfo command not found" >&2 + exit 1 +fi + +goversioninfo "${FLAGS[@]}" \ + -product-name "$NAME" \ + -product-version "$VERSION" \ + -skip-versioninfo \ + -icon=logo/logo.ico \ + -64=true \ + -o resource.syso \ No newline at end of file diff --git a/logo/logo.ico b/logo/logo.ico new file mode 100644 index 0000000000..4f92c9b036 Binary files /dev/null and b/logo/logo.ico differ diff --git a/main_windows.go b/main_windows.go new file mode 100644 index 0000000000..4cdc9ff211 --- /dev/null +++ b/main_windows.go @@ -0,0 +1,5 @@ +//go:build windows + +//go:generate build/gen-windows-versioninfo.sh $GOARCH + +package main