-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.sh
executable file
·53 lines (37 loc) · 1.31 KB
/
build.sh
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
#!/bin/bash
# This script will build rain for all platforms
set -e
NAME=cfn-format
OUTPUT_DIR=dist
VERSION=$(git describe --tags)
declare -A PLATFORMS=([linux]=linux [darwin]=macos [windows]=windows)
declare -A ARCHITECTURES=([386]=i386 [amd64]=amd64 [arm]=arm [arm64]=arm64)
# Run tests first
go vet ./... || exit 1
go test ./... || exit 1
echo "Building $NAME $VERSION..."
for platform in ${!PLATFORMS[@]}; do
for architecture in ${!ARCHITECTURES[@]}; do
if [[ "$architecture" == "386" && "$platform" == "darwin" ]]; then
continue
fi
if [[ "$architecture" == "arm" && "$platform" == "darwin" ]]; then
continue
fi
echo "$platform/$architecture..."
full_name="${NAME}-${VERSION}_${PLATFORMS[$platform]}-${ARCHITECTURES[$architecture]}"
bin_name="$NAME"
if [ "$platform" == "windows" ]; then
bin_name="${NAME}.exe"
fi
mkdir -p "$OUTPUT_DIR/$full_name"
eval GOOS=$platform GOARCH=$architecture go build -o "$OUTPUT_DIR/${full_name}/${bin_name}" "./cmd/cfn-format/*"
cp LICENSE "$OUTPUT_DIR/$full_name"
cp README.md "$OUTPUT_DIR/$full_name"
cd "$OUTPUT_DIR"
zip -9 -r "${full_name}.zip" "$full_name"
rm -r "$full_name"
cd -
done
done
echo "All done."