Move building functions into separate script file
This commit is contained in:
parent
74554f594d
commit
4a439ac555
|
@ -2,69 +2,9 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
version=$TRAVIS_TAG
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
commit=$TRAVIS_COMMIT
|
|
||||||
|
|
||||||
function compile {
|
source "${__dir}/build_funcs.sh"
|
||||||
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 386
|
||||||
compile linux amd64
|
compile linux amd64
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
version=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
commit=$(git log --format="%H" -n 1)
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f compile
|
||||||
|
export -f maketar
|
||||||
|
export -f makezip
|
||||||
|
export -f makedep
|
Loading…
Reference in New Issue