Skip to content

Commit

Permalink
Updates for deb build
Browse files Browse the repository at this point in the history
  • Loading branch information
svrana committed May 31, 2019
1 parent 2f8461c commit 8edbfcc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ GOFILES_WATCH := find . -type f -iname "*.go"
GOFILES_BUILD := $(shell find . -type f -iname "*.go")
PKGS := $(shell go list ./...)

VERSION := $(shell git describe --tags | cut -d'/' -f2 || echo "unreleased")
V_DIRTY := $(shell git describe --exact-match HEAD > /dev/null 2>&1 || echo "-unreleased")
VERSION := $(shell git describe --tags 2>/dev/null || echo "unreleased")
SHA := $(shell git rev-parse --short HEAD)


Expand All @@ -20,7 +19,7 @@ all: build/dev.linux build/dev.darwin ## Builds dev binaries for linux and osx

.PHONY: clean
clean: ## Removes all build artifacts
rm -rf build ; go clean ; rm *.deb
rm -rf build ; go clean ; rm -f dev_*.deb ; rm -f dev_*.changes ; rm -rf *.upload

.PHONY: lint
lint: ## Runs linter
Expand All @@ -35,12 +34,12 @@ test: lint vet ## Run static analysis and tests

build/dev.linux: $(**/*.go) test ## Creates the linux binary
@GOOS=linux CGO_ENABLED=0 go build -ldflags \
'-X "github.com/wish/dev/cmd.BuildDate=${DATE}" -X "github.com/wish/dev/cmd.BuildSha=$(SHA)" -X "github.com/wish/dev/cmd.BuildVersion=$(VERSION)$(V_DIRTY)"' \
'-X "github.com/wish/dev/cmd.BuildDate=${DATE}" -X "github.com/wish/dev/cmd.BuildSha=$(SHA)" -X "github.com/wish/dev/cmd.BuildVersion=$(VERSION)"' \
-o build/dev.linux cmd/dev/*

build/dev.darwin: $(**/*.go) test ## Creates the osx binary
@GOOS=darwin CGO_ENABLED=0 go build -ldflags \
'-X "github.com/wish/dev/cmd.BuildDate=${DATE}" -X "github.com/wish/dev/cmd.BuildSha=$(SHA)" -X "github.com/wish/dev/cmd.BuildVersion=$(VERSION)$(V_DIRTY)"' \
'-X "github.com/wish/dev/cmd.BuildDate=${DATE}" -X "github.com/wish/dev/cmd.BuildSha=$(SHA)" -X "github.com/wish/dev/cmd.BuildVersion=$(VERSION)"' \
-o build/dev.darwin cmd/dev/*

build/dev: ## Make a link to the executable for this OS type for convenience
Expand All @@ -50,13 +49,15 @@ build/dev: ## Make a link to the executable for this OS type for convenience
watch: ## Watch .go files for changes and rerun build (requires entr, see https://github.com/clibs/entr)
$(GOFILES_WATCH) | entr -rc $(MAKE)

# sudo add-apt-repository ppa:user/ppa-name
.PHONY: deb
deb: build/dev.linux ## Bundle the dev executable in a deb file for distribution
fpm --input-type dir --output-type deb \
--name dev \
--version $(VERSION)$(V_DIRTY) \
--version $(VERSION) \
--license MIT \
--maintainer [email protected] \
--deb-user root \
--deb-group root \
--deb-generate-changes \
build/dev.linux=/usr/bin/dev

0 comments on commit 8edbfcc

Please sign in to comment.