Build formula file from template with Makefile.

This commit is contained in:
David Newhall II 2019-06-12 14:32:28 -07:00
parent 49b224cbe1
commit 50b2c07548
3 changed files with 22 additions and 12 deletions

2
.gitignore vendored
View File

@ -7,6 +7,8 @@
/unifi-poller*.pkg
/unifi-poller.macos
/unifi-poller.linux
/unifi-poller.rb
*.sha256
/vendor
.DS_Store
*~

View File

@ -20,13 +20,13 @@ before_install:
- chmod +x $GOPATH/bin/dep
# download super-linter: golangci-lint
- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
- curl -sLo ./up.tgz https://github.com/davidnewhall/unifi-poller/archive/${TRAVIS_TAG}.tar.gz
install:
- dep ensure
- rvm $brew_ruby do gem install --no-document fpm
script:
- rvm $brew_ruby do make release
- openssl dgst -sha256 ./up.tgz | tee release/${TRAVIS_TAG}.tar.gz.sha256
# TODO: upload the formula somewhere.
- make formula
deploy:
provider: releases
api_key:

View File

@ -1,7 +1,7 @@
BINARY:=unifi-poller
URL=https://github.com/davidnewhall/unifi-poller
MAINT="David Newhall II <david at sleepers dot pro>"
DESC="This daemon polls a Unifi controller at a short interval and stores the collected metric data in an Influx Database."
MAINT=David Newhall II <david at sleepers dot pro>
DESC=This daemon polls a Unifi controller at a short interval and stores the collected metric data in an Influx Database.
PACKAGE:=./cmd/$(BINARY)
ifeq ($(VERSION),)
VERSION:=$(shell git tag -l --merged | tail -n1 | tr -d v||echo development)
@ -24,8 +24,8 @@ release: clean test $(BINARY)-$(VERSION)-$(ITERATION).x86_64.rpm $(BINARY)_$(VER
# Delete all build assets.
clean:
# Cleaning up.
rm -f $(BINARY){.macos,.linux,.1,}{,.gz}
rm -f $(BINARY){_,-}*.{deb,rpm,pkg} md2roff
rm -f $(BINARY){.macos,.linux,.1,}{,.gz} $(BINARY).rb
rm -f $(BINARY){_,-}*.{deb,rpm,pkg} md2roff v$(VERSION).tar.gz.sha256
rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html
rm -rf package_build_* release
@ -80,8 +80,8 @@ $(BINARY)-$(VERSION)-$(ITERATION).x86_64.rpm: check_fpm package_build_linux
--before-remove scripts/before-remove.sh \
--license MIT \
--url $(URL) \
--maintainer $(MAINT) \
--description $(DESC) \
--maintainer "$(MAINT)" \
--description "$(DESC)" \
--chdir package_build_linux
deb: clean $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb
@ -95,8 +95,8 @@ $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb: check_fpm package_build_linux
--before-remove scripts/before-remove.sh \
--license MIT \
--url $(URL) \
--maintainer $(MAINT) \
--description $(DESC) \
--maintainer "$(MAINT)" \
--description "$(DESC)" \
--chdir package_build_linux
osxpkg: clean $(BINARY)-$(VERSION).pkg
@ -110,8 +110,8 @@ $(BINARY)-$(VERSION).pkg: check_fpm package_build_osx
--osxpkg-identifier-prefix com.github.davidnewhall \
--license MIT \
--url $(URL) \
--maintainer $(MAINT) \
--description $(DESC) \
--maintainer "$(MAINT)" \
--description "$(DESC)" \
--chdir package_build_osx
# OSX packages use /usr/local because Apple doesn't allow writing many other places.
@ -146,6 +146,14 @@ package_build_linux: readme man linux
check_fpm:
@fpm --version > /dev/null || (echo "FPM missing. Install FPM: https://fpm.readthedocs.io/en/latest/installing.html" && false)
formula: $(BINARY).rb
v$(VERSION).tar.gz.sha256:
# Calculate the SHA from the Github source file.
curl -sL https://github.com/davidnewhall/unifi-poller/archive/v$(VERSION).tar.gz | openssl dgst -sha256 | tee v$(VERSION).tar.gz.sha256
$(BINARY).rb: v$(VERSION).tar.gz.sha256
# Creating formula from template using sed.
sed "s/{{Version}}/$(VERSION)/g;s/{{SHA256}}/$$(<v$(VERSION).tar.gz.sha256)/g;s/{{Desc}}/$(DESC)/g;s%{{URL}}%$(URL)%g" templates/$(BINARY).rb.tmpl | tee $(BINARY).rb
# Extras
# Run code tests and lint.