Skip to content

Commit

Permalink
Add promu support to build binary
Browse files Browse the repository at this point in the history
- Modify Makefile for promu
- Add VERSION file
- Add promu.yml
  • Loading branch information
Charles JUDITH committed Jan 8, 2018
1 parent 162379f commit 8a757b2
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 4 deletions.
44 changes: 44 additions & 0 deletions .promu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
repository:
path: github.com/cloudflare/alertmanager2es
build:
binaries:
- name: alertmanager2es
path: .
flags: -a -tags netgo
ldflags: |
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
tarball:
files:
- LICENSE
- NOTICE
crossbuild:
platforms:
- linux/amd64
- linux/386
- darwin/amd64
- darwin/386
- windows/amd64
- windows/386
- freebsd/amd64
- freebsd/386
- openbsd/amd64
- openbsd/386
- netbsd/amd64
- netbsd/386
- dragonfly/amd64
- linux/arm
- linux/arm64
- freebsd/arm
# Temporarily deactivated as golang.org/x/sys does not have syscalls
# implemented for that os/platform combination.
#- openbsd/arm
#- linux/mips64
#- linux/mips64le
- netbsd/arm
- linux/ppc64
- linux/ppc64le

58 changes: 54 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,57 @@
.PHONY: build test
GO := GO15VENDOREXPERIMENT=1 go
PROMU := $(GOPATH)/bin/promu
pkgs = $(shell $(GO) list ./... | grep -v -E '/vendor/|/ui')

build: test
go build -ldflags "-X main.revision=$(shell git describe --tags --always --dirty=-dev)"
PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= alertmanager2es
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))

ifdef DEBUG
bindata_flags = -debug
endif


all: format build test

test:
go test $(go list ./... | grep -v /vendor/)
@echo ">> running tests"
@$(GO) test -race -short $(pkgs)

style:
@echo ">> checking code style"
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'

format:
@echo ">> formatting code"
@$(GO) fmt $(pkgs)

vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)

build: promu
@echo ">> building binaries"
@$(PROMU) build --prefix $(PREFIX)

tarball: promu
@echo ">> building release tarball"
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)

docker:
@echo ">> building docker image"
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .

assets:
@echo ">> writing assets"
-@$(GO) get -u github.com/jteeuwen/go-bindata/...

promu:
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
$(GO) get -u github.com/prometheus/promu

proto:


.PHONY: all style format build test vet assets tarball docker promu proto
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.2

0 comments on commit 8a757b2

Please sign in to comment.