New release process using docker, circleci and a centralized

building tool
pull/221/head
Steve Durrheimer 9 years ago
parent 7c97b784d6
commit 158200fd49
No known key found for this signature in database
GPG Key ID: 5435BD02508176B7

@ -0,0 +1,4 @@
.build/
.tarballs/
!.build/linux-amd64

9
.gitignore vendored

@ -21,7 +21,8 @@ _testmain.go
*.exe *.exe
dependencies-stamp dependencies-stamp
node_exporter /node_exporter
.build /.build
.deps /.deps
*.tar.gz /.release
/.tarballs

@ -0,0 +1,27 @@
go: 1.5.4
repository:
path: github.com/prometheus/node_exporter
build:
ldflags: |
-X main.Version={{.Version}}
-X {{repoPath}}/collector.Version={{.Version}}
-X {{repoPath}}/collector.Revision={{.Revision}}
-X {{repoPath}}/collector.Branch={{.Branch}}
tarball:
files:
- LICENSE
- NOTICE
crossbuild:
platforms:
- linux/amd64
- linux/386
- darwin/amd64
- darwin/386
- windows/amd64
- windows/386
- netbsd/amd64
- netbsd/386
- linux/arm
- linux/arm64
- netbsd/arm
- linux/ppc64le

@ -2,15 +2,9 @@ sudo: false
language: go language: go
go: go:
- 1.5.3 - 1.5
- tip - tip
env:
- GO15VENDOREXPERIMENT=1
script: script:
- "! gofmt -l $(find . -path ./vendor -prune -o -name '*.go' -print) | read nothing" - make
- go vet
- go test -v $(go list ./... | grep -v /vendor/)
- go build
- ./end-to-end-test.sh - ./end-to-end-test.sh

@ -1,4 +1,7 @@
FROM sdurrheimer/alpine-golang-make-onbuild FROM quay.io/prometheus/busybox:glibc
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com> MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>
COPY node_exporter /bin/node_exporter
EXPOSE 9100 EXPOSE 9100
ENTRYPOINT [ "/bin/node_exporter" ]

@ -11,18 +11,50 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
VERSION := 0.12.0rc3 GO := GO15VENDOREXPERIMENT=1 go
TARGET := node_exporter PROMU := $(GOPATH)/bin/promu
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
REVISION := $(shell git rev-parse --short HEAD 2> /dev/null || echo 'unknown') PREFIX ?= $(shell pwd)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown') BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= node-exporter
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
REPO_PATH := "github.com/prometheus/node_exporter"
LDFLAGS := -X main.Version=$(VERSION)
LDFLAGS += -X $(REPO_PATH)/collector.Version=$(VERSION)
LDFLAGS += -X $(REPO_PATH)/collector.Revision=$(REVISION)
LDFLAGS += -X $(REPO_PATH)/collector.Branch=$(BRANCH)
GOFLAGS := -ldflags "$(LDFLAGS)" all: format build test
include Makefile.COMMON style:
@echo ">> checking code style"
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
test:
@echo ">> running tests"
@$(GO) test -short $(pkgs)
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)" .
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
.PHONY: all style format build test vet tarball docker promu

@ -1,6 +1,9 @@
# Node exporter # Node exporter [![Build Status](https://travis-ci.org/prometheus/node_exporter.svg)][travis]
[![Build Status](https://travis-ci.org/prometheus/node_exporter.svg)](https://travis-ci.org/prometheus/node_exporter) [![CircleCI](https://circleci.com/gh/prometheus/node_exporter/tree/master.svg?style=shield)][circleci]
[![Image Size & Layers](https://imagelayers.io/badge/prom/node-exporter:master.svg)][imagelayers]
[![Docker Stars](https://img.shields.io/docker/stars/prom/node-exporter.svg)][hub]
[![Docker Pulls](https://img.shields.io/docker/pulls/prom/node-exporter.svg)][hub]
Prometheus exporter for machine metrics, written in Go with pluggable metric Prometheus exporter for machine metrics, written in Go with pluggable metric
collectors. collectors.
@ -99,3 +102,9 @@ docker pull prom/node-exporter
docker run -d -p 9100:9100 --net="host" prom/node-exporter docker run -d -p 9100:9100 --net="host" prom/node-exporter
``` ```
[travis]: https://travis-ci.org/prometheus/node_exporter
[hub]: https://hub.docker.com/r/prom/node-exporter/
[circleci]: https://circleci.com/gh/prometheus/node_exporter
[imagelayers]: https://imagelayers.io/?images=prom/node-exporter:master

@ -0,0 +1 @@
0.12.0rc3

@ -0,0 +1,61 @@
machine:
environment:
DOCKER_IMAGE_NAME: prom/node-exporter
QUAY_IMAGE_NAME: quay.io/prometheus/node-exporter
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.5.4-main
REPO_PATH: github.com/prometheus/node_exporter
pre:
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci'
- sudo chmod 0755 /usr/bin/docker
- sudo curl -L 'https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2' | tar xvjf - --strip-components 3 -C $HOME/bin
services:
- docker
dependencies:
pre:
- go get -u github.com/prometheus/promu
- docker info
override:
- promu crossbuild
- ln -s .build/linux-amd64/node_exporter node_exporter
- |
if [ -n "$CIRCLE_TAG" ]; then
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG
make docker DOCKER_IMAGE_NAME=$QUAY_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG
else
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME
make docker DOCKER_IMAGE_NAME=$QUAY_IMAGE_NAME
fi
post:
- mkdir $CIRCLE_ARTIFACTS/binaries/ && cp -a .build/* $CIRCLE_ARTIFACTS/binaries/
- docker images
test:
override:
- docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T
deployment:
hub_branch:
branch: master
owner: prometheus
commands:
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- docker login -e $QUAY_EMAIL -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io
- docker push $DOCKER_IMAGE_NAME
- docker push $QUAY_IMAGE_NAME
hub_tag:
tag: /^[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
owner: prometheus
commands:
- promu crossbuild tarballs
- promu release .tarballs
- mkdir $CIRCLE_ARTIFACTS/releases/ && cp -a .tarballs/* $CIRCLE_ARTIFACTS/releases/
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- docker login -e $QUAY_EMAIL -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io
- |
if [[ "$CIRCLE_TAG" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then
docker tag "$DOCKER_IMAGE_NAME:$CIRCLE_TAG" "$DOCKER_IMAGE_NAME:latest"
docker tag "$QUAY_IMAGE_NAME:$CIRCLE_TAG" "$QUAY_IMAGE_NAME:latest"
fi
- docker push $DOCKER_IMAGE_NAME
- docker push $QUAY_IMAGE_NAME
Loading…
Cancel
Save