Skip to content

Commit 4ca78b1

Browse files
Do not compress darwin arm64 binary (#714)
1 parent 5c7e47a commit 4ca78b1

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

.goreleaser.yml

+13-14
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ builds:
2929
- goos: windows
3030
goarch: arm64
3131
hooks: &build-hooks
32-
# Install upx first, https://github.com/upx/upx/releases
33-
post: upx -9 "{{ .Path }}"
32+
post: ./hack/compress-release-binary.sh {{ .Path }}
3433
main: ./cmd/cli
35-
binary: 'capact'
34+
binary: "capact"
3635
ldflags:
3736
- -s -w -X capact.io/capact/cmd/cli/cmd.Version={{.Version}} -X capact.io/capact/cmd/cli/cmd.Revision={{.ShortCommit}} -X capact.io/capact/cmd/cli/cmd.BuildDate={{.Date}} -X capact.io/capact/cmd/cli/cmd.Branch={{.Branch}}
3837

@@ -44,40 +43,40 @@ builds:
4443
ignore: *build-ignore
4544
hooks: *build-hooks
4645
main: ./cmd/populator
47-
binary: 'populator'
46+
binary: "populator"
4847

4948
archives:
5049
- id: capact-archive
51-
name_template: &archives-name-template '{{ .Binary }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
50+
name_template: &archives-name-template "{{ .Binary }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
5251
format: &archives-format binary
5352
builds:
54-
- capact
53+
- capact
5554

5655
- id: populator-archive
5756
name_template: *archives-name-template
5857
format: *archives-format
5958
builds:
60-
- populator
59+
- populator
6160

6261
brews:
6362
- name: capact
6463
ids:
65-
- capact-archive
64+
- capact-archive
6665
homepage: &homebrew-homepage https://github.com/capactio/homebrew-tap
6766
description: "Capact CLI is a command-line tool, which manages Capact resources."
6867
license: "Apache License 2.0"
6968
tap: &homebrew-tap
7069
owner: capactio
7170
name: homebrew-tap
7271
commit_author: &homebrew-commit-author
73-
name: Capact Bot
74-
72+
name: Capact Bot
73+
7574
test: |
7675
system "#{bin}/capact version"
7776
7877
- name: populator
7978
ids:
80-
- populator-archive
79+
- populator-archive
8180
homepage: *homebrew-homepage
8281
description: "Populator is a command-line tool, which helps to populate various Capact content."
8382
license: "Apache License 2.0"
@@ -97,7 +96,7 @@ dockers:
9796
- "ghcr.io/capactio/tools/capact-cli:v{{ .Major }}"
9897

9998
checksum:
100-
name_template: 'checksums.txt'
99+
name_template: "checksums.txt"
101100

102101
snapshot:
103102
name_template: "{{ .Tag }}-next"
@@ -106,8 +105,8 @@ changelog:
106105
sort: asc
107106
filters:
108107
exclude:
109-
- '^docs:'
110-
- '^test:'
108+
- "^docs:"
109+
- "^test:"
111110

112111
dist: bin
113112

hack/compress-release-binary.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This script compresses binary file built by goreleaser.
4+
#
5+
# Requires passing path to the binary file as an argument.
6+
# Requires UPX to be installed.
7+
8+
# standard bash error handling
9+
set -o nounset # treat unset variables as an error and exit immediately.
10+
set -o errexit # exit immediately when a command fails.
11+
set -E # needs to be set if we want the ERR trap
12+
13+
main() {
14+
number_of_arguments=$1
15+
file_path=$2
16+
17+
if [[ $number_of_arguments -lt 1 ]]; then
18+
echo "Path to the binary file not provided"
19+
exit 1
20+
fi
21+
22+
# Do not compress darwin arm64 binary as it causes UPX to output broken file
23+
if ! ( grep -q "darwin" <<< "$file_path" && grep -q "arm64" <<< "$file_path" ); then
24+
upx -9 "$file_path"
25+
fi
26+
}
27+
28+
main $# "${1:-""}"

0 commit comments

Comments
 (0)