From 3930ec495ca49cb5b58cc0955579b7a5d7673307 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2019 19:45:16 -0700 Subject: [PATCH 01/11] Pass in build env from file. --- .gitignore | 1 + .metadata.sh | 34 ++++++++++++++++++++++++++++++++++ Makefile | 32 ++++++++++---------------------- init/docker/Dockerfile | 22 ++++++++++++++-------- init/docker/hooks/build | 11 +++++++---- init/docker/hooks/push | 4 ++-- scripts/formula-deploy.sh | 15 ++++++++------- 7 files changed, 76 insertions(+), 43 deletions(-) create mode 100755 .metadata.sh diff --git a/.gitignore b/.gitignore index 53ba083f..aec6680f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ README README.html /unifi-poller_manual.html /homebrew-mugs +/.metadata.make diff --git a/.metadata.sh b/.metadata.sh new file mode 100755 index 00000000..c18d6db6 --- /dev/null +++ b/.metadata.sh @@ -0,0 +1,34 @@ +# Each line must have an export clause. +# This file is parsed and sourced by the Makefile, Docker and Homebrew builds. + +# github username +GHUSER="davidnewhall" +# docker hub username +DHUSER="golift" +MAINT="David Newhall II " +VENDOR="Go Lift" +DESC="Polls a UniFi controller and stores metrics in InfluxDB" +GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals" +CONFIG_FILE="up.conf" +LICENSE="MIT" + +# The rest if mostly automatic. + +BINARY="$(basename $(pwd))" +GHREPO="${GHUSER}/${BINARY}" +URL="https://github.com/${GHREPO}" + +# This parameter is passed in as -X to go build. Used to override the Version variable in a package. +# This makes a path like github.com/davidnewhall/unifi-poller/unifipoller.Version=1.3.3 +# Name the Version-containing library the same as the github repo, without dashes. +VERSION_PATH="github.com/${GHUSER}/${BINARY}/$(echo ${BINARY} | tr -d -- -).Version" + +# Dynamic. Recommend not changing. +VERSION="$(git tag -l --merged | tail -n1 | tr -d v || echo development)" +# This produces a 0 in some envirnoments (like Homebrew), but it's only used for packages. +ITERATION=$(git rev-list --count --all || echo 0) +DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" +COMMIT="$(git rev-parse --short HEAD || echo 0)" + +export GHUSER DHUSER MAINT DESC CONFIG_FILE LICENSE GOLANGCI_LINT_ARGS +export BINARY GHREPO URL VERSION_PATH VERSION ITERATION DATE COMMIT diff --git a/Makefile b/Makefile index 77f25848..4a6ed5f6 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,27 @@ # This Makefile is written as generic as possible. # Setting these variables and creating the necesarry paths in your GitHub repo will make this file work. # -# github username -GHUSER=davidnewhall -# docker hub username -DHUSER=golift -MAINT=David Newhall II -DESC=Polls a UniFi controller and stores metrics in InfluxDB -GOLANGCI_LINT_ARGS=--enable-all -D gochecknoglobals -BINARY:=$(shell basename $(shell pwd)) -URL:=https://github.com/$(GHUSER)/$(BINARY) -CONFIG_FILE=up.conf -# This parameter is passed in as -X to go build. Used to override the Version variable in a package. -# This makes a path like github.com/davidnewhall/unifi-poller/unifipoller.Version=1.3.3 -# Name the Version-containing library the same as the github repo, without dashes. -VERSION_PATH:=github.com/$(GHUSER)/$(BINARY)/$(shell echo $(BINARY) | tr -d -- -).Version +IGNORE := $(shell bash -c "source .metadata.sh ; env | sed 's/=/:=/;s/^/export /' > .metadata.make") # These don't generally need to be changed. # md2roff turns markdown into man files and html files. MD2ROFF_BIN=github.com/github/hub/md2roff-bin -# This produces a 0 in some envirnoments (like Homebrew), but it's only used for packages. -ITERATION:=$(shell git rev-list --count --all || echo 0) # Travis CI passes the version in. Local builds get it from the current git tag. ifeq ($(VERSION),) - VERSION:=$(shell git tag -l --merged | tail -n1 | tr -d v || echo development) -endif -ifeq ($(VERSION),) - VERSION:=development + include .metadata.make +else + # Preserve the passed-in version & iteration (homebrew). + _VERSION:=$(VERSION) + _ITERATION:=$(ITERATION) + include .metadata.make + VERSION:=$(_VERSION) + ITERATION:=$(_ITERATION) endif + # rpm is wierd and changes - to _ in versions. RPMVERSION:=$(shell echo $(VERSION) | tr -- - _) -DATE:=$(shell date -u +%Y-%m-%dT%H:%M:%SZ) -COMMIT:=$(shell git rev-parse --short HEAD || echo 0) # Makefile targets follow. diff --git a/init/docker/Dockerfile b/init/docker/Dockerfile index 7bc72b1e..dc00d8b4 100644 --- a/init/docker/Dockerfile +++ b/init/docker/Dockerfile @@ -38,19 +38,25 @@ ARG OS ARG BUILD_DATE ARG COMMIT ARG VERSION +ARG LICENSE=MIT +ARG TITLE=unifi-poller +ARG URL=http://github.com/davidnewhall/unifi-poller +ARG DESC=unifi-poller +ARG VENDOR=golift +ARG AUTHOR=golift # Build-time metadata as defined at https://github.com/opencontainers/image-spec/blob/master/annotations.md LABEL org.opencontainers.image.created="${BUILD_DATE}" \ - org.opencontainers.image.title="UniFi Poller" \ - org.opencontainers.image.documentation="https://github.com/davidnewhall/unifi-poller/wiki/Docker" \ - org.opencontainers.image.description="Polls a UniFi controller and stores metrics in InfluxDB" \ - org.opencontainers.image.url="https://github.com/davidnewhall/unifi-poller" \ + org.opencontainers.image.title="${TITLE}" \ + org.opencontainers.image.documentation="${URL}/wiki/Docker" \ + org.opencontainers.image.description="${DESC}" \ + org.opencontainers.image.url="${URL}" \ org.opencontainers.image.revision="${COMMIT}" \ - org.opencontainers.image.source="https://github.com/davidnewhall/unifi-poller" \ - org.opencontainers.image.vendor="Go Lift" \ - org.opencontainers.image.authors="David Newhall II " \ + org.opencontainers.image.source="${URL}" \ + org.opencontainers.image.vendor="${VENDOR}" \ + org.opencontainers.image.authors="${AUTHOR}" \ org.opencontainers.image.architecture="${OS} ${ARCH}" \ - org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.licenses="${LICENSE}" \ org.opencontainers.image.version="${VERSION}" COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller.${ARCH}.${OS} /unifi-poller diff --git a/init/docker/hooks/build b/init/docker/hooks/build index 8e15743b..25d0c098 100755 --- a/init/docker/hooks/build +++ b/init/docker/hooks/build @@ -7,10 +7,7 @@ set -e -o pipefail # The Docker Cloud config must pass in the BUILDS env variable. # See README.md (in this dir) and the screenshot for more info. -VERSION=$(git tag -l --merged | tail -n1 | tr -d v) # 1.2.3 -DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) -COMMIT=$(git rev-parse --short HEAD) -ITERATION=$(git rev-list --count --all) +source ../../.metadata.sh # Build each configured image from Docker Cloud. for build in $BUILDS; do @@ -23,6 +20,12 @@ for build in $BUILDS; do --build-arg "BUILD_DATE=${DATE}" \ --build-arg "COMMIT=${COMMIT}" \ --build-arg "VERSION=${VERSION}-${ITERATION}" \ + --build-arg "LICENSE=${LICENSE}" \ + --build-arg "TITLE=${TITLE}" \ + --build-arg "DESC=${DESC}" \ + --build-arg "URL=${URL}" \ + --build-arg "VENDOR=${VENDOR}" \ + --build-arg "AUTHOR=${AUTHOR}" \ --tag "${IMAGE_NAME}_${os}_${name}" \ --file Dockerfile ../.. done diff --git a/init/docker/hooks/push b/init/docker/hooks/push index e030ad4d..c71e906c 100755 --- a/init/docker/hooks/push +++ b/init/docker/hooks/push @@ -4,8 +4,8 @@ # It's all a bit complicated for some reason. set -e -o pipefail -VERSION=$(git tag -l --merged | tail -n1 | tr -d v) # 1.2.3 -SHORTVER=$(echo $VERSION | cut -d. -f1,2) # 1.2 +source ../../.metadata.sh + if [ "$BUILDS" != "" ]; then TAGS=$DOCKER_TAG fi diff --git a/scripts/formula-deploy.sh b/scripts/formula-deploy.sh index 9bbe1c06..978b4507 100755 --- a/scripts/formula-deploy.sh +++ b/scripts/formula-deploy.sh @@ -3,26 +3,27 @@ # Deploys a new homebrew formula file to golift/homebrew-tap. # Requires SSH credentials in ssh-agent to work. # Run by Travis-CI when a new release is created on GitHub. -APP=unpacker-poller + +source ../.metadata.sh if [ -z "$VERSION" ]; then VERSION=$TRAVIS_TAG fi VERSION=$(echo $VERSION|tr -d v) -make ${APP}.rb VERSION=$VERSION +make ${BINARY}.rb VERSION=$VERSION if [ -z "$VERSION" ]; then - VERSION=$(grep -E '^\s+url\s+"' ${APP}.rb | cut -d/ -f7 | cut -d. -f1,2,3) + VERSION=$(grep -E '^\s+url\s+"' ${BINARY}.rb | cut -d/ -f7 | cut -d. -f1,2,3) fi rm -rf homebrew-mugs -git config --global user.email "${APP}@auto.releaser" -git config --global user.name "${APP}-auto-releaser" +git config --global user.email "${BINARY}@auto.releaser" +git config --global user.name "${BINARY}-auto-releaser" git clone git@github.com:golift/homebrew-mugs.git -cp ${APP}.rb homebrew-mugs/Formula +cp ${BINARY}.rb homebrew-mugs/Formula pushd homebrew-mugs -git commit -m "Update ${APP} on Release: ${VERSION}" Formula/${APP}.rb +git commit -m "Update ${BINARY} on Release: ${VERSION}" Formula/${BINARY}.rb git push popd From d6d237996e3fb5745a658a896660af1076d06d94 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2019 20:02:19 -0700 Subject: [PATCH 02/11] no git depth limit --- .travis.yml | 2 ++ scripts/formula-deploy.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da2fea15..48f30a81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: go +git: + depth: false addons: apt: packages: diff --git a/scripts/formula-deploy.sh b/scripts/formula-deploy.sh index 978b4507..0b5affae 100755 --- a/scripts/formula-deploy.sh +++ b/scripts/formula-deploy.sh @@ -24,6 +24,6 @@ git clone git@github.com:golift/homebrew-mugs.git cp ${BINARY}.rb homebrew-mugs/Formula pushd homebrew-mugs -git commit -m "Update ${BINARY} on Release: ${VERSION}" Formula/${BINARY}.rb +git commit -m "Update ${BINARY} on Release: ${VERSION}-${ITERATION}" Formula/${BINARY}.rb git push popd From 69b48d542717e7eeaf3e308ef14c74ba9280f46f Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2019 20:17:00 -0700 Subject: [PATCH 03/11] pass in more --- .metadata.sh | 4 ++-- Makefile | 22 ++++++++++++++-------- init/docker/hooks/build | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.metadata.sh b/.metadata.sh index c18d6db6..87aa673e 100755 --- a/.metadata.sh +++ b/.metadata.sh @@ -1,6 +1,6 @@ # Each line must have an export clause. # This file is parsed and sourced by the Makefile, Docker and Homebrew builds. - +TITLE="UniFi Poller" # github username GHUSER="davidnewhall" # docker hub username @@ -30,5 +30,5 @@ ITERATION=$(git rev-list --count --all || echo 0) DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" COMMIT="$(git rev-parse --short HEAD || echo 0)" -export GHUSER DHUSER MAINT DESC CONFIG_FILE LICENSE GOLANGCI_LINT_ARGS +export TITLE GHUSER DHUSER MAINT VENDOR DESC CONFIG_FILE LICENSE GOLANGCI_LINT_ARGS export BINARY GHREPO URL VERSION_PATH VERSION ITERATION DATE COMMIT diff --git a/Makefile b/Makefile index 4a6ed5f6..2cb69819 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm: package_build_linux check_fpm --iteration $(ITERATION) \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - --license MIT \ + --license $(LICENSE) \ --url $(URL) \ --maintainer "$(MAINT)" \ --description "$(DESC)" \ @@ -137,7 +137,7 @@ $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb: package_build_linux check_fpm --iteration $(ITERATION) \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - --license MIT \ + --license $(LICENSE) \ --url $(URL) \ --maintainer "$(MAINT)" \ --description "$(DESC)" \ @@ -155,7 +155,7 @@ $(BINARY)-$(RPMVERSION)-$(ITERATION).i386.rpm: package_build_linux_386 check_fpm --iteration $(ITERATION) \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - --license MIT \ + --license $(LICENSE) \ --url $(URL) \ --maintainer "$(MAINT)" \ --description "$(DESC)" \ @@ -173,7 +173,7 @@ $(BINARY)_$(VERSION)-$(ITERATION)_i386.deb: package_build_linux_386 check_fpm --iteration $(ITERATION) \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - --license MIT \ + --license $(LICENSE) \ --url $(URL) \ --maintainer "$(MAINT)" \ --description "$(DESC)" \ @@ -191,7 +191,7 @@ $(BINARY)-$(RPMVERSION)-$(ITERATION).arm64.rpm: package_build_linux_arm64 check_ --iteration $(ITERATION) \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - --license MIT \ + --license $(LICENSE) \ --url $(URL) \ --maintainer "$(MAINT)" \ --description "$(DESC)" \ @@ -209,7 +209,7 @@ $(BINARY)_$(VERSION)-$(ITERATION)_arm64.deb: package_build_linux_arm64 check_fpm --iteration $(ITERATION) \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - --license MIT \ + --license $(LICENSE) \ --url $(URL) \ --maintainer "$(MAINT)" \ --description "$(DESC)" \ @@ -227,7 +227,7 @@ $(BINARY)-$(RPMVERSION)-$(ITERATION).armhf.rpm: package_build_linux_armhf check_ --iteration $(ITERATION) \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - --license MIT \ + --license $(LICENSE) \ --url $(URL) \ --maintainer "$(MAINT)" \ --description "$(DESC)" \ @@ -245,7 +245,7 @@ $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb: package_build_linux_armhf check_fpm --iteration $(ITERATION) \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - --license MIT \ + --license $(LICENSE) \ --url $(URL) \ --maintainer "$(MAINT)" \ --description "$(DESC)" \ @@ -257,6 +257,12 @@ docker: --build-arg "BUILD_DATE=${DATE}" \ --build-arg "COMMIT=${COMMIT}" \ --build-arg "VERSION=${VERSION}-${ITERATION}" \ + --build-arg "LICENSE=${LICENSE}" \ + --build-arg "TITLE=${TITLE}" \ + --build-arg "DESC=${DESC}" \ + --build-arg "URL=${URL}" \ + --build-arg "VENDOR=${VENDOR}" \ + --build-arg "AUTHOR=${MAINT}" \ --tag $(DHUSER)/$(BINARY):local . # Build an environment that can be packaged for linux. diff --git a/init/docker/hooks/build b/init/docker/hooks/build index 25d0c098..fe37e43a 100755 --- a/init/docker/hooks/build +++ b/init/docker/hooks/build @@ -25,7 +25,7 @@ for build in $BUILDS; do --build-arg "DESC=${DESC}" \ --build-arg "URL=${URL}" \ --build-arg "VENDOR=${VENDOR}" \ - --build-arg "AUTHOR=${AUTHOR}" \ + --build-arg "AUTHOR=${MAINT}" \ --tag "${IMAGE_NAME}_${os}_${name}" \ --file Dockerfile ../.. done From d96eb7b8ec0d190f97361f58c1d708b5e769de71 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2019 20:27:58 -0700 Subject: [PATCH 04/11] trigger docker build --- init/homebrew/unifi-poller.rb.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/homebrew/unifi-poller.rb.tmpl b/init/homebrew/unifi-poller.rb.tmpl index ba5e1e8f..1bfda369 100644 --- a/init/homebrew/unifi-poller.rb.tmpl +++ b/init/homebrew/unifi-poller.rb.tmpl @@ -17,7 +17,7 @@ class UnifiPoller < Formula # to $GOPATH/src/github.com/davidnewhall/unifi-poller bin_path.install Dir["*"] cd bin_path do - system "dep", "ensure", "-vendor-only" + system "dep", "ensure", "--vendor-only" system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}", "ETC=#{etc}" # If this fails, the user gets a nice big warning about write permissions on their # #{var}/log folder. The alternative could be letting the app silently fail From 08f1bc3ada32618913a0bcdc442d1e43f6ef770e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2019 21:00:27 -0700 Subject: [PATCH 05/11] fix paths in docker build --- init/docker/hooks/build | 16 +++++++++------- init/docker/hooks/push | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/init/docker/hooks/build b/init/docker/hooks/build index fe37e43a..edfefd2d 100755 --- a/init/docker/hooks/build +++ b/init/docker/hooks/build @@ -1,13 +1,13 @@ #!/bin/bash - -# This always run local to the Dockerfile folder, so the path is ../.. - -set -e -o pipefail - # The Docker Cloud config must pass in the BUILDS env variable. # See README.md (in this dir) and the screenshot for more info. -source ../../.metadata.sh +set -e -o pipefail + +# This always run local to the Dockerfile folder, so the path is ../.. +pushd ../.. + +source .metadata.sh # Build each configured image from Docker Cloud. for build in $BUILDS; do @@ -27,5 +27,7 @@ for build in $BUILDS; do --build-arg "VENDOR=${VENDOR}" \ --build-arg "AUTHOR=${MAINT}" \ --tag "${IMAGE_NAME}_${os}_${name}" \ - --file Dockerfile ../.. + --file Dockerfile . done + +popd diff --git a/init/docker/hooks/push b/init/docker/hooks/push index c71e906c..f49206ee 100755 --- a/init/docker/hooks/push +++ b/init/docker/hooks/push @@ -1,10 +1,12 @@ #!/bin/bash - # This post build hook creates multi-architecture docker manifests. # It's all a bit complicated for some reason. + set -e -o pipefail -source ../../.metadata.sh +pushd ../.. +source .metadata.sh +popd if [ "$BUILDS" != "" ]; then TAGS=$DOCKER_TAG From 9fe411fcf6a52e57303a332fa8880993f68857c4 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2019 21:14:37 -0700 Subject: [PATCH 06/11] fix dockerfile path --- init/docker/hooks/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/docker/hooks/build b/init/docker/hooks/build index edfefd2d..5053d4c3 100755 --- a/init/docker/hooks/build +++ b/init/docker/hooks/build @@ -27,7 +27,7 @@ for build in $BUILDS; do --build-arg "VENDOR=${VENDOR}" \ --build-arg "AUTHOR=${MAINT}" \ --tag "${IMAGE_NAME}_${os}_${name}" \ - --file Dockerfile . + --file ${DOCKERFILE_PATH} . done popd From 338ea302c8e48f7ee934971413e2e6d6260273d7 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2019 21:20:54 -0700 Subject: [PATCH 07/11] fix binary name --- .metadata.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.metadata.sh b/.metadata.sh index 87aa673e..ce87c779 100755 --- a/.metadata.sh +++ b/.metadata.sh @@ -13,8 +13,8 @@ CONFIG_FILE="up.conf" LICENSE="MIT" # The rest if mostly automatic. - -BINARY="$(basename $(pwd))" +BINARY="$(basename $(git rev-parse --show-toplevel))" +[ "$BINARY" != "" ] || BINARY="$(basename $(pwd))" GHREPO="${GHUSER}/${BINARY}" URL="https://github.com/${GHREPO}" From 872a3e782c7f0342088d8f37c37c47a056b1e46e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 9 Jul 2019 00:47:11 -0700 Subject: [PATCH 08/11] more auto --- .metadata.sh | 17 +++++++----- Makefile | 37 +++++++++++++++---------- init/docker/Dockerfile | 43 ++++++++++++++---------------- init/docker/hooks/build | 4 ++- init/homebrew/unifi-poller.rb.tmpl | 30 ++++++++++----------- scripts/formula-deploy.sh | 18 ++++--------- scripts/install.sh | 2 +- 7 files changed, 76 insertions(+), 75 deletions(-) diff --git a/.metadata.sh b/.metadata.sh index ce87c779..261460aa 100755 --- a/.metadata.sh +++ b/.metadata.sh @@ -1,6 +1,8 @@ # Each line must have an export clause. # This file is parsed and sourced by the Makefile, Docker and Homebrew builds. -TITLE="UniFi Poller" + +# Must match the repo name. +BINARY="unifi-poller" # github username GHUSER="davidnewhall" # docker hub username @@ -9,19 +11,21 @@ MAINT="David Newhall II " VENDOR="Go Lift" DESC="Polls a UniFi controller and stores metrics in InfluxDB" GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals" +# Example must exist at examples/$CONFIG_FILE.example CONFIG_FILE="up.conf" LICENSE="MIT" -# The rest if mostly automatic. -BINARY="$(basename $(git rev-parse --show-toplevel))" -[ "$BINARY" != "" ] || BINARY="$(basename $(pwd))" +export BINARY GHUSER DHUSER MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LICENSE + +# The rest is mostly automatic. + GHREPO="${GHUSER}/${BINARY}" URL="https://github.com/${GHREPO}" # This parameter is passed in as -X to go build. Used to override the Version variable in a package. # This makes a path like github.com/davidnewhall/unifi-poller/unifipoller.Version=1.3.3 # Name the Version-containing library the same as the github repo, without dashes. -VERSION_PATH="github.com/${GHUSER}/${BINARY}/$(echo ${BINARY} | tr -d -- -).Version" +VERSION_PATH="github.com/${GHREPO}/$(echo ${BINARY} | tr -d -- -).Version" # Dynamic. Recommend not changing. VERSION="$(git tag -l --merged | tail -n1 | tr -d v || echo development)" @@ -30,5 +34,4 @@ ITERATION=$(git rev-list --count --all || echo 0) DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" COMMIT="$(git rev-parse --short HEAD || echo 0)" -export TITLE GHUSER DHUSER MAINT VENDOR DESC CONFIG_FILE LICENSE GOLANGCI_LINT_ARGS -export BINARY GHREPO URL VERSION_PATH VERSION ITERATION DATE COMMIT +export GHREPO URL VERSION_PATH VERSION ITERATION DATE COMMIT diff --git a/Makefile b/Makefile index 2cb69819..6791d8b5 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@ ifeq ($(VERSION),) include .metadata.make else # Preserve the passed-in version & iteration (homebrew). - _VERSION:=$(VERSION) - _ITERATION:=$(ITERATION) + _VERSION:=$(VERSION) + _ITERATION:=$(ITERATION) include .metadata.make VERSION:=$(_VERSION) ITERATION:=$(_ITERATION) @@ -42,7 +42,7 @@ release: clean vendor test macos arm windows linux_packages clean: # Cleaning up. rm -f $(BINARY) $(BINARY).*.{macos,linux,exe}{,.gz,.zip} $(BINARY).1{,.gz} $(BINARY).rb - rm -f $(BINARY){_,-}*.{deb,rpm} v*.tar.gz.sha256 + rm -f $(BINARY){_,-}*.{deb,rpm} v*.tar.gz.sha256 .metadata.make rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html rm -rf package_build_* release @@ -254,15 +254,17 @@ $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb: package_build_linux_armhf check_fpm docker: docker build -f init/docker/Dockerfile \ - --build-arg "BUILD_DATE=${DATE}" \ - --build-arg "COMMIT=${COMMIT}" \ - --build-arg "VERSION=${VERSION}-${ITERATION}" \ - --build-arg "LICENSE=${LICENSE}" \ - --build-arg "TITLE=${TITLE}" \ - --build-arg "DESC=${DESC}" \ - --build-arg "URL=${URL}" \ - --build-arg "VENDOR=${VENDOR}" \ - --build-arg "AUTHOR=${MAINT}" \ + --build-arg "BUILD_DATE=$(DATE)" \ + --build-arg "COMMIT=$(COMMIT)" \ + --build-arg "VERSION=$(VERSION)-$(ITERATION)" \ + --build-arg "LICENSE=$(LICENSE)" \ + --build-arg "DESC=$(DESC)" \ + --build-arg "URL=$(URL)" \ + --build-arg "VENDOR=$(VENDOR)" \ + --build-arg "AUTHOR=$(MAINT)" \ + --build-arg "BINARY=$(BINARY)" \ + --build-arg "GHREPO=$(GHREPO)" \ + --build-arg "CONFIG_FILE=$(CONFIG_FILE)" \ --tag $(DHUSER)/$(BINARY):local . # Build an environment that can be packaged for linux. @@ -306,8 +308,15 @@ v$(VERSION).tar.gz.sha256: curl -sL $(URL)/archive/v$(VERSION).tar.gz | openssl dgst -r -sha256 | tee $@ $(BINARY).rb: v$(VERSION).tar.gz.sha256 # Creating formula from template using sed. - sed "s/{{Version}}/$(VERSION)/g;s/{{SHA256}}/`head -c64 $<`/g;s/{{Desc}}/$(DESC)/g;s%{{URL}}%$(URL)%g" init/homebrew/$(BINARY).rb.tmpl | tee $(BINARY).rb - + sed -e "s/{{Version}}/$(VERSION)/g" \ + -e "s/{{Iter}}/$(ITERATION)/g" \ + -e "s/{{SHA256}}/$(shell head -c64 $<)/g" \ + -e "s/{{Desc}}/$(DESC)/g" \ + -e "s%{{URL}}%$(URL)%g" \ + -e "s%{{GHREPO}}%$(GHREPO)%g" \ + -e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \ + -e "s%{{Class}}%$(shell echo $(BINARY) | perl -pe 's/(?:\b|-)(\p{Ll})/\u$$1/g')%g" \ + init/homebrew/$(BINARY).rb.tmpl | tee $(BINARY).rb # Extras # Run code tests and lint. diff --git a/init/docker/Dockerfile b/init/docker/Dockerfile index dc00d8b4..b1f14ad4 100644 --- a/init/docker/Dockerfile +++ b/init/docker/Dockerfile @@ -6,31 +6,26 @@ ARG ARCH=amd64 ARG OS=linux ARG BUILD_DATE=0 ARG COMMIT=0 -ARG VERSION=development +ARG VERSION=unknown +ARG BINARY=application-builder +ARG GHREPO=golift/application-builder FROM golang:stretch as builder ARG ARCH ARG OS +ARG BINARY +ARG GHREPO -RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/github.com/davidnewhall/unifi-poller +RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/github.com/${GHREPO} RUN apt-get update \ && apt-get install -y curl \ && curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh -COPY . $GOPATH/src/github.com/davidnewhall/unifi-poller -WORKDIR $GOPATH/src/github.com/davidnewhall/unifi-poller +COPY . $GOPATH/src/github.com/${GHREPO} +WORKDIR $GOPATH/src/github.com/${GHREPO} RUN dep ensure --vendor-only \ - && CGO_ENABLED=0 make unifi-poller.${ARCH}.${OS} - -# -# creating container for run -# to use this container use the following command: -# -# docker run -d -v /your/config/up.conf:/etc/unifi-poller/up.conf golift/unifi-poller -# -# by using "-e UNIFI_PASSWORD=your-secret-pasword" you can avoid this configuration in the config file -# + && CGO_ENABLED=0 make ${BINARY}.${ARCH}.${OS} FROM scratch ARG ARCH @@ -39,28 +34,30 @@ ARG BUILD_DATE ARG COMMIT ARG VERSION ARG LICENSE=MIT -ARG TITLE=unifi-poller -ARG URL=http://github.com/davidnewhall/unifi-poller -ARG DESC=unifi-poller +ARG BINARY +ARG GHREPO +ARG URL=http://github.com/golift/application-builder +ARG DESC=application-builder ARG VENDOR=golift ARG AUTHOR=golift +ARG CONFIG_FILE=config.conf # Build-time metadata as defined at https://github.com/opencontainers/image-spec/blob/master/annotations.md LABEL org.opencontainers.image.created="${BUILD_DATE}" \ - org.opencontainers.image.title="${TITLE}" \ + org.opencontainers.image.title="${BINARY}" \ org.opencontainers.image.documentation="${URL}/wiki/Docker" \ org.opencontainers.image.description="${DESC}" \ org.opencontainers.image.url="${URL}" \ org.opencontainers.image.revision="${COMMIT}" \ - org.opencontainers.image.source="${URL}" \ + org.opencontainers.image.source="https://github.com/${GHREPO}" \ org.opencontainers.image.vendor="${VENDOR}" \ org.opencontainers.image.authors="${AUTHOR}" \ org.opencontainers.image.architecture="${OS} ${ARCH}" \ org.opencontainers.image.licenses="${LICENSE}" \ org.opencontainers.image.version="${VERSION}" -COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller.${ARCH}.${OS} /unifi-poller -COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/examples/up.conf.example /etc/unifi-poller/up.conf +COPY --from=builder /go/src/github.com/${GHREPO}/${BINARY}.${ARCH}.${OS} /image +COPY --from=builder /go/src/github.com/${GHREPO}/examples/${CONFIG_FILE}.example /etc/${BINARY}/${CONFIG_FILE} -VOLUME [ "/etc/unifi-poller" ] -ENTRYPOINT [ "/unifi-poller" ] +VOLUME [ "/etc/${BINARY}" ] +ENTRYPOINT [ "/image" ] diff --git a/init/docker/hooks/build b/init/docker/hooks/build index 5053d4c3..01be1ca9 100755 --- a/init/docker/hooks/build +++ b/init/docker/hooks/build @@ -21,11 +21,13 @@ for build in $BUILDS; do --build-arg "COMMIT=${COMMIT}" \ --build-arg "VERSION=${VERSION}-${ITERATION}" \ --build-arg "LICENSE=${LICENSE}" \ - --build-arg "TITLE=${TITLE}" \ --build-arg "DESC=${DESC}" \ --build-arg "URL=${URL}" \ --build-arg "VENDOR=${VENDOR}" \ --build-arg "AUTHOR=${MAINT}" \ + --build-arg "BINARY=${BINARY}" \ + --build-arg "GHREPO=${GHREPO}" \ + --build-arg "CONFIG_FILE=${CONFIG_FILE}" \ --tag "${IMAGE_NAME}_${os}_${name}" \ --file ${DOCKERFILE_PATH} . done diff --git a/init/homebrew/unifi-poller.rb.tmpl b/init/homebrew/unifi-poller.rb.tmpl index 1bfda369..c9731742 100644 --- a/init/homebrew/unifi-poller.rb.tmpl +++ b/init/homebrew/unifi-poller.rb.tmpl @@ -1,5 +1,5 @@ # Homebrew Formula Template. Built by Makefile: `make fomula` -class UnifiPoller < Formula +class {{Class}} < Formula desc "{{Desc}}" homepage "{{URL}}" url "{{URL}}/archive/v{{Version}}.tar.gz" @@ -12,27 +12,25 @@ class UnifiPoller < Formula def install ENV["GOPATH"] = buildpath - bin_path = buildpath/"src/github.com/davidnewhall/unifi-poller" + bin_path = buildpath/"src/github.com/{{GHREPO}}" # Copy all files from their current location (GOPATH root) - # to $GOPATH/src/github.com/davidnewhall/unifi-poller - bin_path.install Dir["*"] + # to $GOPATH/src/github.com/{{GHREPO}} + bin_path.install Dir["*",".??*"] cd bin_path do system "dep", "ensure", "--vendor-only" - system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}", "ETC=#{etc}" + system "make", "install", "VERSION=#{version}", "ITERATION={{Iter}}", "PREFIX=#{prefix}", "ETC=#{etc}" # If this fails, the user gets a nice big warning about write permissions on their # #{var}/log folder. The alternative could be letting the app silently fail # to start when it cannot write logs. This is better. Fix perms; reinstall. - touch("#{var}/log/unifi-poller.log") + touch("#{var}/log/#{name}.log") end end def caveats <<-EOS - This application will not work until the config file has authentication - information for a UniFi Controller and an Influx Database. Edit the config - file at #{etc}/unifi-poller/up.conf then start the application with - brew services start unifi-poller ~ log file: #{var}/log/unifi-poller.log - The manual explains the config file options: man unifi-poller + Edit the config file at #{etc}/#{name}/{{CONFIG_FILE}} then start #{name} with + brew services start #{name} ~ log file: #{var}/log/#{name}.log + The manual explains the config file options: man #{name} EOS end @@ -48,24 +46,24 @@ class UnifiPoller < Formula #{plist_name} ProgramArguments - #{bin}/unifi-poller + #{bin}/#{name} -c - #{etc}/unifi-poller/up.conf + #{etc}/#{name}/{{CONFIG_FILE}} RunAtLoad KeepAlive StandardErrorPath - #{var}/log/unifi-poller.log + #{var}/log/#{name}.log StandardOutPath - #{var}/log/unifi-poller.log + #{var}/log/#{name}.log EOS end test do - assert_match "unifi-poller v#{version}", shell_output("#{bin}/unifi-poller -v 2>&1", 2) + assert_match "#{name} v#{version}", shell_output("#{bin}/#{name} -v 2>&1", 2) end end diff --git a/scripts/formula-deploy.sh b/scripts/formula-deploy.sh index 0b5affae..980d2e2b 100755 --- a/scripts/formula-deploy.sh +++ b/scripts/formula-deploy.sh @@ -4,26 +4,18 @@ # Requires SSH credentials in ssh-agent to work. # Run by Travis-CI when a new release is created on GitHub. -source ../.metadata.sh +source .metadata.sh -if [ -z "$VERSION" ]; then - VERSION=$TRAVIS_TAG -fi -VERSION=$(echo $VERSION|tr -d v) +make ${BINARY}.rb -make ${BINARY}.rb VERSION=$VERSION - -if [ -z "$VERSION" ]; then - VERSION=$(grep -E '^\s+url\s+"' ${BINARY}.rb | cut -d/ -f7 | cut -d. -f1,2,3) -fi - -rm -rf homebrew-mugs git config --global user.email "${BINARY}@auto.releaser" git config --global user.name "${BINARY}-auto-releaser" + +rm -rf homebrew-mugs git clone git@github.com:golift/homebrew-mugs.git cp ${BINARY}.rb homebrew-mugs/Formula pushd homebrew-mugs -git commit -m "Update ${BINARY} on Release: ${VERSION}-${ITERATION}" Formula/${BINARY}.rb +git commit -m "Update ${BINARY} on Release: v${VERSION}-${ITERATION}" Formula/${BINARY}.rb git push popd diff --git a/scripts/install.sh b/scripts/install.sh index 5b260028..caea43a6 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -4,7 +4,7 @@ # # Use it like this: (sudo is optional) # === -# curl https://raw.githubusercontent.com/davidnewhall/unifi-poller/master/scripts/install.sh | sudo bash +# curl https://raw.githubusercontent.com/this/repo/master/scripts/install.sh | sudo bash # === # If you're on redhat, this installs the latest rpm. If you're on Debian, it installs the latest deb package. # From 1e78f80de7eb0eeec858087b9517c9ae5cc91199 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 9 Jul 2019 01:35:43 -0700 Subject: [PATCH 09/11] Rename templates --- Makefile | 5 +++-- .../{unifi-poller.rb.tmpl => formula.rb.tmpl} | 0 init/systemd/template.unit.service | 20 +++++++++++++++++++ init/systemd/unifi-poller.service | 20 ------------------- 4 files changed, 23 insertions(+), 22 deletions(-) rename init/homebrew/{unifi-poller.rb.tmpl => formula.rb.tmpl} (100%) create mode 100644 init/systemd/template.unit.service delete mode 100644 init/systemd/unifi-poller.service diff --git a/Makefile b/Makefile index 6791d8b5..9e5501b8 100644 --- a/Makefile +++ b/Makefile @@ -279,7 +279,8 @@ package_build_linux: readme man linux cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/$(CONFIG_FILE) cp LICENSE *.html examples/*?.?* $@/usr/share/doc/$(BINARY)/ # These go to their own folder so the img src in the html pages continue to work. - cp init/systemd/$(BINARY).service $@/lib/systemd/system/ + sed -e "s/{{BINARY}}/$(BINARY)/g" -e "s/{{DESC}}/$(DESC)/g" \ + init/systemd/template.unit.service > $@/lib/systemd/system/$(BINARY).service package_build_linux_386: package_build_linux linux386 mkdir -p $@ @@ -316,7 +317,7 @@ $(BINARY).rb: v$(VERSION).tar.gz.sha256 -e "s%{{GHREPO}}%$(GHREPO)%g" \ -e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \ -e "s%{{Class}}%$(shell echo $(BINARY) | perl -pe 's/(?:\b|-)(\p{Ll})/\u$$1/g')%g" \ - init/homebrew/$(BINARY).rb.tmpl | tee $(BINARY).rb + init/homebrew/formula.rb.tmpl | tee $(BINARY).rb # Extras # Run code tests and lint. diff --git a/init/homebrew/unifi-poller.rb.tmpl b/init/homebrew/formula.rb.tmpl similarity index 100% rename from init/homebrew/unifi-poller.rb.tmpl rename to init/homebrew/formula.rb.tmpl diff --git a/init/systemd/template.unit.service b/init/systemd/template.unit.service new file mode 100644 index 00000000..a471a3ef --- /dev/null +++ b/init/systemd/template.unit.service @@ -0,0 +1,20 @@ +# Systemd service unit for {{BINARY}}. + +[Unit] +Description={{BINARY}} - {{DESC}} +After=network.target +Requires=network.target + +[Service] +ExecStart=/usr/bin/{{BINARY}} $DAEMON_OPTS +EnvironmentFile=-/etc/default/{{BINARY}} +EnvironmentFile=-/etc/sysconfig/{{BINARY}} +Restart=on-error +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier={{BINARY}} +Type=simple +User=nobody + +[Install] +WantedBy=multi-user.target diff --git a/init/systemd/unifi-poller.service b/init/systemd/unifi-poller.service deleted file mode 100644 index c8c65428..00000000 --- a/init/systemd/unifi-poller.service +++ /dev/null @@ -1,20 +0,0 @@ -# Sytemd service unit for unifi-poller. - -[Unit] -Description=UniFi Poller - Stores UniFi Metrics in InfluxDB -After=network.target -Requires=network.target - -[Service] -ExecStart=/usr/bin/unifi-poller $DAEMON_OPTS -EnvironmentFile=-/etc/default/unifi-poller -EnvironmentFile=-/etc/sysconfig/unifi-poller -Restart=on-error -StandardOutput=syslog -StandardError=syslog -SyslogIdentifier=unifi-poller -Type=simple -User=nobody - -[Install] -WantedBy=multi-user.target From dd65cbd23f10c116e9ca074180b5f7fb76d43512 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 9 Jul 2019 01:41:18 -0700 Subject: [PATCH 10/11] remove comment --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 9e5501b8..9040fda8 100644 --- a/Makefile +++ b/Makefile @@ -356,7 +356,6 @@ install: man readme $(BINARY) /usr/bin/install -m 0644 -cp examples/$(CONFIG_FILE).example $(ETC)/$(BINARY)/ [ -f $(ETC)/$(BINARY)/$(CONFIG_FILE) ] || /usr/bin/install -m 0644 -cp examples/$(CONFIG_FILE).example $(ETC)/$(BINARY)/$(CONFIG_FILE) /usr/bin/install -m 0644 -cp LICENSE *.html examples/* $(PREFIX)/share/doc/$(BINARY)/ - # These go to their own folder so the img src in the html pages continue to work. # If you installed with `make install` run `make uninstall` before installing a binary package. (even on Linux!!!) # This will remove the package install from macOS, it will not remove a package install from Linux. From 0ab583368c467d10d0a0014b88b29e32d05900d7 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 9 Jul 2019 02:14:05 -0700 Subject: [PATCH 11/11] More generic --- .gitignore | 2 +- .metadata.sh | 4 +++- Makefile | 17 +++++++++-------- scripts/formula-deploy.sh | 8 ++++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index aec6680f..d806a068 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,5 @@ MANUAL.html README README.html /unifi-poller_manual.html -/homebrew-mugs +/homebrew_release_repo /.metadata.make diff --git a/.metadata.sh b/.metadata.sh index 261460aa..2c375d2d 100755 --- a/.metadata.sh +++ b/.metadata.sh @@ -7,6 +7,8 @@ BINARY="unifi-poller" GHUSER="davidnewhall" # docker hub username DHUSER="golift" +# Github repo containing homebrew formula repo. +HBREPO="golift/homebrew-mugs" MAINT="David Newhall II " VENDOR="Go Lift" DESC="Polls a UniFi controller and stores metrics in InfluxDB" @@ -15,7 +17,7 @@ GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals" CONFIG_FILE="up.conf" LICENSE="MIT" -export BINARY GHUSER DHUSER MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LICENSE +export BINARY GHUSER DHUSER HBREPO MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LICENSE # The rest is mostly automatic. diff --git a/Makefile b/Makefile index 9040fda8..26ca8664 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ # This Makefile is written as generic as possible. -# Setting these variables and creating the necesarry paths in your GitHub repo will make this file work. +# Setting the variables in .metadata.sh and creating the paths in the repo makes this work. # +# Suck in our application information. IGNORE := $(shell bash -c "source .metadata.sh ; env | sed 's/=/:=/;s/^/export /' > .metadata.make") -# These don't generally need to be changed. - # md2roff turns markdown into man files and html files. MD2ROFF_BIN=github.com/github/hub/md2roff-bin + # Travis CI passes the version in. Local builds get it from the current git tag. ifeq ($(VERSION),) include .metadata.make @@ -264,22 +264,22 @@ docker: --build-arg "AUTHOR=$(MAINT)" \ --build-arg "BINARY=$(BINARY)" \ --build-arg "GHREPO=$(GHREPO)" \ - --build-arg "CONFIG_FILE=$(CONFIG_FILE)" \ + --build-arg "CONFIG_FILE=$(CONFIG_FILE)" \ --tag $(DHUSER)/$(BINARY):local . # Build an environment that can be packaged for linux. package_build_linux: readme man linux # Building package environment for linux. - mkdir -p $@/usr/bin $@/etc/$(BINARY) $@/lib/systemd/system - mkdir -p $@/usr/share/man/man1 $@/usr/share/doc/$(BINARY) + mkdir -p $@/usr/bin $@/etc/$(BINARY) $@/usr/share/man/man1 $@/usr/share/doc/$(BINARY) # Copying the binary, config file, unit file, and man page into the env. cp $(BINARY).amd64.linux $@/usr/bin/$(BINARY) cp *.1.gz $@/usr/share/man/man1 cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/ cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/$(CONFIG_FILE) cp LICENSE *.html examples/*?.?* $@/usr/share/doc/$(BINARY)/ - # These go to their own folder so the img src in the html pages continue to work. - sed -e "s/{{BINARY}}/$(BINARY)/g" -e "s/{{DESC}}/$(DESC)/g" \ + [ ! -f init/systemd/template.unit.service ] || mkdir -p $@/lib/systemd/system + [ ! -f init/systemd/template.unit.service ] || \ + sed -e "s/{{BINARY}}/$(BINARY)/g" -e "s/{{DESC}}/$(DESC)/g" \ init/systemd/template.unit.service > $@/lib/systemd/system/$(BINARY).service package_build_linux_386: package_build_linux linux386 @@ -318,6 +318,7 @@ $(BINARY).rb: v$(VERSION).tar.gz.sha256 -e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \ -e "s%{{Class}}%$(shell echo $(BINARY) | perl -pe 's/(?:\b|-)(\p{Ll})/\u$$1/g')%g" \ init/homebrew/formula.rb.tmpl | tee $(BINARY).rb + # Extras # Run code tests and lint. diff --git a/scripts/formula-deploy.sh b/scripts/formula-deploy.sh index 980d2e2b..66704bd7 100755 --- a/scripts/formula-deploy.sh +++ b/scripts/formula-deploy.sh @@ -11,11 +11,11 @@ make ${BINARY}.rb git config --global user.email "${BINARY}@auto.releaser" git config --global user.name "${BINARY}-auto-releaser" -rm -rf homebrew-mugs -git clone git@github.com:golift/homebrew-mugs.git +rm -rf homebrew_release_repo +git clone git@github.com:${HBREPO}.git homebrew_release_repo -cp ${BINARY}.rb homebrew-mugs/Formula -pushd homebrew-mugs +cp ${BINARY}.rb homebrew_release_repo/Formula +pushd homebrew_release_repo git commit -m "Update ${BINARY} on Release: v${VERSION}-${ITERATION}" Formula/${BINARY}.rb git push popd