diff --git a/.gitignore b/.gitignore index 53ba083f..d806a068 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +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 new file mode 100755 index 00000000..2c375d2d --- /dev/null +++ b/.metadata.sh @@ -0,0 +1,39 @@ +# Each line must have an export clause. +# This file is parsed and sourced by the Makefile, Docker and Homebrew builds. + +# Must match the repo name. +BINARY="unifi-poller" +# github username +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" +GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals" +# Example must exist at examples/$CONFIG_FILE.example +CONFIG_FILE="up.conf" +LICENSE="MIT" + +export BINARY GHUSER DHUSER HBREPO 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/${GHREPO}/$(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 GHREPO URL VERSION_PATH VERSION ITERATION DATE COMMIT 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/Makefile b/Makefile index 77f25848..26ca8664 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. +# Setting the variables in .metadata.sh and creating the paths in the repo makes this 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 - -# These don't generally need to be changed. +# Suck in our application information. +IGNORE := $(shell bash -c "source .metadata.sh ; env | sed 's/=/:=/;s/^/export /' > .metadata.make") # 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. @@ -54,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 @@ -131,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)" \ @@ -149,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)" \ @@ -167,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)" \ @@ -185,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)" \ @@ -203,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)" \ @@ -221,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)" \ @@ -239,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)" \ @@ -257,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)" \ @@ -266,24 +254,33 @@ $(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 "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. 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. - cp init/systemd/$(BINARY).service $@/lib/systemd/system/ + [ ! -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 mkdir -p $@ @@ -312,7 +309,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/formula.rb.tmpl | tee $(BINARY).rb # Extras @@ -352,7 +357,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. diff --git a/init/docker/Dockerfile b/init/docker/Dockerfile index 7bc72b1e..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 @@ -38,23 +33,31 @@ ARG OS ARG BUILD_DATE ARG COMMIT ARG VERSION +ARG LICENSE=MIT +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="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="${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="https://github.com/davidnewhall/unifi-poller" \ - org.opencontainers.image.vendor="Go Lift" \ - org.opencontainers.image.authors="David Newhall II " \ + 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="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 -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 8e15743b..01be1ca9 100755 --- a/init/docker/hooks/build +++ b/init/docker/hooks/build @@ -1,16 +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. -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) +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 @@ -23,6 +20,16 @@ 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 "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 ../.. + --file ${DOCKERFILE_PATH} . done + +popd diff --git a/init/docker/hooks/push b/init/docker/hooks/push index e030ad4d..f49206ee 100755 --- a/init/docker/hooks/push +++ b/init/docker/hooks/push @@ -1,11 +1,13 @@ #!/bin/bash - # This post build hook creates multi-architecture docker manifests. # 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 +pushd ../.. +source .metadata.sh +popd + if [ "$BUILDS" != "" ]; then TAGS=$DOCKER_TAG fi diff --git a/init/homebrew/unifi-poller.rb.tmpl b/init/homebrew/formula.rb.tmpl similarity index 55% rename from init/homebrew/unifi-poller.rb.tmpl rename to init/homebrew/formula.rb.tmpl index ba5e1e8f..c9731742 100644 --- a/init/homebrew/unifi-poller.rb.tmpl +++ b/init/homebrew/formula.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 "dep", "ensure", "--vendor-only" + 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/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 diff --git a/scripts/formula-deploy.sh b/scripts/formula-deploy.sh index 9bbe1c06..66704bd7 100755 --- a/scripts/formula-deploy.sh +++ b/scripts/formula-deploy.sh @@ -3,26 +3,19 @@ # 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 -if [ -z "$VERSION" ]; then - VERSION=$TRAVIS_TAG -fi -VERSION=$(echo $VERSION|tr -d v) +source .metadata.sh -make ${APP}.rb VERSION=$VERSION +make ${BINARY}.rb -if [ -z "$VERSION" ]; then - VERSION=$(grep -E '^\s+url\s+"' ${APP}.rb | cut -d/ -f7 | cut -d. -f1,2,3) -fi +git config --global user.email "${BINARY}@auto.releaser" +git config --global user.name "${BINARY}-auto-releaser" -rm -rf homebrew-mugs -git config --global user.email "${APP}@auto.releaser" -git config --global user.name "${APP}-auto-releaser" -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 ${APP}.rb homebrew-mugs/Formula -pushd homebrew-mugs -git commit -m "Update ${APP} on Release: ${VERSION}" Formula/${APP}.rb +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 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. #