Skip to content

Commit

Permalink
Sign Windows release binaries (#3455)
Browse files Browse the repository at this point in the history
### Proposed changes

This PR adds a new Makefile target `make sign-goreleaser-exe` target to
sign all built GoReleaser windows binaries. This PR contains 2 changes:

- Makefile target
- Copied ci-mgmt workflow files for validation purposes (generated from:
pulumi/ci-mgmt#1318)

Please see the linked ci-mgmt issue for status of GitHub actions
workflows to validate that the binaries are signed.
  • Loading branch information
rquitales authored Jan 27, 2025
1 parent d05645f commit b776b68
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ on:
tags:
- v*.*.*-**
env:
AZURE_SIGNING_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
AZURE_SIGNING_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
AZURE_SIGNING_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
AZURE_SIGNING_KEY_VAULT_URI: ${{ secrets.AZURE_SIGNING_KEY_VAULT_URI }}
SKIP_SIGNING: ${{ secrets.AZURE_SIGNING_CLIENT_ID == '' &&
secrets.AZURE_SIGNING_CLIENT_SECRET == '' && secrets.AZURE_SIGNING_TENANT_ID
== '' && secrets.AZURE_SIGNING_KEY_VAULT_URI == '' }}
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
PROVIDER: kubernetes
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
- v*.*.*
- "!v*.*.*-**"
env:
AZURE_SIGNING_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
AZURE_SIGNING_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
AZURE_SIGNING_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
AZURE_SIGNING_KEY_VAULT_URI: ${{ secrets.AZURE_SIGNING_KEY_VAULT_URI }}
SKIP_SIGNING: ${{ secrets.AZURE_SIGNING_CLIENT_ID == '' &&
secrets.AZURE_SIGNING_CLIENT_SECRET == '' && secrets.AZURE_SIGNING_TENANT_ID
== '' && secrets.AZURE_SIGNING_KEY_VAULT_URI == '' }}
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
PROVIDER: kubernetes
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
Expand Down
33 changes: 25 additions & 8 deletions .goreleaser.prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,42 @@ before:
- make schema
- make k8sprovider
builds:
- dir: provider
- id: build-provider
dir: provider
env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- darwin
- windows
- linux
goarch:
- amd64
- arm64
ignore: []
ignore: &a1 []
main: ./cmd/pulumi-resource-kubernetes/
ldflags: &a2
- -s
- -w
- -X
github.com/pulumi/pulumi-kubernetes/provider/v4/pkg/version.Version={{.Tag}}
binary: pulumi-resource-kubernetes
- id: build-provider-sign-windows
dir: provider
env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- windows
goarch:
- amd64
- arm64
ignore: *a1
main: ./cmd/pulumi-resource-kubernetes/
ldflags:
- -s
- -w
- -X
github.com/pulumi/pulumi-kubernetes/provider/v4/pkg/version.Version={{.Tag}}
ldflags: *a2
binary: pulumi-resource-kubernetes
hooks:
post:
- make sign-goreleaser-exe-{{ .Arch }}
archives:
- name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
id: archive
Expand Down
33 changes: 25 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,42 @@ before:
- make schema
- make k8sprovider
builds:
- dir: provider
- id: build-provider
dir: provider
env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- darwin
- windows
- linux
goarch:
- amd64
- arm64
ignore: []
ignore: &a1 []
main: ./cmd/pulumi-resource-kubernetes/
ldflags: &a2
- -s
- -w
- -X
github.com/pulumi/pulumi-kubernetes/provider/v4/pkg/version.Version={{.Tag}}
binary: pulumi-resource-kubernetes
- id: build-provider-sign-windows
dir: provider
env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- windows
goarch:
- amd64
- arm64
ignore: *a1
main: ./cmd/pulumi-resource-kubernetes/
ldflags:
- -s
- -w
- -X
github.com/pulumi/pulumi-kubernetes/provider/v4/pkg/version.Version={{.Tag}}
ldflags: *a2
binary: pulumi-resource-kubernetes
hooks:
post:
- make sign-goreleaser-exe-{{ .Arch }}
archives:
- name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
id: archive
Expand Down
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,48 @@ install_nodejs_sdk::

examples::
cd provider/pkg/gen/examples/upstream && go run generate.go ./yaml ./

# Set these variables to enable signing of the windows binary
AZURE_SIGNING_CLIENT_ID ?=
AZURE_SIGNING_CLIENT_SECRET ?=
AZURE_SIGNING_TENANT_ID ?=
AZURE_SIGNING_KEY_VAULT_URI ?=
SKIP_SIGNING ?=

bin/jsign-6.0.jar:
wget https://github.com/ebourg/jsign/releases/download/6.0/jsign-6.0.jar --output-document=bin/jsign-6.0.jar

sign-goreleaser-exe-amd64: GORELEASER_ARCH := amd64_v1
sign-goreleaser-exe-arm64: GORELEASER_ARCH := arm64

# Set the shell to bash to allow for the use of bash syntax.
sign-goreleaser-exe-%: SHELL:=/bin/bash
sign-goreleaser-exe-%: bin/jsign-6.0.jar
@# Only sign windows binary if fully configured.
@# Test variables set by joining with | between and looking for || showing at least one variable is empty.
@# Move the binary to a temporary location and sign it there to avoid the target being up-to-date if signing fails.
@set -e; \
if [[ "${SKIP_SIGNING}" != "true" ]]; then \
if [[ "|${AZURE_SIGNING_CLIENT_ID}|${AZURE_SIGNING_CLIENT_SECRET}|${AZURE_SIGNING_TENANT_ID}|${AZURE_SIGNING_KEY_VAULT_URI}|" == *"||"* ]]; then \
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"; \
echo "To rebuild with signing delete the unsigned windows exe file and rebuild with the fixed configuration"; \
if [[ "${CI}" == "true" ]]; then exit 1; fi; \
else \
file=dist/build-provider-sign-windows_windows_${GORELEASER_ARCH}/pulumi-resource-kubernetes.exe; \
mv $${file} $${file}.unsigned; \
az login --service-principal \
--username "${AZURE_SIGNING_CLIENT_ID}" \
--password "${AZURE_SIGNING_CLIENT_SECRET}" \
--tenant "${AZURE_SIGNING_TENANT_ID}" \
--output none; \
ACCESS_TOKEN=$$(az account get-access-token --resource "https://vault.azure.net" | jq -r .accessToken); \
java -jar bin/jsign-6.0.jar \
--storetype AZUREKEYVAULT \
--keystore "PulumiCodeSigning" \
--url "${AZURE_SIGNING_KEY_VAULT_URI}" \
--storepass "$${ACCESS_TOKEN}" \
$${file}.unsigned; \
mv $${file}.unsigned $${file}; \
az logout; \
fi; \
fi

0 comments on commit b776b68

Please sign in to comment.