-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not compress darwin arm64 binary (#714)
- Loading branch information
1 parent
5c7e47a
commit 4ca78b1
Showing
2 changed files
with
41 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This script compresses binary file built by goreleaser. | ||
# | ||
# Requires passing path to the binary file as an argument. | ||
# Requires UPX to be installed. | ||
|
||
# standard bash error handling | ||
set -o nounset # treat unset variables as an error and exit immediately. | ||
set -o errexit # exit immediately when a command fails. | ||
set -E # needs to be set if we want the ERR trap | ||
|
||
main() { | ||
number_of_arguments=$1 | ||
file_path=$2 | ||
|
||
if [[ $number_of_arguments -lt 1 ]]; then | ||
echo "Path to the binary file not provided" | ||
exit 1 | ||
fi | ||
|
||
# Do not compress darwin arm64 binary as it causes UPX to output broken file | ||
if ! ( grep -q "darwin" <<< "$file_path" && grep -q "arm64" <<< "$file_path" ); then | ||
upx -9 "$file_path" | ||
fi | ||
} | ||
|
||
main $# "${1:-""}" |