-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-executables.sh
More file actions
executable file
·61 lines (52 loc) · 1.34 KB
/
Copy pathbuild-executables.sh
File metadata and controls
executable file
·61 lines (52 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
version=$1
if [[ -z "$version" ]]; then
echo "usage: $0 <version>"
exit 1
fi
package_name=stashflow
binary_name=$package_name
# The full list of the platforms is at: https://golang.org/doc/install/source#environment
platforms=(
#"darwin/amd64"
"darwin/arm64"
"linux/amd64"
"linux/arm"
"linux/arm64"
#"windows/amd64"
)
rm -rf release/
mkdir -p release
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
os=${platform_split[0]}
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
if [ $os = "darwin" ]; then
os="macOS"
fi
output_binary=$binary_name
if [ $os = "windows" ]; then
output_binary+='.exe'
fi
archive_name=$package_name'-'$version'-'$os'-'$GOARCH
echo "Building release/$output_binary for $os-$GOARCH..."
env GOOS=$GOOS GOARCH=$GOARCH go build \
-ldflags="-s -w -X main.version=$version" \
-o release/$output_binary ./cmd/stashflow
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
pushd release > /dev/null
if [ $os = "windows" ]; then
zip $archive_name.zip $output_binary
rm $output_binary
else
chmod a+x $output_binary
gzip -c $output_binary > $archive_name.gz
rm $output_binary
fi
popd > /dev/null
done