Skip to content

Commit f230630

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

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Makefile

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

0 commit comments

Comments
 (0)