Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: signed windows and macos binaries #97

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ jobs:
# GitHub sets the GITHUB_TOKEN secret automatically.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
SP_CI_USER_TOKEN: ${{ secrets.SP_CI_USER_TOKEN }}
SP_ORGANIZATION_ID: ${{ secrets.SP_ORGANIZATION_ID }}
SP_PROJECT: ${{ secrets.SP_PROJECT }}

SWO_ISSUER_ID: ${{ secrets.SWO_ISSUER_ID }}
SWO_KEY_ID: ${{ secrets.SWO_KEY_ID }}
SWO_MAC_P8_FILE: ${{ secrets.SWO_MAC_P8_FILE }}
SWO_MAC_P12_CERT: ${{ secrets.SWO_MAC_P12_CERT }}
SWO_P12_PASSWORD: ${{ secrets.SWO_P12_PASSWORD }}
42 changes: 40 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy

builds:
- env:
- id: linux
env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
Expand All @@ -17,7 +19,6 @@ builds:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
Expand All @@ -29,15 +30,35 @@ builds:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
- id: windows
env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
ldflags:
- "-s -w -X 'main.version=v{{ .Version }}'"
targets:
- windows_amd64
hooks:
post:
- env:
- SP_SIGNING_POLICY=Release
- SP_ARTIFACT_CONFIGURATION=exe
cmd: pwsh -c "Submit-SigningRequest -ApiToken "$env:SP_CI_USER_TOKEN" -OrganizationId "$env:SP_ORGANIZATION_ID" -ProjectSlug "$env:SP_PROJECT" -SigningPolicySlug "$env:SP_SIGNING_POLICY" -ArtifactConfigurationSlug "$env:SP_ARTIFACT_CONFIGURATION" -InputArtifactPath '{{ .Path }}' -OutputArtifactPath '{{ .Path }}' -Force -WaitForCompletion"
output: true

archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'

checksum:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256

signs:
- artifacts: checksum
args:
Expand All @@ -50,9 +71,26 @@ signs:
- "${signature}"
- "--detach-sign"
- "${artifact}"

release:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
# If you want to manually examine the release before its live, uncomment this line:
# draft: true

notarize:
macos:
- enabled: '{{ isEnvSet "SWO_MAC_P12_CERT" }}'
ids:
- mac
sign:
certificate: "{{.Env.SWO_MAC_P12_CERT}}"
password: "{{.Env.SWO_P12_PASSWORD}}"

notarize:
issuer_id: "{{.Env.SWO_ISSUER_ID}}"
key_id: "{{.Env.SWO_KEY_ID}}"
key: "{{.Env.SWO_MAC_P8_FILE}}"
wait: true
timeout: 20m