From 50c0f3693f8b057e2abc93490085be532f311a65 Mon Sep 17 00:00:00 2001
From: Richard Mitchell <richard.j.mitchell@gmail.com>
Date: Tue, 19 Mar 2019 22:10:49 +0000
Subject: [PATCH] Fix build process and cut new version

---
 .promu.yml                   | 14 ++++++++----
 CHANGELOG.md                 |  6 ++++++
 Dockerfile.amd64             |  2 +-
 Dockerfile.arm7              |  2 +-
 Dockerfile.build.amd64.glibc |  8 -------
 Dockerfile.build.amd64.musl  |  8 -------
 Dockerfile.build.arm7.glibc  |  8 -------
 Dockerfile.build.arm7.musl   | 10 ---------
 Makefile                     | 41 ++++++++++++------------------------
 VERSION                      |  2 +-
 10 files changed, 33 insertions(+), 68 deletions(-)
 delete mode 100644 Dockerfile.build.amd64.glibc
 delete mode 100644 Dockerfile.build.amd64.musl
 delete mode 100644 Dockerfile.build.arm7.glibc
 delete mode 100644 Dockerfile.build.arm7.musl

diff --git a/.promu.yml b/.promu.yml
index 472edff..0d89d47 100644
--- a/.promu.yml
+++ b/.promu.yml
@@ -1,9 +1,14 @@
+go:
+    version: 1.12.0
+    cgo: false
 repository:
     path: github.com/mitchellrj/hue_exporter
 build:
     flags: -a -tags 'netgo static_build'
     ldflags: |
         -s
+        -w
+        -extldflags "-static"
         -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}}
@@ -14,7 +19,8 @@ tarball:
         - LICENSE
 crossbuild:
   platforms:
-      - linux/amd64
-      - darwin/amd64
-      - linux/arm
-      - linux/arm64
\ No newline at end of file
+    - darwin/amd64
+    - linux/amd64
+    - linux/armv6
+    - linux/armv7
+    - linux/arm64
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 10b837b..78eb8de 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# v0.2.2 (2019-03-19)
+
+* Add counter metric for bridge restarts
+* Fix build info metrics for dockerized builds
+* Fix crossbuilds
+
 # v0.2.1 (2018-08-11)
 
 Use musl builds for alpine images.
diff --git a/Dockerfile.amd64 b/Dockerfile.amd64
index 019f2a5..6dc13a4 100644
--- a/Dockerfile.amd64
+++ b/Dockerfile.amd64
@@ -1,7 +1,7 @@
 FROM        alpine:latest
 MAINTAINER  Richard Mitchell <hue-exporter@mitch.org.uk>
 
-COPY ./build/hue_exporter.amd64.musl /bin/hue_exporter
+COPY ./.build/linux-amd64/hue_exporter /bin/hue_exporter
 COPY hue_exporter.example.yml   /etc/hue_exporter/config.yml
 
 EXPOSE      9366
diff --git a/Dockerfile.arm7 b/Dockerfile.arm7
index e7379c8..d635406 100644
--- a/Dockerfile.arm7
+++ b/Dockerfile.arm7
@@ -1,7 +1,7 @@
 FROM        armhf/alpine:latest
 MAINTAINER  Richard Mitchell <hue-exporter@mitch.org.uk>
 
-COPY ./build/hue_exporter.arm7.musl /bin/hue_exporter
+COPY ./.build/linux-armv7/hue_exporter /bin/hue_exporter
 COPY hue_exporter.example.yml   /etc/hue_exporter/config.yml
 
 EXPOSE      9366
