mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
Update packing task to use gox
This commit is contained in:
14
Makefile
14
Makefile
@@ -1,11 +1,15 @@
|
||||
DEV_DEPS = github.com/kardianos/govendor \
|
||||
github.com/vektra/mockery/.../ \
|
||||
github.com/mailru/easyjson/... \
|
||||
github.com/jteeuwen/go-bindata/...
|
||||
github.com/jteeuwen/go-bindata/... \
|
||||
github.com/mitchellh/gox
|
||||
|
||||
BINARY = bin/ozuio
|
||||
BINNAME = ozuio
|
||||
BINARY = bin/${BINNAME}
|
||||
BINDIR = $(shell dirname ${BINARY})
|
||||
SOURCES = $(shell find . -name '*.go')
|
||||
VERSION = $(shell cat VERSION)
|
||||
OSARCH = "linux/amd64 darwin/amd64"
|
||||
|
||||
.DEFAULT_GOAL: $(BINARY)
|
||||
$(BINARY): $(SOURCES)
|
||||
@@ -64,5 +68,7 @@ web-debug-bindata:
|
||||
cd web && go-bindata -debug -pkg web static/... templates/...
|
||||
|
||||
.PHONY: package
|
||||
package:
|
||||
./package.sh
|
||||
package: dev-deps
|
||||
gox -output "pkg/${VERSION}/${BINNAME}_${VERSION}_{{.OS}}_{{.Arch}}" \
|
||||
-osarch=${OSARCH} \
|
||||
-ldflags "-X main.Version=${VERSION}"
|
||||
|
||||
72
package.sh
72
package.sh
@@ -1,72 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
set -e
|
||||
shopt -s extglob
|
||||
|
||||
main() {
|
||||
local name="ozuio"
|
||||
local platforms=(
|
||||
darwin-386 darwin-amd64
|
||||
freebsd-386 freebsd-amd64 freebsd-arm
|
||||
linux-386 linux-amd64 linux-arm
|
||||
netbsd-386 netbsd-amd64 netbsd-arm
|
||||
openbsd-386 openbsd-amd64
|
||||
solaris-amd64
|
||||
windows-386 windows-amd64
|
||||
)
|
||||
local builddir="build"
|
||||
local outputdir="pkg"
|
||||
|
||||
local version
|
||||
version="$(get-version)"
|
||||
|
||||
local workdir="${builddir}/${version}"
|
||||
mkdir -p "$workdir"
|
||||
|
||||
for platform in "${platforms[@]}"; do
|
||||
if [[ "$platform" =~ ^(.+)-(.+)$ ]]; then
|
||||
local os="${BASH_REMATCH[1]}"
|
||||
local arch="${BASH_REMATCH[2]}"
|
||||
local pkg="${name}_${version}_${os}_${arch}"
|
||||
local pkgdir="${workdir}/${pkg}"
|
||||
local binary="${pkgdir}/${name}"
|
||||
|
||||
if [ "$os" == "windows" ]; then
|
||||
binary="${binary}.exe"
|
||||
fi
|
||||
|
||||
echo "building $pkg"
|
||||
GOOS="$os" GOARCH="$arch" go build -o "$binary" \
|
||||
-ldflags "-X main.Version=${version}"
|
||||
|
||||
cp "README.md" "${pkgdir}/"
|
||||
|
||||
mkdir -p "${outputdir}/${version}"
|
||||
|
||||
if [ "$os" == "windows" ]; then
|
||||
local archive="${outputdir}/${version}/${pkg}.zip"
|
||||
echo "creating ${archive}"
|
||||
local cwd="$(pwd)"
|
||||
cd "$workdir"
|
||||
zip -r "../../$archive" "$pkg"
|
||||
cd "$cwd"
|
||||
else
|
||||
local archive="${outputdir}/${version}/${pkg}.tar.gz"
|
||||
echo "creating ${archive}"
|
||||
tar -C "$workdir" -czf "$archive" "$pkg"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
get-version() {
|
||||
trim "$(cat "VERSION")"
|
||||
}
|
||||
|
||||
trim() {
|
||||
local string="$@"
|
||||
string="${string#"${string%%[![:space:]]*}"}"
|
||||
string="${string%"${string##*[![:space:]]}"}"
|
||||
echo -n "$string"
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user