Use Go 1.7 for cross compilation instead of goxc(1)

This commit is contained in:
Marius 2016-09-30 00:10:42 +02:00
parent 216c45287a
commit 536aaeba71
2 changed files with 90 additions and 17 deletions

84
.scripts/build_all.sh Executable file
View File

@ -0,0 +1,84 @@
#!/usr/bin/env bash
set -e
version=$TRAVIS_TAG
commit=$TRAVIS_COMMIT
function compile {
local os=$1
local arch=$2
local ext=$3
echo "Compiling for $os/$arch..."
local dir="tusd_${os}_${arch}"
rm -rf "$dir"
mkdir -p "$dir"
GOOS=$os GOARCH=$arch go build \
-ldflags="-X github.com/tus/tusd/cmd/tusd/cli.VersionName=${version} -X github.com/tus/tusd/cmd/tusd/cli.GitCommit=${commit} -X 'github.com/tus/tusd/cmd/tusd/cli.BuildDate=$(date --utc)'" \
-o "$dir/tusd$ext" ./cmd/tusd/main.go
}
function makezip {
local os=$1
local arch=$2
local ext=$3
echo "Zipping for $os/$arch..."
local dir="tusd_${os}_${arch}"
zip "$dir.zip" "$dir/tusd$ext" LICENSE.txt README.md
}
function maketar {
local os=$1
local arch=$2
echo "Tarring for $os/$arch..."
local dir="tusd_${os}_${arch}"
tar -czf "$dir.tar.gz" "$dir/tusd" LICENSE.txt README.md
}
function makedep {
local arch=$1
echo "Debbing for $arch..."
local dir="tusd_snapshot_${arch}"
rm -rf "$dir"
mkdir -p "$dir"
mkdir -p "$dir/DEBIAN"
mkdir -p "$dir/usr/bin"
cp "./tusd_linux_${arch}/tusd" "./$dir/usr/bin/tusd"
echo "Package: tusd" >> "./$dir/DEBIAN/control"
echo "Maintainer: Marius <maerious@gmail.com>" >> "./$dir/DEBIAN/control"
echo "Section: devel" >> "./$dir/DEBIAN/control"
echo "Priority: optional" >> "./$dir/DEBIAN/control"
echo "Version: ${version}" >> "./$dir/DEBIAN/control"
echo "Architecture: ${arch}" >> "./$dir/DEBIAN/control"
echo "Homepage: https://github.com/tus/tusd" >> "./$dir/DEBIAN/control"
echo "Built-Using: $(go version)" >> "./$dir/DEBIAN/control"
echo "Description: The official server implementation of the tus resumable upload protocol." >> "./$dir/DEBIAN/control"
dpkg-deb --build "$dir"
}
compile linux 386
compile linux amd64
compile linux arm
compile darwin 386
compile darwin amd64
compile windows 386 .exe
compile windows amd64 .exe
maketar linux 386
maketar linux amd64
maketar linux arm
makezip darwin 386
makezip darwin amd64
makezip windows 386 .exe
makezip windows amd64 .exe
makedep amd64

View File

@ -21,35 +21,24 @@ matrix:
allow_failures:
- go: tip
install:
- export PACKAGES=$(find ./ -maxdepth 1 -type d -not \( -name ".git" -or -name "cmd" -or -name ".infra" -or -name "vendor" -or -name "data" -or -name ".hooks" \))
- export PACKAGES=$(find ./ -maxdepth 2 -name '*.go' -printf '%h\n' | sort | uniq)
- rsync -r ./vendor/ $GOPATH/src
- go get $PACKAGES
script:
- go test $PACKAGES
before_deploy:
- export GOROOT_BOOTSTRAP=$GOROOT
- go get github.com/laher/goxc
- goxc -t -bc="linux darwin windows"
- goxc -d=./ -wd=./cmd/tusd -bc="linux darwin windows" -build-ldflags="-X github.com/tus/tusd/cmd/tusd/cli.VersionName=$TRAVIS_TAG -X github.com/tus/tusd/cmd/tusd/cli.GitCommit=$TRAVIS_COMMIT -X 'github.com/tus/tusd/cmd/tusd/cli.BuildDate=$(date --utc)'"
- ./.scripts/build_all.sh
deploy:
provider: releases
api_key:
secure: dV3wr9ebEps3YrzIoqmkYc7fw0IECz7QLPRENPSxTJyd5TTYXGsnTS26cMe2LdGwYrXw0njt2GGovMyBZFTtxyYI3mMO4AZRwvZfx/yGzPWJBbVi6NjZVRg/bpyK+mQJ5BUlkPAYJmRpdc6qD+nvCGakBOxoByC5XDK+yM+bKFs=
file:
- snapshot/tusd_darwin_386.zip
- snapshot/tusd_darwin_amd64.zip
- snapshot/tusd_linux_386.tar.gz
- snapshot/tusd_linux_amd64.tar.gz
- snapshot/tusd_linux_arm.tar.gz
- snapshot/tusd_snapshot_amd64.deb
- snapshot/tusd_snapshot_armhf.deb
- snapshot/tusd_snapshot_i386.deb
- snapshot/tusd_windows_386.zip
- snapshot/tusd_windows_amd64.zip
file_glob: true
file: tusd_*.*
skip_cleanup: true
on:
all_branches: true
tags: true
go: 1.5
go: 1.7
repo: tus/tusd
after_deploy:
- make frey && frey setup --force-yes --projectDir .infra