This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from carlpett/promu
Add Promu+CircleCI and versioning
- Loading branch information
Showing
8 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
verbose: true | ||
go: | ||
version: 1.8 | ||
cgo: false | ||
repository: | ||
path: github.com/carlpett/stream_exporter | ||
build: | ||
flags: -a -tags netgo | ||
ldflags: | | ||
-s | ||
-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: | ||
prefix: . | ||
crossbuild: | ||
platforms: | ||
# Only build common platforms for now to keep build times short. Easy to add more on request. | ||
- linux/amd64 | ||
- windows/amd64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
GO := go | ||
FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH))) | ||
PROMU := $(FIRST_GOPATH)/bin/promu | ||
pkgs = $(shell $(GO) list ./... | grep -v /vendor/) | ||
|
||
PREFIX ?= $(shell pwd)/.build | ||
BIN_DIR ?= $(shell pwd) | ||
|
||
ifdef DEBUG | ||
bindata_flags = -debug | ||
endif | ||
|
||
all: format build | ||
|
||
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) | ||
|
||
test: | ||
@echo ">> testing code" | ||
@$(GO) test $(pkgs) | ||
|
||
build: promu | ||
@echo ">> building binaries" | ||
@$(PROMU) build --prefix $(PREFIX) | ||
|
||
tarball: promu | ||
@echo ">> building release tarball" | ||
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) | ||
|
||
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 vet tarball docker promu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
machine: | ||
environment: | ||
REPO_PATH: github.com/carlpett/stream_exporter | ||
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.8-base | ||
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: | ||
- make promu | ||
- docker info | ||
- git describe --always | sed -r 's/^v//' | tee VERSION | ||
override: | ||
- promu crossbuild | ||
- ln -s .build/linux-amd64/stream_exporter stream_exporter | ||
- | | ||
if [ -n "$CIRCLE_TAG" ]; then | ||
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG | ||
else | ||
make docker DOCKER_IMAGE_NAME=$DOCKER_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: carlpett | ||
hub_tag: | ||
tag: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ | ||
owner: carlpett | ||
commands: | ||
- promu crossbuild tarballs | ||
- promu checksum .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 | ||
#- | | ||
# if [[ "$CIRCLE_TAG" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then | ||
# docker tag "$DOCKER_IMAGE_NAME:$CIRCLE_TAG" "$DOCKER_IMAGE_NAME:latest" | ||
# fi | ||
#- docker push $DOCKER_IMAGE_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters