Skip to content

Commit fa9b366

Browse files
authored
ci: improve goreleaser pipeline (#773)
This PR improves the goreleaser pipeline in the following ways: - It utilizes the [YAML merge key](https://yaml.org/type/merge.html) to reduce code duplication - It adds the `-s` ldflag to reduce binary size: [Omit the symbol table and debug information.](https://pkg.go.dev/cmd/link) - It adds the `-trimpath` flag to trim absolute file paths from build output Binary size of `linux/amd64` build on: - 069fffe: 14192497 B - d0dfda9: 12738712 B -> File size reduction is about 10%.
1 parent 069fffe commit fa9b366

File tree

1 file changed

+21
-35
lines changed

1 file changed

+21
-35
lines changed

.goreleaser.yml

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,28 @@ before:
33
- go mod tidy
44

55
builds:
6-
- id: hcloud-build
7-
main: ./cmd/hcloud/main.go
8-
binary: hcloud
9-
ldflags:
10-
- -w
11-
- -X {{ .ModulePath }}/internal/version.version={{ .Version }}
12-
- -X {{ .ModulePath }}/internal/version.versionPrerelease={{- if .IsSnapshot -}}dev+{{ .ShortCommit }}{{- end -}}
13-
env:
14-
- CGO_ENABLED=0
15-
goos:
16-
- freebsd
17-
- windows
18-
- linux
19-
goarch:
20-
- amd64
21-
- arm
22-
- arm64
23-
- "386"
24-
goarm:
25-
- "6"
26-
- "7"
6+
- <<: &build_defaults
7+
main: ./cmd/hcloud/main.go
8+
binary: hcloud
9+
flags:
10+
- -trimpath
11+
ldflags:
12+
- -s
13+
- -w
14+
- -X {{ .ModulePath }}/internal/version.version={{ .Version }}
15+
- -X {{ .ModulePath }}/internal/version.versionPrerelease={{- if .IsSnapshot -}}dev+{{ .ShortCommit }}{{- end -}}
16+
env:
17+
- CGO_ENABLED=0
2718

28-
- id: hcloud-build-darwin
29-
main: ./cmd/hcloud/main.go
30-
binary: hcloud
31-
ldflags:
32-
- -w
33-
- -X {{ .ModulePath }}/internal/version.version={{ .Version }}
34-
- -X {{ .ModulePath }}/internal/version.versionPrerelease={{- if .IsSnapshot -}}dev+{{ .ShortCommit }}{{- end -}}
35-
env:
36-
- CGO_ENABLED=0
37-
goos:
38-
- darwin
39-
goarch:
40-
- amd64
41-
- arm64
19+
id: hcloud-build
20+
goos: [freebsd, windows, linux]
21+
goarch: [amd64, arm, arm64, "386"]
22+
goarm: ["6", "7"]
23+
24+
- <<: *build_defaults
25+
id: hcloud-build-darwin
26+
goos: [darwin]
27+
goarch: [amd64, arm64]
4228
hooks:
4329
post:
4430
- cmd: >

0 commit comments

Comments
 (0)