forked from michael1011/lightningtip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·74 lines (55 loc) · 2.07 KB
/
release.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
72
73
74
#!/usr/bin/env bash
# Simple bash script to build basic lnd tools for all the platforms
# we support with the golang cross-compiler.
#
# Copyright (c) 2016 Company 0, LLC.
# Use of this source code is governed by the ISC
# license.
# If no tag specified, use date + version otherwise use tag.
if [[ $1x = x ]]; then
DATE=`date +%Y%m%d`
VERSION="01"
TAG=$DATE-$VERSION
else
TAG=$1
fi
PACKAGE=lightningTip
MAINDIR=$PACKAGE-$TAG
mkdir -p $MAINDIR
cd $MAINDIR
SYS=( "windows-386" "windows-amd64" "linux-386" "linux-amd64" "linux-arm" "linux-arm64")
# GCC cross compiler for the SYS above
# These are necessary for https://github.com/mattn/go-sqlite3
# It is assumed that the machine you are compiling on is running Linux amd64
GCC=( "i686-w64-mingw32-gcc" "x86_64-w64-mingw32-gcc" "gcc" "gcc" "arm-linux-gnueabihf-gcc" "aarch64-linux-gnu-gcc")
# Additional flag to allow cross compiling from 64 to 32 bit on Linux
GCC_LINUX_32BIT="-m32"
cp -r ../frontend/ .
# Use the first element of $GOPATH in the case where GOPATH is a list
# (something that is totally allowed).
GPATH=$(echo $GOPATH | cut -f1 -d:)
for index in ${!SYS[@]}; do
OS=$(echo ${SYS[index]} | cut -f1 -d-)
ARCH=$(echo ${SYS[index]} | cut -f2 -d-)
CC=${GCC[index]}
CFLAGS=""
mkdir $PACKAGE-${SYS[index]}-$TAG
cd $PACKAGE-${SYS[index]}-$TAG
echo "Building:" $OS $ARCH
# Add flag to allow cross compilation to 32 bit Linux
if [[ $OS = "linux" ]]; then
if [[ $ARCH = "386" ]]; then
CFLAGS="$GCC_LINUX_32BIT"
fi
fi
env GOOS=$OS GOARCH=$ARCH CGO_ENABLED=1 CC=$CC CFLAGS=$CFLAGS LDFLAGS=$CFLAGS go build github.com/michael1011/lightningtip
env GOOS=$OS GOARCH=$ARCH CGO_ENABLED=1 CC=$CC CFLAGS=$CFLAGS LDFLAGS=$CFLAGS go build github.com/michael1011/lightningtip/cmd/tipreport
cd ..
if [[ $OS = "windows" ]]; then
zip -r $PACKAGE-${SYS[index]}-$TAG.zip $PACKAGE-${SYS[index]}-$TAG frontend/
else
tar -cvzf $PACKAGE-${SYS[index]}-$TAG.tar.gz $PACKAGE-${SYS[index]}-$TAG frontend/
fi
rm -r $PACKAGE-${SYS[index]}-$TAG
done
rm -rf frontend