forked from Niek/superview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·71 lines (61 loc) · 2.49 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: ./build.sh <version number>"
echo "Suggested version: "$(git describe --tags | tr -d v | awk '{printf "%.1f", $1 + .1}')
exit
fi
if ! command -v fyne-cross &> /dev/null; then
echo "This build script requires fyne-cross v2 to be installed:"
echo "go get github.com/lucor/fyne-cross/v2/cmd/fyne-cross"
exit
fi
VERSION=$1
echo "Build packages with version number ${VERSION}"
platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/386" "linux/amd64")
files=()
for program in "superview-cli" "superview-gui"; do
for platform in "${platforms[@]}"; do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name="${program}-${GOOS}-${GOARCH}-v${VERSION}"
if [ $GOOS == "windows" ]; then
output_name+=".exe"
fi
if [ "$program" == "superview-cli" ]; then
output_name="build/${output_name}"
env GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -o $output_name ${program}.go
if [ $? -ne 0 ]; then
echo "An error has occurred! Aborting the script execution..."
exit 1
fi
else
fyne-cross ${GOOS} -silent -arch ${GOARCH} -ldflags="-s -w" -output ${output_name} "${program}.go"
output_name="fyne-cross/dist/${GOOS}-${GOARCH}/${output_name}"
if [ $GOOS == "windows" ]; then
output_name+=".zip"
elif [ $GOOS == "linux" ]; then
output_name+=".tar.gz"
else
if command -v create-dmg &> /dev/null; then
# Create the DMG file
create-dmg --hdiutil-quiet --volname "Superview" --volicon "Icon.png" "${output_name}.dmg" "${output_name}.app"
output_name+=".dmg"
# Sign the DMG including all content
if command -v codesign &> /dev/null; then
codesign --force --verify --verbose --sign "Apple Distribution: Nivadema B.V. (N577R5DT64)" "${output_name}"
fi
else
output_name+=".app"
fi
fi
fi
echo "Built: ${output_name}"
files+=($output_name)
done
done
git tag v${VERSION}
git push origin --tags
if command -v hub &> /dev/null; then
hub release create -do $(for f in "${files[@]}"; do echo "-a "$f; done) -m "Release v${VERSION}" v${VERSION}
fi