From 78cce004127be97f38696af3d789f331389ce15b Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 18 Jan 2016 22:31:56 +0100 Subject: [PATCH] Unification: Drone config, Makefile, structure and badges --- .drone.sec | 2 +- .drone.yml | 26 ++++++++++++++++------- Makefile | 32 ++++++++++++++++++++++++++++ README.md | 62 ++++++++++++++++++++++++++++++++++-------------------- main.go | 6 ++++++ 5 files changed, 96 insertions(+), 32 deletions(-) create mode 100644 Makefile diff --git a/.drone.sec b/.drone.sec index a37d9f4..4c29b57 100644 --- a/.drone.sec +++ b/.drone.sec @@ -1 +1 @@ -eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.I7UNh81HqRV7vD9XrlFPRj5OjqcA0Os9gr4HIvWexZ4pbAwW0jG-rS7j0_maMt-36TDnw8yq_QuYYq9krlgrYxOr8hDtD8HpUjvf4gTtBP8gFWlzk2iax7ZYBdt7WzqWLdnOgPO0UbTYsMqpmlvEkWPmWutThEQYUrgtRqL6Wg8C_7ZM9e4HIL-d8v3fEKThJxK4bosRruCULXXEFqy2l98PtkA7ZIuijDB8sHMpRPPhhNyJCfqH1Mq1qc5Lv7BXTnHMWB4o9vc__Mi6fPxKRPdf0UYXwR1aBbrRjHelWFgIIcELZyS_UE-06va6eUhV1VKYIxnhn9WCPCocvaOa3w._YYkhrS1UVH--LOy.70UCog1CF2x1ENWrW8KbeJ98zVPSDsvWW3jFFIpeIiLSMrie9yywx0MDygLZt8DqVyRe65VyUr2_ZLVVgp2PAA8tSB99CAT124zut-MFYfLrczIQompPPXeEOnnbao3zNGCoUBROZVthwDaYD1QRW8ALyV5AoTwz97rm7DaMG1BkzAUSMLcOIXrDsZ3t7kJfT-VLn3NAOQtau7eozG98AWXOHoUQyEKdFAJU6h4ZW7UvuW5Z2ZXwoOSLDEjby9H88bUyDtHqDGPx1tXuPruggbGFExMSTxzFvCJ3SfBtRk7rTdMTJljPeiKVmUGUeBqBUI3PwGcoaKwb22BH89-trNdrdzC3OuBrdtlaGG0eyq28fVVQ3Revdqv9cms9bgQ9RM1o9A.d1XqcZFGi6M3YOIV1osnCg \ No newline at end of file +eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.G6Nny2XGFBtLfgrL0cPtC35a5yZkANTXmCQNlV4d91wNW1FSZWdHhTC9uwn5OaGq8TaeSlg3SLdt02ypmx38WenTc1zFbSjElfVWm8nQJP689ggy5EL0vTIXczbzwKk3Y7KVFAH0g4Xi_Lr6SdJJTIZREACkKcVDWVod44e32bFF7iF-u9vhIQ0GpB76d-WFJgSzBlh4ojBrCA_un2ItjJ3rVPfJi00VbTkh8fiovOsiTWg1MhgcTDyh78tqlD-f9fdeP4W5a88-v7l6H45ttrmhfPFyT46Xju7uhtdLX5MwtqZ_augSelw8qkXmUVM_yNqBDA04HGJBSGxT8rKWKg.QuQsEmFZNiVkEwAJ.XuYkMZlmfeQRaHFpRCg0Y6Ynkj7bxHyPLQ1Okmnk-F7HGogeaS4zxrbc9GQK_EKe5mEaDE_NkS76tAABChSnsXONmTezeRakyatc00PZYykARf2dwodwENI9rrHqZFJqnC0l5moFQyC9iFICeLP9RVdQ9DZhc0t-GU2hCK_CglZ09Ag2eHtvi8x75483_x_ZtVkpF1vsMXOxUMCDO_wCVcWy6o-Fkx7gPBR6AR56qD-MRBGeNn975IQ3bV1fxRTYnvRC3tX6xslZoQ6M-lIZTWFTTvZkEWYe3FSwD2HYUbm7rI4iivoNsFzmsMl38SqSQ_s_MyLcju9CcJsVmXokixKk-TcVCoDDG62gUQWTXEG4jz2sMxfwU4H2Fgg7AlFh2_At3gSVr2GXdgMtB1TYr0e1KQIVW_3DbNtYi6_neHg.k_x3SoJ2TUSAx_awKAYQWw \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index 235abd6..0aeada9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,27 +1,37 @@ build: image: golang:1.5 environment: - - GO15VENDOREXPERIMENT=1 - - GOOS=linux - - GOARCH=amd64 - CGO_ENABLED=0 commands: - - go get - - go build - - go test + - make deps + - make vet + - make build + - make test publish: + coverage: + when: + branch: master docker: - username: drone + username: $$DOCKER_USER password: $$DOCKER_PASS email: $$DOCKER_EMAIL repo: plugins/drone-docker + tag: latest when: branch: master + docker: + username: $$DOCKER_USER + password: $$DOCKER_PASS + email: $$DOCKER_EMAIL + repo: plugins/drone-docker + tag: develop + when: + branch: develop plugin: name: Docker - desc: Build and Publish images to a Docker registry. + desc: Build and publish images to a Docker registry type: publish image: plugins/drone-docker labels: diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..aea4dd4 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +.PHONY: clean deps fmt vet test docker + +EXECUTABLE ?= drone-docker +IMAGE ?= plugins/$(EXECUTABLE) +CI_BUILD_NUMBER ?= 0 + +LDFLAGS = -X "main.buildDate=$(shell date -u '+%Y-%m-%d %H:%M:%S %Z')" +PACKAGES = $(shell go list ./... | grep -v /vendor/) + +clean: + go clean -i ./... + +deps: + go get -t ./... + +fmt: + go fmt $(PACKAGES) + +vet: + go vet $(PACKAGES) + +test: + @for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done; + +docker: + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-s -w $(LDFLAGS)' + docker build --rm -t $(IMAGE) . + +$(EXECUTABLE): $(wildcard *.go) + go build -ldflags '-s -w $(LDFLAGS)' + +build: $(EXECUTABLE) diff --git a/README.md b/README.md index ae19cdf..b7b6a46 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,57 @@ # drone-docker [![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-docker/status.svg)](http://beta.drone.io/drone-plugins/drone-docker) +[![Coverage Status](https://aircover.co/badges/drone-plugins/drone-docker/coverage.svg)](https://aircover.co/drone-plugins/drone-docker) [![](https://badge.imagelayers.io/plugins/drone-docker:latest.svg)](https://imagelayers.io/?images=plugins/drone-docker:latest 'Get your own badge on imagelayers.io') -Drone plugin for publishing Docker images +Drone plugin to build and publish images to a Docker registry ## Docker -Build the Docker container: +Build the container using `make`: -```sh -docker build --rm=true -t plugins/drone-docker . +``` +make deps docker ``` -Build and Publish a Docker container +### Example ```sh docker run -i --privileged -v $(pwd):/drone/src plugins/drone-docker <