Skip to content

Commit 8fe0ed1

Browse files
author
Laurie Clark-Michalek
committed
Use promu for releases
1 parent 8acfc1b commit 8fe0ed1

File tree

3 files changed

+140
-32
lines changed

3 files changed

+140
-32
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ exporter_exporter
22
*.pem
33
*.deb
44
dist
5+
.build
6+
.tarballs
7+
vendor

.promu.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
verbose: true
2+
go:
3+
version: 1.7
4+
cgo: false
5+
repository:
6+
path: github.com/QubitProducts/exporter_exporter
7+
build:
8+
prefix: .
9+
binaries:
10+
- name: exporter_exporter
11+
path: .
12+
flags: -a
13+
ldflags: |
14+
-s
15+
-X main.Version={{.Version}}
16+
-X main.Revision={{.Revision}}
17+
-X main.Branch={{.Branch}}
18+
-X main.BuildUser={{user}}@{{host}}
19+
-X main.BuildDate={{date "20060102-15:04:05"}}
20+
tarball:
21+
prefix: .
22+
files:
23+
- LICENSE
24+
- NOTICE
25+
- README.md
26+
- expexp.yaml
27+
- exporter_exporter.conf
28+
- exporter_exporter.defaults
29+
crossbuild:
30+
platforms:
31+
- linux/amd64
32+
- darwin/amd64
33+
- windows/amd64

Makefile

Lines changed: 104 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,114 @@
1-
TARGET=deb
2-
PACKAGE_NAME=expexp
3-
PACKAGE_VERSION=0.2.0
4-
PACKAGE_REVISION=2
5-
PACKAGE_ARCH=amd64
6-
PACKAGE_MAINTAINER[email protected]
7-
PACKAGE_FILE=$(PACKAGE_NAME)_$(PACKAGE_VERSION)-$(PACKAGE_REVISION)_$(PACKAGE_ARCH).$(TARGET)
1+
GITHUB_ORG = QubitProducts
2+
GITHUB_REPO = exporter_exporter
83

9-
GITREPO=https://github.com/QubitProducts/exporter_exporter.git
4+
SHELL := /usr/bin/env bash
5+
GO := GO15VENDOREXPERIMENT=1 go
6+
FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH)))
7+
PROMU := $(FIRST_GOPATH)/bin/promu
8+
PKGS = $(shell $(GO) list $(shell glide nv))
9+
FILES = $(shell find . -name '*.go' | grep -v vendor)
10+
PREFIX ?= $(shell pwd)
11+
BIN_DIR ?= $(shell pwd)
1012

11-
BINNAME=exporter_exporter
13+
PACKAGE_TARGET = deb
14+
PACKAGE_NAME = expexp
15+
PACKAGE_VERSION = $(shell cat VERSION)
16+
PACKAGE_REVISION = 3
17+
PACKAGE_ARCH = amd64
18+
PACKAGE_MAINTAINER = [email protected]
19+
PACKAGE_FILE = $(PACKAGE_NAME)_$(PACKAGE_VERSION)-$(PACKAGE_REVISION)_$(PACKAGE_ARCH).$(PACKAGE_TARGET)
20+
BINNAME = exporter_exporter
1221

13-
PWD=$(shell pwd)
22+
PWD := $(shell pwd)
23+
24+
# V := 1 # When V is set, print commands and build progress.
25+
Q := $(if $V,,@)
1426

1527
all: package
28+
clean:
29+
$Q rm -f $(PACKAGE_FILE)
30+
$Q rm -rf dist
31+
$Q rm -rf build
32+
33+
.PHONY: test
34+
test:
35+
$Q echo ">> running short tests"
36+
$Q $(GO) test -short $(pkgs)
37+
38+
.PHONY: test-static
39+
test-static:
40+
$Q echo ">> running static tests"
41+
$Q $(GO) vet $(pkgs)
42+
$Q [[ "$(shell gofmt -l $(files))" == "" ]] || (echo "gofmt check failed"; exit 1)
43+
44+
.PHONY: format
45+
format:
46+
$Q echo ">> formatting code"
47+
$Q $(GO) fmt $(pkgs)
48+
49+
.PHONY: vet
50+
vet:
51+
$Q echo ">> vetting code"
52+
$Q $(GO) vet $(pkgs)
53+
54+
.PHONY: build
55+
build: promu
56+
$Q echo ">> building binaries"
57+
$Q $(PROMU) build --prefix $(PREFIX)
58+
59+
.PHONY: tarball
60+
tarball: promu
61+
$Q echo ">> building release tarball"
62+
$Q $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
1663

