mirror of
https://github.com/esimov/pigo.git
synced 2024-05-31 13:58:25 +08:00
Creatre build scripts
This commit is contained in:
parent
ac6bac1e3b
commit
7f8d2e3e28
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,5 +2,6 @@
|
||||
*.png
|
||||
*.jpg
|
||||
*.jpeg
|
||||
pigo
|
||||
vendor
|
||||
packages
|
||||
|
10
Makefile
Normal file
10
Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
all:
|
||||
@./build.sh
|
||||
clean:
|
||||
@rm -f pigo
|
||||
install: all
|
||||
@cp pigo /usr/local/bin
|
||||
uninstall:
|
||||
@rm -f /usr/local/bin/pigo
|
||||
package:
|
||||
@NOCOPY=1 ./build.sh package
|
65
build.sh
Executable file
65
build.sh
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
VERSION="1.0.1"
|
||||
PROTECTED_MODE="no"
|
||||
|
||||
export GO15VENDOREXPERIMENT=1
|
||||
|
||||
cd $(dirname "${BASH_SOURCE[0]}")
|
||||
OD="$(pwd)"
|
||||
WD=$OD
|
||||
|
||||
package() {
|
||||
echo Packaging $1 Binary
|
||||
bdir=pigo-${VERSION}-$2-$3
|
||||
rm -rf packages/$bdir && mkdir -p packages/$bdir
|
||||
GOOS=$2 GOARCH=$3 ./build.sh
|
||||
if [ "$2" == "windows" ]; then
|
||||
mv pigo packages/$bdir/pigo.exe
|
||||
else
|
||||
mv pigo packages/$bdir
|
||||
fi
|
||||
cp README.md packages/$bdir
|
||||
cd packages
|
||||
if [ "$2" == "linux" ]; then
|
||||
tar -zcf $bdir.tar.gz $bdir
|
||||
else
|
||||
zip -r -q $bdir.zip $bdir
|
||||
fi
|
||||
rm -rf $bdir
|
||||
cd ..
|
||||
}
|
||||
|
||||
if [ "$1" == "package" ]; then
|
||||
rm -rf packages/
|
||||
package "Windows" "windows" "amd64"
|
||||
package "Mac" "darwin" "amd64"
|
||||
package "Linux" "linux" "amd64"
|
||||
package "FreeBSD" "freebsd" "amd64"
|
||||
exit
|
||||
fi
|
||||
|
||||
# temp directory for storing isolated environment.
|
||||
TMP="$(mktemp -d -t sdb.XXXX)"
|
||||
rmtemp() {
|
||||
rm -rf "$TMP"
|
||||
}
|
||||
trap rmtemp EXIT
|
||||
|
||||
if [ "$NOCOPY" != "1" ]; then
|
||||
# copy all files to an isolated directory.
|
||||
WD="$TMP/src/github.com/esimov/pigo"
|
||||
export GOPATH="$TMP"
|
||||
for file in `find . -type f`; do
|
||||
# TODO: use .gitignore to ignore, or possibly just use git to determine the file list.
|
||||
if [[ "$file" != "." && "$file" != ./.git* && "$file" != ./pigo ]]; then
|
||||
mkdir -p "$WD/$(dirname "${file}")"
|
||||
cp -P "$file" "$WD/$(dirname "${file}")"
|
||||
fi
|
||||
done
|
||||
cd $WD
|
||||
fi
|
||||
|
||||
# build and store objects into original directory.
|
||||
go build -ldflags "-X main.Version=$VERSION" -o "$OD/pigo" cmd/pigo/*.go
|
Loading…
Reference in New Issue
Block a user