mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
Clean up build.sh
This commit is contained in:
parent
0618e2b9b4
commit
0afcb5b7e7
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
syncthing
|
syncthing
|
||||||
|
syncthing.exe
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
dist
|
*.zip
|
||||||
|
118
build.sh
118
build.sh
@ -2,48 +2,90 @@
|
|||||||
|
|
||||||
export COPYFILE_DISABLE=true
|
export COPYFILE_DISABLE=true
|
||||||
|
|
||||||
|
distFiles=(README.md LICENSE) # apart from the binary itself
|
||||||
version=$(git describe --always)
|
version=$(git describe --always)
|
||||||
buildDir=dist
|
|
||||||
|
|
||||||
if [[ $fast != yes ]] ; then
|
build() {
|
||||||
|
go build -ldflags "-w -X main.Version $version" ./cmd/syncthing
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare() {
|
||||||
./assets.sh | gofmt > auto/gui.files.go
|
./assets.sh | gofmt > auto/gui.files.go
|
||||||
go get -d
|
go get -d
|
||||||
|
}
|
||||||
|
|
||||||
|
test() {
|
||||||
go test ./...
|
go test ./...
|
||||||
fi
|
}
|
||||||
|
|
||||||
if [[ -z $1 ]] ; then
|
tarDist() {
|
||||||
go build -ldflags "-X main.Version $version" ./cmd/syncthing
|
name="$1"
|
||||||
elif [[ $1 == "tar" ]] ; then
|
mkdir -p "$name"
|
||||||
go build -ldflags "-X main.Version $version" ./cmd/syncthing \
|
cp syncthing "${distFiles[@]}" "$name"
|
||||||
&& mkdir syncthing-dist \
|
tar zcvf "$name.tar.gz" "$name"
|
||||||
&& cp syncthing README.md LICENSE syncthing-dist \
|
rm -rf "$name"
|
||||||
&& tar zcvf syncthing-dist.tar.gz syncthing-dist \
|
}
|
||||||
&& rm -rf syncthing-dist
|
|
||||||
elif [[ $1 == "all" ]] ; then
|
|
||||||
rm -rf "$buildDir"
|
|
||||||
mkdir -p "$buildDir" || exit 1
|
|
||||||
|
|
||||||
export GOARM=7
|
zipDist() {
|
||||||
for os in darwin-amd64 linux-amd64 linux-arm freebsd-amd64 windows-amd64 ; do
|
name="$1"
|
||||||
echo "$os"
|
mkdir -p "$name"
|
||||||
export name="syncthing-$os"
|
cp syncthing.exe "${distFiles[@]}" "$name"
|
||||||
export GOOS=${os%-*}
|
zip -r "$name.zip" "$name"
|
||||||
export GOARCH=${os#*-}
|
rm -rf "$name"
|
||||||
go build -ldflags "-X main.Version $version" ./cmd/syncthing
|
}
|
||||||
mkdir -p "$name"
|
|
||||||
cp README.md LICENSE "$name"
|
case "$1" in
|
||||||
case $GOOS in
|
"")
|
||||||
windows)
|
build
|
||||||
cp syncthing.exe "$buildDir/$name.exe"
|
;;
|
||||||
mv syncthing.exe "$name"
|
|
||||||
zip -qr "$buildDir/$name.zip" "$name"
|
tar)
|
||||||
;;
|
rm -f *.tar.gz *.zip
|
||||||
*)
|
prepare
|
||||||
cp syncthing "$buildDir/$name"
|
test || exit 1
|
||||||
mv syncthing "$name"
|
build
|
||||||
tar zcf "$buildDir/$name.tar.gz" "$name"
|
|
||||||
;;
|
eval $(go env)
|
||||||
esac
|
name="syncthing-$GOOS-$GOARCH-$version"
|
||||||
rm -r "$name"
|
|
||||||
done
|
tarDist "$name"
|
||||||
fi
|
;;
|
||||||
|
|
||||||
|
all)
|
||||||
|
rm -f *.tar.gz *.zip
|
||||||
|
prepare
|
||||||
|
test || exit 1
|
||||||
|
|
||||||
|
export GOARM=7
|
||||||
|
for os in darwin-amd64 linux-amd64 linux-arm freebsd-amd64 windows-amd64 ; do
|
||||||
|
export GOOS=${os%-*}
|
||||||
|
export GOARCH=${os#*-}
|
||||||
|
|
||||||
|
build
|
||||||
|
|
||||||
|
name="syncthing-$os-$version"
|
||||||
|
case $GOOS in
|
||||||
|
windows)
|
||||||
|
zipDist "$name"
|
||||||
|
rm -f syncthing.exe
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
tarDist "$name"
|
||||||
|
rm -f syncthing
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
|
||||||
|
upload)
|
||||||
|
tag=$(git describe)
|
||||||
|
shopt -s nullglob
|
||||||
|
for f in *gz *zip ; do
|
||||||
|
relup calmh/syncthing "$tag" "$f"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Unknown build parameter $1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user