Skip to content

Commit a92862e

Browse files
committed
Add windows signing make target
1 parent e093fa1 commit a92862e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,48 @@ install_java_sdk: # Required by CI
128128
.pulumi/bin/pulumi: HOME := $(WORKING_DIR)
129129
.pulumi/bin/pulumi: .pulumi.version
130130
curl -fsSL https://get.pulumi.com | sh -s -- --version "$(PULUMI_VERSION)"
131+
132+
# Set these variables to enable signing of the windows binary
133+
AZURE_SIGNING_CLIENT_ID ?=
134+
AZURE_SIGNING_CLIENT_SECRET ?=
135+
AZURE_SIGNING_TENANT_ID ?=
136+
AZURE_SIGNING_KEY_VAULT_URI ?=
137+
SKIP_SIGNING ?=
138+
139+
bin/jsign-6.0.jar:
140+
wget https://github.com/ebourg/jsign/releases/download/6.0/jsign-6.0.jar --output-document=bin/jsign-6.0.jar
141+
142+
sign-goreleaser-exe-amd64: GORELEASER_ARCH := amd64_v1
143+
sign-goreleaser-exe-arm64: GORELEASER_ARCH := arm64
144+
145+
# Set the shell to bash to allow for the use of bash syntax.
146+
sign-goreleaser-exe-%: SHELL:=/bin/bash
147+
sign-goreleaser-exe-%: bin/jsign-6.0.jar
148+
@# Only sign windows binary if fully configured.
149+
@# Test variables set by joining with | between and looking for || showing at least one variable is empty.
150+
@# Move the binary to a temporary location and sign it there to avoid the target being up-to-date if signing fails.
151+
@set -e; \
152+
if [[ "${SKIP_SIGNING}" != "true" ]]; then \
153+
if [[ "|${AZURE_SIGNING_CLIENT_ID}|${AZURE_SIGNING_CLIENT_SECRET}|${AZURE_SIGNING_TENANT_ID}|${AZURE_SIGNING_KEY_VAULT_URI}|" == *"||"* ]]; then \
154+
echo "Can't sign windows binaries as required configuration not set: AZURE_SIGNING_CLIENT_ID, AZURE_SIGNING_CLIENT_SECRET, AZURE_SIGNING_TENANT_ID, AZURE_SIGNING_KEY_VAULT_URI"; \
155+
echo "To rebuild with signing delete the unsigned windows exe file and rebuild with the fixed configuration"; \
156+
if [[ "${CI}" == "true" ]]; then exit 1; fi; \
157+
else \
158+
file=dist/build-provider-sign-windows_windows_${GORELEASER_ARCH}/pulumi-resource-kubernetes-coredns.exe; \
159+
mv $${file} $${file}.unsigned; \
160+
az login --service-principal \
161+
--username "${AZURE_SIGNING_CLIENT_ID}" \
162+
--password "${AZURE_SIGNING_CLIENT_SECRET}" \
163+
--tenant "${AZURE_SIGNING_TENANT_ID}" \
164+
--output none; \
165+
ACCESS_TOKEN=$$(az account get-access-token --resource "https://vault.azure.net" | jq -r .accessToken); \
166+
java -jar bin/jsign-6.0.jar \
167+
--storetype AZUREKEYVAULT \
168+
--keystore "PulumiCodeSigning" \
169+
--url "${AZURE_SIGNING_KEY_VAULT_URI}" \
170+
--storepass "$${ACCESS_TOKEN}" \
171+
$${file}.unsigned; \
172+
mv $${file}.unsigned $${file}; \
173+
az logout; \
174+
fi; \
175+
fi

0 commit comments

Comments
 (0)