2016-03-01 19:15:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
shopt -s nullglob # if no files match glob, assume empty list instead of string literal
|
|
|
|
|
|
|
|
## PACKAGE TO BUILD
|
|
|
|
Package=github.com/mholt/caddy
|
|
|
|
Extension=github.com/hacdias/caddy-hugo
|
|
|
|
|
|
|
|
## PATHS TO USE
|
|
|
|
DistDir=$GOPATH/src/$Extension/dist
|
|
|
|
BuildDir=$DistDir/builds
|
|
|
|
ReleaseDir=$DistDir/release
|
|
|
|
|
|
|
|
caddyext install hugo:github.com/hacdias/caddy-hugo
|
|
|
|
|
|
|
|
## BEGIN
|
|
|
|
|
|
|
|
# Compile binaries
|
|
|
|
mkdir -p $BuildDir
|
|
|
|
cd $BuildDir
|
|
|
|
rm -f caddy*
|
2016-03-01 20:38:02 +00:00
|
|
|
gox $Package
|
2016-03-01 19:15:02 +00:00
|
|
|
|
|
|
|
# Zip them up with release notes and stuff
|
|
|
|
mkdir -p $ReleaseDir
|
|
|
|
cd $ReleaseDir
|
|
|
|
rm -f caddy*
|
|
|
|
for f in $BuildDir/*
|
|
|
|
do
|
|
|
|
# Name .zip file same as binary, but strip .exe from end
|
2016-03-02 19:12:07 +00:00
|
|
|
zipname=$(basename ${f%".exe"})
|
2016-03-01 19:15:02 +00:00
|
|
|
if [[ $f == *"linux"* ]] || [[ $f == *"bsd"* ]]; then
|
|
|
|
zipname=${zipname}.tar.gz
|
|
|
|
else
|
|
|
|
zipname=${zipname}.zip
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Binary inside the zip file is simply the project name
|
|
|
|
binbase=$(basename $Package)
|
|
|
|
if [[ $f == *.exe ]]; then
|
|
|
|
binbase=$binbase.exe
|
|
|
|
fi
|
|
|
|
bin=$BuildDir/$binbase
|
|
|
|
mv $f $bin
|
|
|
|
|
|
|
|
# Compress distributable
|
|
|
|
if [[ $zipname == *.zip ]]; then
|
|
|
|
zip -j $zipname $bin
|
|
|
|
else
|
2016-03-01 19:47:12 +00:00
|
|
|
tar -cvzf $zipname -C $BuildDir $binbase
|
2016-03-01 19:15:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Put binary filename back to original
|
|
|
|
mv $bin $f
|
|
|
|
done
|
|
|
|
|
2016-03-02 22:08:56 +00:00
|
|
|
cd $DistDir
|
|
|
|
pwd
|
|
|
|
ls
|
|
|
|
sed -i 's/{TIME}/'$(date +%s)'/g' bintray.json
|