2021-10-24 04:29:45 +03:00
|
|
|
VERSION := $(shell git describe --tag)
|
|
|
|
|
|
|
|
.PHONY:
|
|
|
|
|
|
|
|
help:
|
2022-03-18 20:53:52 +03:00
|
|
|
@echo "Typical commands (more see below):"
|
|
|
|
@echo " make build - Build web app, documentation and server/client (sloowwww)"
|
|
|
|
@echo " make server-amd64 - Build server/client binary (amd64, no web app or docs)"
|
|
|
|
@echo " make install-amd64 - Install ntfy binary to /usr/bin/ntfy (amd64)"
|
|
|
|
@echo " make web - Build the web app"
|
|
|
|
@echo " make docs - Build the documentation"
|
2022-03-17 05:33:23 +03:00
|
|
|
@echo " make check - Run all tests, vetting/formatting checks and linters"
|
2022-03-18 20:53:52 +03:00
|
|
|
@echo
|
|
|
|
@echo "Build everything:"
|
|
|
|
@echo " make build - Build web app, documentation and server/client"
|
|
|
|
@echo " make clean - Clean build/dist folders"
|
|
|
|
@echo
|
|
|
|
@echo "Build server & client (not release version):"
|
|
|
|
@echo " make server - Build server & client (all architectures)"
|
|
|
|
@echo " make server-amd64 - Build server & client (amd64 only)"
|
2022-04-07 02:45:30 +03:00
|
|
|
@echo " make server-armv6 - Build server & client (armv6 only)"
|
2022-03-18 20:53:52 +03:00
|
|
|
@echo " make server-armv7 - Build server & client (armv7 only)"
|
|
|
|
@echo " make server-arm64 - Build server & client (arm64 only)"
|
|
|
|
@echo
|
|
|
|
@echo "Build web app:"
|
|
|
|
@echo " make web - Build the web app"
|
|
|
|
@echo " make web-deps - Install web app dependencies (npm install the universe)"
|
|
|
|
@echo " make web-build - Actually build the web app"
|
|
|
|
@echo
|
|
|
|
@echo "Build documentation:"
|
|
|
|
@echo " make docs - Build the documentation"
|
|
|
|
@echo " make docs-deps - Install Python dependencies (pip3 install)"
|
|
|
|
@echo " make docs-build - Actually build the documentation"
|
2021-10-24 04:29:45 +03:00
|
|
|
@echo
|
|
|
|
@echo "Test/check:"
|
2022-03-17 05:33:23 +03:00
|
|
|
@echo " make test - Run tests"
|
|
|
|
@echo " make race - Run tests with -race flag"
|
|
|
|
@echo " make coverage - Run tests and show coverage"
|
|
|
|
@echo " make coverage-html - Run tests and show coverage (as HTML)"
|
|
|
|
@echo " make coverage-upload - Upload coverage results to codecov.io"
|
2021-10-24 04:29:45 +03:00
|
|
|
@echo
|
|
|
|
@echo "Lint/format:"
|
2022-03-17 05:33:23 +03:00
|
|
|
@echo " make fmt - Run 'go fmt'"
|
|
|
|
@echo " make fmt-check - Run 'go fmt', but don't change anything"
|
|
|
|
@echo " make vet - Run 'go vet'"
|
|
|
|
@echo " make lint - Run 'golint'"
|
|
|
|
@echo " make staticcheck - Run 'staticcheck'"
|
2021-10-24 04:29:45 +03:00
|
|
|
@echo
|
2022-03-18 20:53:52 +03:00
|
|
|
@echo "Releasing:"
|
2022-03-17 05:33:23 +03:00
|
|
|
@echo " make release - Create a release"
|
|
|
|
@echo " make release-snapshot - Create a test release"
|
2021-10-24 04:29:45 +03:00
|
|
|
@echo
|
|
|
|
@echo "Install locally (requires sudo):"
|
2022-03-18 20:53:52 +03:00
|
|
|
@echo " make install-amd64 - Copy amd64 binary from dist/ to /usr/bin/ntfy"
|
2022-04-07 02:45:30 +03:00
|
|
|
@echo " make install-armv6 - Copy armv6 binary from dist/ to /usr/bin/ntfy"
|
2022-03-18 20:53:52 +03:00
|
|
|
@echo " make install-armv7 - Copy armv7 binary from dist/ to /usr/bin/ntfy"
|
|
|
|
@echo " make install-arm64 - Copy arm64 binary from dist/ to /usr/bin/ntfy"
|
|
|
|
@echo " make install-deb-amd64 - Install .deb from dist/ (amd64 only)"
|
|
|
|
@echo " make install-deb-armv7 - Install .deb from dist/ (armv7 only)"
|
|
|
|
@echo " make install-deb-arm64 - Install .deb from dist/ (arm64 only)"
|
|
|
|
|
|
|
|
|
|
|
|
# Building everything
|
|
|
|
|
|
|
|
clean: .PHONY
|
|
|
|
rm -rf dist build server/docs server/site
|
|
|
|
|
|
|
|
build: web docs server
|
2021-10-24 04:29:45 +03:00
|
|
|
|
|
|
|
|
2021-12-07 20:23:42 +03:00
|
|
|
# Documentation
|
2022-03-06 05:15:40 +03:00
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
docs: docs-deps docs-build
|
|
|
|
|
2021-12-07 21:37:01 +03:00
|
|
|
docs-deps: .PHONY
|
|
|
|
pip3 install -r requirements.txt
|
|
|
|
|
2022-03-17 05:33:23 +03:00
|
|
|
docs-build: .PHONY
|
2021-12-07 20:23:42 +03:00
|
|
|
mkdocs build
|
|
|
|
|
2022-03-06 04:24:10 +03:00
|
|
|
|
|
|
|
# Web app
|
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
web: web-deps web-build
|
|
|
|
|
2022-03-06 04:24:10 +03:00
|
|
|
web-deps:
|
2022-03-18 20:53:52 +03:00
|
|
|
cd web && npm install
|
|
|
|
# If this fails for .svg files, optimizes them with svgo
|
2022-03-06 04:24:10 +03:00
|
|
|
|
|
|
|
web-build:
|
|
|
|
cd web \
|
|
|
|
&& npm run build \
|
|
|
|
&& mv build/index.html build/app.html \
|
|
|
|
&& rm -rf ../server/site \
|
|
|
|
&& mv build ../server/site \
|
|
|
|
&& rm \
|
2022-03-10 07:28:55 +03:00
|
|
|
../server/site/config.js \
|
2022-03-10 23:37:50 +03:00
|
|
|
../server/site/asset-manifest.json
|
2022-03-06 04:24:10 +03:00
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
|
|
|
|
# Main server/client build
|
|
|
|
|
|
|
|
server: server-deps
|
|
|
|
goreleaser build --snapshot --rm-dist --debug
|
|
|
|
|
|
|
|
server-amd64: server-deps-static-sites
|
|
|
|
goreleaser build --snapshot --rm-dist --debug --id ntfy_amd64
|
|
|
|
|
2022-04-07 02:45:30 +03:00
|
|
|
server-armv6: server-deps-static-sites server-deps-gcc-armv6-armv7
|
|
|
|
goreleaser build --snapshot --rm-dist --debug --id ntfy_armv6
|
|
|
|
|
|
|
|
server-armv7: server-deps-static-sites server-deps-gcc-armv6-armv7
|
2022-03-18 20:53:52 +03:00
|
|
|
goreleaser build --snapshot --rm-dist --debug --id ntfy_armv7
|
|
|
|
|
|
|
|
server-arm64: server-deps-static-sites server-deps-gcc-arm64
|
|
|
|
goreleaser build --snapshot --rm-dist --debug --id ntfy_arm64
|
|
|
|
|
|
|
|
server-deps: server-deps-static-sites server-deps-all server-deps-gcc
|
|
|
|
|
2022-04-07 02:45:30 +03:00
|
|
|
server-deps-gcc: server-deps-gcc-armv6-armv7 server-deps-gcc-arm64
|
2022-03-18 20:53:52 +03:00
|
|
|
|
|
|
|
server-deps-static-sites:
|
|
|
|
mkdir -p server/docs server/site
|
|
|
|
touch server/docs/index.html server/site/app.html
|
|
|
|
|
|
|
|
server-deps-all:
|
|
|
|
which upx || { echo "ERROR: upx not installed. On Ubuntu, run: apt install upx"; exit 1; }
|
|
|
|
|
2022-04-07 02:45:30 +03:00
|
|
|
server-deps-gcc-armv6-armv7:
|
|
|
|
which arm-linux-gnueabi-gcc || { echo "ERROR: ARMv6/ARMv7 cross compiler not installed. On Ubuntu, run: apt install gcc-arm-linux-gnueabi"; exit 1; }
|
2022-03-18 20:53:52 +03:00
|
|
|
|
|
|
|
server-deps-gcc-arm64:
|
|
|
|
which aarch64-linux-gnu-gcc || { echo "ERROR: ARM64 cross compiler not installed. On Ubuntu, run: apt install gcc-aarch64-linux-gnu"; exit 1; }
|
2022-03-06 04:24:10 +03:00
|
|
|
|
|
|
|
|
2021-10-24 04:29:45 +03:00
|
|
|
# Test/check targets
|
|
|
|
|
|
|
|
check: test fmt-check vet lint staticcheck
|
|
|
|
|
|
|
|
test: .PHONY
|
2021-12-23 01:20:43 +03:00
|
|
|
go test -v $(shell go list ./... | grep -vE 'ntfy/(test|examples|tools)')
|
2021-10-24 04:29:45 +03:00
|
|
|
|
|
|
|
race: .PHONY
|
2021-12-23 01:20:43 +03:00
|
|
|
go test -race $(shell go list ./... | grep -vE 'ntfy/(test|examples|tools)')
|
2021-10-24 04:29:45 +03:00
|
|
|
|
|
|
|
coverage:
|
|
|
|
mkdir -p build/coverage
|
2021-12-23 01:20:43 +03:00
|
|
|
go test -race -coverprofile=build/coverage/coverage.txt -covermode=atomic $(shell go list ./... | grep -vE 'ntfy/(test|examples|tools)')
|
|
|
|
go tool cover -func build/coverage/coverage.txt
|
2021-10-24 04:29:45 +03:00
|
|
|
|
|
|
|
coverage-html:
|
|
|
|
mkdir -p build/coverage
|
2021-12-23 01:20:43 +03:00
|
|
|
go test -race -coverprofile=build/coverage/coverage.txt -covermode=atomic $(shell go list ./... | grep -vE 'ntfy/(test|examples|tools)')
|
|
|
|
go tool cover -html build/coverage/coverage.txt
|
2021-10-24 04:29:45 +03:00
|
|
|
|
|
|
|
coverage-upload:
|
|
|
|
cd build/coverage && (curl -s https://codecov.io/bash | bash)
|
|
|
|
|
2021-11-20 23:43:15 +03:00
|
|
|
|
2021-10-24 04:29:45 +03:00
|
|
|
# Lint/formatting targets
|
|
|
|
|
|
|
|
fmt:
|
2021-12-07 23:39:42 +03:00
|
|
|
gofmt -s -w .
|
2021-10-24 04:29:45 +03:00
|
|
|
|
|
|
|
fmt-check:
|
|
|
|
test -z $(shell gofmt -l .)
|
|
|
|
|
|
|
|
vet:
|
2021-12-23 01:20:43 +03:00
|
|
|
go vet ./...
|
2021-10-24 04:29:45 +03:00
|
|
|
|
|
|
|
lint:
|
2022-01-26 06:30:53 +03:00
|
|
|
which golint || go install golang.org/x/lint/golint@latest
|
2021-12-23 01:20:43 +03:00
|
|
|
go list ./... | grep -v /vendor/ | xargs -L1 golint -set_exit_status
|
2021-10-24 04:29:45 +03:00
|
|
|
|
|
|
|
staticcheck: .PHONY
|
|
|
|
rm -rf build/staticcheck
|
2021-12-07 22:06:33 +03:00
|
|
|
which staticcheck || go install honnef.co/go/tools/cmd/staticcheck@latest
|
2021-10-24 04:29:45 +03:00
|
|
|
mkdir -p build/staticcheck
|
2021-12-23 01:20:43 +03:00
|
|
|
ln -s "go" build/staticcheck/go
|
2021-10-24 04:29:45 +03:00
|
|
|
PATH="$(PWD)/build/staticcheck:$(PATH)" staticcheck ./...
|
|
|
|
rm -rf build/staticcheck
|
|
|
|
|
2021-11-20 23:43:15 +03:00
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
# Releasing targets
|
2021-10-24 04:29:45 +03:00
|
|
|
|
2022-04-25 03:32:17 +03:00
|
|
|
release: clean server-deps release-check-tags docs web check
|
2022-03-18 20:53:52 +03:00
|
|
|
goreleaser release --rm-dist --debug
|
2021-10-24 04:29:45 +03:00
|
|
|
|
2022-04-25 03:32:17 +03:00
|
|
|
release-snapshot: clean server-deps docs web check
|
2022-03-18 20:53:52 +03:00
|
|
|
goreleaser release --snapshot --skip-publish --rm-dist --debug
|
2021-10-24 04:29:45 +03:00
|
|
|
|
2021-12-06 00:28:12 +03:00
|
|
|
release-check-tags:
|
|
|
|
$(eval LATEST_TAG := $(shell git describe --abbrev=0 --tags | cut -c2-))
|
2021-12-07 00:43:06 +03:00
|
|
|
if ! grep -q $(LATEST_TAG) docs/install.md; then\
|
2021-12-06 00:28:12 +03:00
|
|
|
echo "ERROR: Must update docs/install.md with latest tag first.";\
|
|
|
|
exit 1;\
|
|
|
|
fi
|
2022-03-13 23:06:40 +03:00
|
|
|
if ! grep -q $(LATEST_TAG) docs/releases.md; then\
|
2022-03-19 00:18:52 +03:00
|
|
|
echo "ERROR: Must update docs/releases.md with latest tag first.";\
|
2022-03-13 23:06:40 +03:00
|
|
|
exit 1;\
|
|
|
|
fi
|
2021-12-06 00:28:12 +03:00
|
|
|
|
2021-10-24 04:29:45 +03:00
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
# Installing targets
|
2021-10-24 04:29:45 +03:00
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
install-amd64: remove-binary
|
2022-04-20 23:31:25 +03:00
|
|
|
sudo cp -a dist/ntfy_amd64_linux_amd64_v1/ntfy /usr/bin/ntfy
|
2021-10-24 04:29:45 +03:00
|
|
|
|
2022-04-07 02:45:30 +03:00
|
|
|
install-armv6: remove-binary
|
|
|
|
sudo cp -a dist/ntfy_armv6_linux_armv6/ntfy /usr/bin/ntfy
|
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
install-armv7: remove-binary
|
|
|
|
sudo cp -a dist/ntfy_armv7_linux_armv7/ntfy /usr/bin/ntfy
|
2021-10-24 04:29:45 +03:00
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
install-arm64: remove-binary
|
|
|
|
sudo cp -a dist/ntfy_arm64_linux_arm64/ntfy /usr/bin/ntfy
|
|
|
|
|
|
|
|
remove-binary:
|
2021-10-24 04:29:45 +03:00
|
|
|
sudo rm -f /usr/bin/ntfy
|
|
|
|
|
2022-03-18 20:53:52 +03:00
|
|
|
install-amd64-deb: purge-package
|
|
|
|
sudo dpkg -i dist/ntfy_*_linux_amd64.deb
|
|
|
|
|
|
|
|
install-armv7-deb: purge-package
|
|
|
|
sudo dpkg -i dist/ntfy_*_linux_armv7.deb
|
|
|
|
|
|
|
|
install-arm64-deb: purge-package
|
|
|
|
sudo dpkg -i dist/ntfy_*_linux_arm64.deb
|
|
|
|
|
|
|
|
purge-package:
|
2021-10-24 04:29:45 +03:00
|
|
|
sudo systemctl stop ntfy || true
|
|
|
|
sudo apt-get purge ntfy || true
|