17-
binary: clean-binary
18-
go build .
19-
mkdir -p dist/usr/local/bin
20-
mkdir -p dist/etc/init
21-
mkdir -p dist/etc/default
22-
mkdir -p dist/etc/exporter_exporter.d/
23-
install -m755 $(BINNAME) dist//usr/local/bin/$(BINNAME)
24-
install -m644 $(BINNAME).conf dist/etc/init/$(BINNAME).conf
25-
install -m644 $(BINNAME).defaults dist/etc/default/$(BINNAME)
26-
install -m644 expexp.yaml dist/etc/exporter_exporter.yaml
27-
touch dist/etc/exporter_exporter.d/.dir
28-
clean-binary:
29-
rm -f dist/usr/local/bin/$(BINNAME)
30-
31-
package: clean binary
32-
cd dist && \
64+
.PHONY: promu
65+
promu:
66+
$Q echo ">> fetching promu"
67+
$Q GOOS=$(shell uname -s | tr A-Z a-z) \
68+
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
69+
$(GO) get -u github.com/prometheus/promu
70+
71+
.PHONY: github-release
72+
github-release:
73+
$Q echo ">> fetching github-release"
74+
$Q GOOS=$(shell uname -s | tr A-Z a-z) \
75+
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
76+
$(GO) get -u github.com/aktau/github-release
77+
78+
.PHONY: release
79+
release: promu github-release package
80+
$Q echo ">> crossbuilding binaries"
81+
$Q promu crossbuild
82+
$Q echo ">> crossbuilding tarballs"
83+
$Q promu crossbuild tarballs
84+
$Q echo ">> creating github release"
85+
$Q github-release release -u $(GITHUB_ORG) -r $(GITHUB_REPO) --tag v$(VERSION) --name v$(VERSION)
86+
$Q echo ">> uploading artifacts"
87+
$Q promu release .tarballs
88+
$Q echo ">> uploading deb"
89+
$Q github-release upload -u $(GITHUB_ORG) -r $(GITHUB_REPO) --tag v$(VERSION) --name $(PACKAGE_FILE) --file $(PACKAGE_FILE)
90+
91+
.PHONY: prepare-package clean-package package
92+
prepare-package: clean-package
93+
$Q echo ">> crossbuilding binaries"
94+
$Q promu crossbuild -p linux/amd64
95+
$Q mkdir -p dist/usr/local/bin
96+
$Q mkdir -p dist/etc/init
97+
$Q mkdir -p dist/etc/default
98+
$Q mkdir -p dist/etc/exporter_exporter.d/
99+
$Q install -m755 .build/linux-amd64/$(BINNAME) dist/usr/local/bin/$(BINNAME)
100+
$Q install -m644 $(BINNAME).conf dist/etc/init/$(BINNAME).conf
101+
$Q install -m644 $(BINNAME).defaults dist/etc/default/$(BINNAME)
102+
$Q install -m644 expexp.yaml dist/etc/exporter_exporter.yaml
103+
$Q touch dist/etc/exporter_exporter.d/.dir
104+
105+
clean-package:
106+
$Q rm -rf dist
107+
108+
package: prepare-package
109+
$Q cd dist && \
33110
fpm \
34-
-t $(TARGET) \
111+
-t $(PACKAGE_TARGET) \
35112
-m $(PACKAGE_MAINTAINER) \
36113
-n $(PACKAGE_NAME) \
37114
-a $(PACKAGE_ARCH) \
@@ -41,8 +118,3 @@ package: clean binary
41118
-p ../$(PACKAGE_FILE) \
42119
.
43120

44-
45-
clean:
46-
rm -f $(PACKAGE_FILE)
47-
rm -rf dist
48-
rm -rf build

0 commit comments

Comments
 (0)