Updates build configuration for multi-platform support

Configures the build process to support multiple platforms (Linux, Darwin, Windows) and architectures (amd64, arm64).

Disables CGO to simplify cross-compilation.

Updates Docker image creation to produce separate images for amd64 and arm64, and creates manifest lists for `latest` and versioned tags.
This commit is contained in:
Antoine Aflalo
2025-02-13 20:12:49 -05:00
parent a3dfec642c
commit 2da3bae04a

View File

@@ -27,8 +27,14 @@ builds:
main: cmd/cbzoptimizer/main.go main: cmd/cbzoptimizer/main.go
goos: goos:
- linux - linux
- darwin
- windows
goarch: goarch:
- amd64 - amd64
- arm64
ignore:
- goos: windows
goarch: arm64
# ensures mod timestamp to be the commit timestamp # ensures mod timestamp to be the commit timestamp
mod_timestamp: "{{ .CommitTimestamp }}" mod_timestamp: "{{ .CommitTimestamp }}"
flags: flags:
@@ -37,7 +43,7 @@ builds:
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }}
env: env:
- CGO_ENABLED=1 - CGO_ENABLED=0
# config the checksum filename # config the checksum filename
# https://goreleaser.com/customization/checksum # https://goreleaser.com/customization/checksum
checksum: checksum:
@@ -60,11 +66,25 @@ sboms:
# https://goreleaser.com/customization/docker # https://goreleaser.com/customization/docker
dockers: dockers:
- image_templates: - image_templates:
- "ghcr.io/belphemur/cbzoptimizer:latest" - "ghcr.io/belphemur/cbzoptimizer:latest-amd64"
- "ghcr.io/belphemur/cbzoptimizer:{{ .Version }}" - "ghcr.io/belphemur/cbzoptimizer:{{ .Version }}-amd64"
dockerfile: Dockerfile use: buildx
build_flag_templates: build_flag_templates:
- "--pull" - "--pull"
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- image_templates:
- "ghcr.io/belphemur/cbzoptimizer:latest-arm64"
- "ghcr.io/belphemur/cbzoptimizer:{{ .Version }}-arm64"
use: buildx
goarch: arm64
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.created={{.Date}}" - "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}" - "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}" - "--label=org.opencontainers.image.revision={{.FullCommit}}"
@@ -97,4 +117,13 @@ docker_signs:
args: args:
- "sign" - "sign"
- "${artifact}" - "${artifact}"
- "--yes" # needed on cosign 2.0.0+ - "--yes" # needed on cosign 2.0.0+
docker_manifests:
- name_template: "ghcr.io/belphemur/cbzoptimizer:{{ .Version }}"
image_templates:
- "ghcr.io/belphemur/cbzoptimizer:{{ .Version }}-amd64"
- "ghcr.io/belphemur/cbzoptimizer:{{ .Version }}-arm64"
- name_template: "ghcr.io/belphemur/cbzoptimizer:latest"
image_templates:
- "ghcr.io/belphemur/cbzoptimizer:latest-amd64"
- "ghcr.io/belphemur/cbzoptimizer:latest-arm64"