Use promu/docker/circleci based release process

This commit is contained in:
Johannes 'fish' Ziemke 2016-01-24 23:38:06 +01:00
parent e26a5e4728
commit cdeb0c9743
9 changed files with 154 additions and 9 deletions

4
.dockerignore Normal file
View file

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

8
.gitignore vendored
View file

@ -1,4 +1,6 @@
.build/
dependencies-stamp
*.tar.gz
statsd_exporter
/statsd_exporter
/.build
/.deps
/.release
/.tarballs

12
.promu.yml Normal file
View file

@ -0,0 +1,12 @@
go: 1.6.2
repository:
path: github.com/prometheus/statsd_exporter
build:
flags: -a -tags 'netgo static_build'
ldflags: |
-X main.Version={{.Version}}
tarball:
files:
- LICENSE
- NOTICE

10
.travis.yml Normal file
View file

@ -0,0 +1,10 @@
sudo: false
language: go
go:
- 1.6.2
- 1.5.4
- tip
script:
- make

View file

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

View file

@ -11,7 +11,50 @@
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION := 0.2.0
TARGET := statsd_exporter
GO := GO15VENDOREXPERIMENT=1 go
PROMU := $(GOPATH)/bin/promu
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
include Makefile.COMMON
PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= statsd-exporter
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
all: format build test
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

View file

@ -1,5 +1,8 @@
statsd_exporter
=============
# statsd exporter [![Build Status](https://travis-ci.org/prometheus/statsd_exporter.svg)][travis]
[![CircleCI](https://circleci.com/gh/prometheus/statsd_exporter/tree/master.svg?style=shield)][circleci]
[![Docker Repository on Quay](https://quay.io/repository/prometheus/statsd-exporter/status)][quay]
[![Docker Pulls](https://img.shields.io/docker/pulls/prom/statsd-exporter.svg)][hub]
`statsd_exporter` receives StatsD-style metrics and exports them as Prometheus metrics.
@ -123,3 +126,9 @@ docker run -d -p 9102:9102 -p 9125:9125/udp \
-v $PWD/statsd_mapping.conf:/tmp/statsd_mapping.conf \
prom/statsd-exporter -statsd.mapping-config=/tmp/statsd_mapping.conf
```
[travis]: https://travis-ci.org/prometheus/statsd_exporter
[circleci]: https://circleci.com/gh/prometheus/statsd_exporter
[quay]: https://quay.io/repository/prometheus/statsd-exporter
[hub]: https://hub.docker.com/r/prom/statsd-exporter/

1
VERSION Normal file
View file

@ -0,0 +1 @@
0.2.0

61
circle.yml Normal file
View file

@ -0,0 +1,61 @@
machine:
environment:
DOCKER_IMAGE_NAME: prom/statsd-exporter
QUAY_IMAGE_NAME: quay.io/prometheus/statsd-exporter
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.5.4-main
REPO_PATH: github.com/prometheus/statsd_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/statsd_exporter statsd_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