diff --git a/Dockerfile.build.amd64.glibc b/Dockerfile.build.amd64.glibc
deleted file mode 100644
index 8b053c4..0000000
--- a/Dockerfile.build.amd64.glibc
+++ /dev/null
@@ -1,8 +0,0 @@
-FROM amd64/golang:stretch
-
-RUN go get -u github.com/prometheus/promu
-COPY . /go/src/github.com/mitchellrj/hue_exporter
-WORKDIR /go/src/github.com/mitchellrj/hue_exporter
-
-VOLUME /build
-CMD promu build && mv hue_exporter /build/hue_exporter.amd64
diff --git a/Dockerfile.build.amd64.musl b/Dockerfile.build.amd64.musl
deleted file mode 100644
index 924a2cb..0000000
--- a/Dockerfile.build.amd64.musl
+++ /dev/null
@@ -1,8 +0,0 @@
-FROM amd64/golang:alpine
-
-RUN go get -u github.com/prometheus/promu
-COPY . /go/src/github.com/mitchellrj/hue_exporter
-WORKDIR /go/src/github.com/mitchellrj/hue_exporter
-
-VOLUME /build
-CMD promu build && mv hue_exporter /build/hue_exporter.amd64.musl
diff --git a/Dockerfile.build.arm7.glibc b/Dockerfile.build.arm7.glibc
deleted file mode 100644
index 15f7f47..0000000
--- a/Dockerfile.build.arm7.glibc
+++ /dev/null
@@ -1,8 +0,0 @@
-FROM arm32v7/golang:stretch
-
-RUN go get -u github.com/prometheus/promu
-COPY . /go/src/github.com/mitchellrj/hue_exporter
-WORKDIR /go/src/github.com/mitchellrj/hue_exporter
-
-VOLUME /build
-CMD promu build && mv hue_exporter /build/hue_exporter.arm7
diff --git a/Dockerfile.build.arm7.musl b/Dockerfile.build.arm7.musl
deleted file mode 100644
index 13c47a5..0000000
--- a/Dockerfile.build.arm7.musl
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM armhf/alpine:latest
-
-RUN apk add --no-cache git go musl-dev && mkdir /go
-ENV GOPATH=/go
-RUN go get -u github.com/prometheus/promu
-COPY . /go/src/github.com/mitchellrj/hue_exporter
-WORKDIR /go/src/github.com/mitchellrj/hue_exporter
-
-VOLUME /build
-CMD promu build && mv hue_exporter /build/hue_exporter.arm7.musl
diff --git a/Makefile b/Makefile
index 8fcbbfa..2bf894a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,6 @@
+PREFIX                  ?= $(shell pwd)
+VERSION                 ?= $(shell cat VERSION)
+
 all: style staticcheck build test
 
 style:
@@ -19,40 +22,24 @@ promu:
 	GOOS= GOARCH= go get -u github.com/prometheus/promu
 
 build: promu
-	promu build
-
-dist: darwin amd64 arm7 amd64-musl arm7-musl docker
-
-darwin: build
-	cp hue_exporter build/hue_exporter.darwin
-
-amd64:
-	docker build --pull -f Dockerfile.build.amd64.glibc -t hue_exporter_builder:latest .
-	docker run -v $$(pwd)/build:/build hue_exporter_builder:latest
+	promu build hue_exporter --prefix $(PREFIX)
 
-arm7:
-	docker build --pull -f Dockerfile.build.arm7.glibc -t hue_exporter_builder:latest-arm .
-	docker run -v $$(pwd)/build:/build hue_exporter_builder:latest-arm
+crossbuild:
+	promu crossbuild hue_exporter
 
-amd64-musl:
-	docker build --pull -f Dockerfile.build.amd64.musl -t hue_exporter_builder:latest-musl .
-	docker run -v $$(pwd)/build:/build hue_exporter_builder:latest-musl
-
-arm7-musl:
-	docker build --pull -f Dockerfile.build.arm7.musl -t hue_exporter_builder:latest-arm-musl .
-	docker run -v $$(pwd)/build:/build hue_exporter_builder:latest-arm-musl
-
-docker:
+docker: crossbuild
 	docker build --pull -f Dockerfile.amd64 -t mitchellrj/hue_exporter:latest .
-	docker tag mitchellrj/hue_exporter:latest mitchellrj/hue_exporter:$$(build/hue_exporter.darwin -V)
+	docker tag mitchellrj/hue_exporter:latest mitchellrj/hue_exporter:$(VERSION)
 	docker build --pull -f Dockerfile.arm7 -t mitchellrj/hue_exporter:latest-arm7 .
-	docker tag mitchellrj/hue_exporter:latest mitchellrj/hue_exporter:$$(build/hue_exporter.darwin -V)-arm7
+	docker tag mitchellrj/hue_exporter:latest mitchellrj/hue_exporter:$(VERSION)-arm7
+
+dist: docker
 
 push:
 	docker push mitchellrj/hue_exporter:latest
-	docker push mitchellrj/hue_exporter:$$(build/hue_exporter.darwin -V)
+	docker push mitchellrj/hue_exporter:$(VERSION)
 	docker push mitchellrj/hue_exporter:latest-arm7
-	docker push mitchellrj/hue_exporter:$$(build/hue_exporter.darwin -V)-arm7
+	docker push mitchellrj/hue_exporter:$(VERSION)-arm7
 
 DEFAULT: all
-.PHONY: all style test format vet staticcheck promu build
+.PHONY: all style test format vet staticcheck promu build crossbuild dist docker push
diff --git a/VERSION b/VERSION
index 7dff5b8..f477849 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.2.1
\ No newline at end of file
+0.2.2
\ No newline at end of file
-- 
GitLab