| 1 |
MAKEFLAGS := --jobs=1 |
| 2 |
NPM := npm |
| 3 |
PYTHON := python3 |
| 4 |
PIP := pip3 |
| 5 |
VERSION := $(shell git describe --tag) |
| 6 |
COMMIT := $(shell git rev-parse --short HEAD) |
| 7 |
|
| 8 |
# FORCE is an always-out-of-date target with no recipe; listing it as a prerequisite |
| 9 |
# forces that target's recipe to run every time (the classic "FORCE target" idiom). |
| 10 |
FORCE: |
| 11 |
|
| 12 |
help: |
| 13 |
@echo "Typical commands (more see below):" |
| 14 |
@echo " make build - Build web app, documentation and server/client (sloowwww)" |
| 15 |
@echo " make cli-linux-amd64 - Build server/client binary (amd64, no web app or docs)" |
| 16 |
@echo " make install-linux-amd64 - Install ntfy binary to /usr/bin/ntfy (amd64)" |
| 17 |
@echo " make web - Build the web app" |
| 18 |
@echo " make docs - Build the documentation" |
| 19 |
@echo " make check - Run all tests, vetting/formatting checks and linters" |
| 20 |
@echo |
| 21 |
@echo "Build everything:" |
| 22 |
@echo " make build - Build web app, documentation and server/client" |
| 23 |
@echo " make clean - Clean build/dist folders" |
| 24 |
@echo |
| 25 |
@echo "Build server & client (using GoReleaser, not release version):" |
| 26 |
@echo " make cli - Build server & client (all architectures)" |
| 27 |
@echo " make cli-linux-amd64 - Build server & client (Linux, amd64 only)" |
| 28 |
@echo " make cli-linux-armv6 - Build server & client (Linux, armv6 only)" |
| 29 |
@echo " make cli-linux-armv7 - Build server & client (Linux, armv7 only)" |
| 30 |
@echo " make cli-linux-arm64 - Build server & client (Linux, arm64 only)" |
| 31 |
@echo " make cli-windows-amd64 - Build client (Windows, amd64 only)" |
| 32 |
@echo " make cli-darwin-all - Build client (macOS, arm64+amd64 universal binary)" |
| 33 |
@echo |
| 34 |
@echo "Build server & client (without GoReleaser):" |
| 35 |
@echo " make cli-linux-server - Build client & server (no GoReleaser, current arch, Linux)" |
| 36 |
@echo " make cli-darwin-server - Build client & server (no GoReleaser, current arch, macOS)" |
| 37 |
@echo " make cli-windows-server - Build client & server (no GoReleaser, amd64 only, Windows)" |
| 38 |
@echo " make cli-client - Build client only (no GoReleaser, current arch, Linux/macOS/Windows)" |
| 39 |
@echo |
| 40 |
@echo "Build dev Docker:" |
| 41 |
@echo " make docker-dev - Build client & server for current architecture using Docker only" |
| 42 |
@echo |
| 43 |
@echo "Build web app:" |
| 44 |
@echo " make web - Build the web app" |
| 45 |
@echo " make web-deps - Install web app dependencies (npm install the universe)" |
| 46 |
@echo " make web-build - Actually build the web app" |
| 47 |
@echo " make web-lint - Run eslint on the web app" |
| 48 |
@echo " make web-test - Run vitest unit tests for the web app" |
| 49 |
@echo " make web-fmt - Run prettier on the web app" |
| 50 |
@echo " make web-fmt-check - Run prettier on the web app, but don't change anything" |
| 51 |
@echo |
| 52 |
@echo "Build documentation:" |
| 53 |
@echo " make docs - Build the documentation" |
| 54 |
@echo " make docs-deps - Install Python dependencies (pip3 install)" |
| 55 |
@echo " make docs-build - Actually build the documentation" |
| 56 |
@echo |
| 57 |
@echo "Test/check:" |
| 58 |
@echo " make test - Run all tests (Go + web)" |
| 59 |
@echo " make cli-test - Run Go tests only" |
| 60 |
@echo " make web-test - Run web app tests only" |
| 61 |
@echo " make race - Run tests with -race flag" |
| 62 |
@echo " make coverage - Run tests and show coverage" |
| 63 |
@echo " make coverage-html - Run tests and show coverage (as HTML)" |
| 64 |
@echo " make coverage-upload - Upload coverage results to codecov.io" |
| 65 |
@echo |
| 66 |
@echo "Lint/format:" |
| 67 |
@echo " make fmt - Run 'go fmt'" |
| 68 |
@echo " make fmt-check - Run 'go fmt', but don't change anything" |
| 69 |
@echo " make vet - Run 'go vet'" |
| 70 |
@echo " make lint - Run 'golint'" |
| 71 |
@echo " make staticcheck - Run 'staticcheck'" |
| 72 |
@echo |
| 73 |
@echo "Releasing:" |
| 74 |
@echo " make release - Create a release" |
| 75 |
@echo " make release-snapshot - Create a test release" |
| 76 |
@echo |
| 77 |
@echo "Install locally (requires sudo):" |
| 78 |
@echo " make install-linux-amd64 - Copy amd64 binary from dist/ to /usr/bin/ntfy" |
| 79 |
@echo " make install-linux-armv6 - Copy armv6 binary from dist/ to /usr/bin/ntfy" |
| 80 |
@echo " make install-linux-armv7 - Copy armv7 binary from dist/ to /usr/bin/ntfy" |
| 81 |
@echo " make install-linux-arm64 - Copy arm64 binary from dist/ to /usr/bin/ntfy" |
| 82 |
@echo " make install-linux-deb-amd64 - Install .deb from dist/ (amd64 only)" |
| 83 |
@echo " make install-linux-deb-armv6 - Install .deb from dist/ (armv6 only)" |
| 84 |
@echo " make install-linux-deb-armv7 - Install .deb from dist/ (armv7 only)" |
| 85 |
@echo " make install-linux-deb-arm64 - Install .deb from dist/ (arm64 only)" |
| 86 |
|
| 87 |
|
| 88 |
# Building everything |
| 89 |
|
| 90 |
clean: FORCE |
| 91 |
rm -rf dist build server/docs server/site |
| 92 |
|
| 93 |
build: web docs cli |
| 94 |
|
| 95 |
update: web-deps-update cli-deps-update docs-deps-update go-check |
| 96 |
docker pull alpine |
| 97 |
|
| 98 |
docker-dev: |
| 99 |
docker build \ |
| 100 |
--file ./Dockerfile-build \ |
| 101 |
--tag binwiederhier/ntfy:$(VERSION) \ |
| 102 |
--tag binwiederhier/ntfy:dev \ |
| 103 |
--build-arg VERSION=$(VERSION) \ |
| 104 |
--build-arg COMMIT=$(COMMIT) \ |
| 105 |
./ |
| 106 |
|
| 107 |
|
| 108 |
# Ubuntu-specific |
| 109 |
|
| 110 |
build-deps-ubuntu: |
| 111 |
sudo apt-get update |
| 112 |
sudo apt-get install -y \ |
| 113 |
curl \ |
| 114 |
gcc-aarch64-linux-gnu \ |
| 115 |
gcc-arm-linux-gnueabi \ |
| 116 |
gcc-mingw-w64-x86-64 \ |
| 117 |
python3 \ |
| 118 |
python3-venv \ |
| 119 |
jq |
| 120 |
which pip3 || sudo apt-get install -y python3-pip |
| 121 |
|
| 122 |
|
| 123 |
# Documentation |
| 124 |
|
| 125 |
docs: docs-deps docs-build |
| 126 |
|
| 127 |
docs-venv: FORCE |
| 128 |
$(PYTHON) -m venv ./venv |
| 129 |
|
| 130 |
docs-build: docs-venv |
| 131 |
(. venv/bin/activate && $(PYTHON) -m mkdocs build) |
| 132 |
|
| 133 |
docs-deps: docs-venv |
| 134 |
(. venv/bin/activate && $(PIP) install -r requirements.txt) |
| 135 |
|
| 136 |
docs-deps-update: FORCE |
| 137 |
(. venv/bin/activate && $(PIP) install -r requirements.txt --upgrade) |
| 138 |
|
| 139 |
|
| 140 |
# Web app |
| 141 |
|
| 142 |
web: web-deps web-build |
| 143 |
|
| 144 |
web-build: |
| 145 |
cd web \ |
| 146 |
&& $(NPM) run build \ |
| 147 |
&& mv build/index.html build/app.html \ |
| 148 |
&& rm -rf ../server/site \ |
| 149 |
&& mv build ../server/site \ |
| 150 |
&& rm \ |
| 151 |
../server/site/config.js |
| 152 |
|
| 153 |
web-deps: |
| 154 |
cd web && $(NPM) ci |
| 155 |
# Use "npm ci" so that we don't change the package lock file |
| 156 |
# If this fails for .svg files, optimize them with svgo |
| 157 |
|
| 158 |
web-deps-update: |
| 159 |
cd web && $(NPM) update --before="$(shell date -d '7 days ago' +%Y-%m-%d)" |
| 160 |
cd web && $(NPM) install |
| 161 |
|
| 162 |
web-fmt: |
| 163 |
cd web && $(NPM) run format |
| 164 |
|
| 165 |
web-fmt-check: |
| 166 |
cd web && $(NPM) run format:check |
| 167 |
|
| 168 |
web-lint: |
| 169 |
cd web && $(NPM) run lint |
| 170 |
|
| 171 |
web-test: |
| 172 |
cd web && $(NPM) run test |
| 173 |
|
| 174 |
# Main server/client build |
| 175 |
|
| 176 |
cli: cli-deps |
| 177 |
goreleaser build --snapshot --clean |
| 178 |
|
| 179 |
cli-linux-amd64: cli-deps-static-sites |
| 180 |
goreleaser build --snapshot --clean --id ntfy_linux_amd64 |
| 181 |
|
| 182 |
cli-linux-armv6: cli-deps-static-sites cli-deps-gcc-armv6-armv7 |
| 183 |
goreleaser build --snapshot --clean --id ntfy_linux_armv6 |
| 184 |
|
| 185 |
cli-linux-armv7: cli-deps-static-sites cli-deps-gcc-armv6-armv7 |
| 186 |
goreleaser build --snapshot --clean --id ntfy_linux_armv7 |
| 187 |
|
| 188 |
cli-linux-arm64: cli-deps-static-sites cli-deps-gcc-arm64 |
| 189 |
goreleaser build --snapshot --clean --id ntfy_linux_arm64 |
| 190 |
|
| 191 |
cli-windows-amd64: cli-deps-static-sites |
| 192 |
goreleaser build --snapshot --clean --id ntfy_windows_amd64 |
| 193 |
|
| 194 |
cli-darwin-all: cli-deps-static-sites |
| 195 |
goreleaser build --snapshot --clean --id ntfy_darwin_all |
| 196 |
|
| 197 |
cli-linux-server: cli-deps-static-sites |
| 198 |
# This is a target to build the CLI (including the server) manually. |
| 199 |
# Use this for development, if you really don't want to install GoReleaser ... |
| 200 |
mkdir -p dist/ntfy_linux_server server/docs |
| 201 |
CGO_ENABLED=1 go build \ |
| 202 |
-o dist/ntfy_linux_server/ntfy \ |
| 203 |
-tags sqlite_omit_load_extension,osusergo,netgo \ |
| 204 |
-ldflags \ |
| 205 |
"-linkmode=external -extldflags=-static -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(shell date +%s)" |
| 206 |
|
| 207 |
cli-darwin-server: cli-deps-static-sites |
| 208 |
# This is a target to build the CLI (including the server) manually. |
| 209 |
# Use this for macOS/iOS development, so you have a local server to test with. |
| 210 |
mkdir -p dist/ntfy_darwin_server server/docs |
| 211 |
CGO_ENABLED=1 go build \ |
| 212 |
-o dist/ntfy_darwin_server/ntfy \ |
| 213 |
-tags sqlite_omit_load_extension,osusergo,netgo \ |
| 214 |
-ldflags \ |
| 215 |
"-linkmode=external -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(shell date +%s)" |
| 216 |
|
| 217 |
cli-windows-server: cli-deps-static-sites |
| 218 |
# This is a target to build the CLI (including the server) for Windows. |
| 219 |
# Use this for Windows development, if you really don't want to install GoReleaser ... |
| 220 |
mkdir -p dist/ntfy_windows_server server/docs |
| 221 |
CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build \ |
| 222 |
-o dist/ntfy_windows_server/ntfy.exe \ |
| 223 |
-tags sqlite_omit_load_extension,osusergo,netgo \ |
| 224 |
-ldflags \ |
| 225 |
"-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(shell date +%s)" |
| 226 |
|
| 227 |
cli-client: cli-deps-static-sites |
| 228 |
# This is a target to build the CLI (excluding the server) manually. This should work on Linux/macOS/Windows. |
| 229 |
# Use this for development, if you really don't want to install GoReleaser ... |
| 230 |
mkdir -p dist/ntfy_client server/docs |
| 231 |
CGO_ENABLED=0 go build \ |
| 232 |
-o dist/ntfy_client/ntfy \ |
| 233 |
-tags noserver \ |
| 234 |
-ldflags \ |
| 235 |
"-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(shell date +%s)" |
| 236 |
|
| 237 |
cli-deps: cli-deps-static-sites cli-deps-all cli-deps-gcc |
| 238 |
|
| 239 |
cli-deps-gcc: cli-deps-gcc-armv6-armv7 cli-deps-gcc-arm64 cli-deps-gcc-windows |
| 240 |
|
| 241 |
cli-deps-static-sites: |
| 242 |
mkdir -p server/docs server/site |
| 243 |
touch server/docs/index.html server/site/app.html |
| 244 |
|
| 245 |
cli-deps-all: |
| 246 |
go install github.com/goreleaser/goreleaser/v2@latest |
| 247 |
|
| 248 |
cli-deps-gcc-armv6-armv7: |
| 249 |
which arm-linux-gnueabi-gcc || { echo "ERROR: ARMv6/ARMv7 cross compiler not installed. On Ubuntu, run: apt install gcc-arm-linux-gnueabi"; exit 1; } |
| 250 |
|
| 251 |
cli-deps-gcc-arm64: |
| 252 |
which aarch64-linux-gnu-gcc || { echo "ERROR: ARM64 cross compiler not installed. On Ubuntu, run: apt install gcc-aarch64-linux-gnu"; exit 1; } |
| 253 |
|
| 254 |
cli-deps-gcc-windows: |
| 255 |
which x86_64-w64-mingw32-gcc || { echo "ERROR: Windows cross compiler not installed. On Ubuntu, run: apt install gcc-mingw-w64-x86-64"; exit 1; } |
| 256 |
|
| 257 |
cli-deps-update: |
| 258 |
go get -u |
| 259 |
go mod tidy |
| 260 |
go install honnef.co/go/tools/cmd/staticcheck@latest |
| 261 |
go install golang.org/x/lint/golint@latest |
| 262 |
go install github.com/goreleaser/goreleaser/v2@latest |
| 263 |
|
| 264 |
cli-build-results: |
| 265 |
cat dist/config.yaml |
| 266 |
[ -f dist/artifacts.json ] && cat dist/artifacts.json | jq . || true |
| 267 |
[ -f dist/metadata.json ] && cat dist/metadata.json | jq . || true |
| 268 |
[ -f dist/checksums.txt ] && cat dist/checksums.txt || true |
| 269 |
find dist -maxdepth 2 -type f \ |
| 270 |
\( -name '*.deb' -or -name '*.rpm' -or -name '*.zip' -or -name '*.tar.gz' -or -name 'ntfy' \) \ |
| 271 |
-and -not -path 'dist/goreleaserdocker*' \ |
| 272 |
-exec sha256sum {} \; |
| 273 |
|
| 274 |
# Test/check targets |
| 275 |
|
| 276 |
check: test web-fmt-check fmt-check vet web-lint lint staticcheck template-check go-check |
| 277 |
|
| 278 |
checkv: testv web-fmt-check fmt-check vet web-lint lint staticcheck template-check go-check |
| 279 |
|
| 280 |
test: cli-test web-test |
| 281 |
|
| 282 |
testv: cli-testv web-test |
| 283 |
|
| 284 |
cli-test: FORCE |
| 285 |
go test $(shell go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -vE 'ntfy/v2/(test|examples|tools)') |
| 286 |
|
| 287 |
cli-testv: FORCE |
| 288 |
go test -v $(shell go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -vE 'ntfy/v2/(test|examples|tools)') |
| 289 |
|
| 290 |
race: FORCE |
| 291 |
go test -v -race $(shell go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -vE 'ntfy/v2/(test|examples|tools)') |
| 292 |
|
| 293 |
coverage: |
| 294 |
mkdir -p build/coverage |
| 295 |
go test -v -race -coverprofile=build/coverage/coverage.txt -covermode=atomic $(shell go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -vE 'ntfy/v2/(test|examples|tools|web)') |
| 296 |
go tool cover -func build/coverage/coverage.txt |
| 297 |
|
| 298 |
coverage-html: |
| 299 |
mkdir -p build/coverage |
| 300 |
go test -race -coverprofile=build/coverage/coverage.txt -covermode=atomic $(shell go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -vE 'ntfy/v2/(test|examples|tools)') |
| 301 |
go tool cover -html build/coverage/coverage.txt |
| 302 |
|
| 303 |
coverage-upload: |
| 304 |
cd build/coverage && (curl -s https://codecov.io/bash | bash) |
| 305 |
|
| 306 |
|
| 307 |
# Lint/formatting targets |
| 308 |
|
| 309 |
fmt: web-fmt |
| 310 |
gofmt -s -w . |
| 311 |
|
| 312 |
fmt-check: |
| 313 |
test -z $(shell gofmt -l .) |
| 314 |
|
| 315 |
vet: |
| 316 |
go vet ./... |
| 317 |
|
| 318 |
lint: |
| 319 |
which golint || go install golang.org/x/lint/golint@latest |
| 320 |
go list ./... | grep -v /vendor/ | grep -vE 'ntfy/v2/template/gotext' | xargs -L1 golint -set_exit_status |
| 321 |
|
| 322 |
staticcheck: FORCE |
| 323 |
rm -rf build/staticcheck |
| 324 |
which staticcheck || go install honnef.co/go/tools/cmd/staticcheck@latest |
| 325 |
mkdir -p build/staticcheck |
| 326 |
ln -s "go" build/staticcheck/go |
| 327 |
PATH="$(PWD)/build/staticcheck:$(PATH)" staticcheck $$(go list ./... | grep -vE 'ntfy/v2/template/gotext') |
| 328 |
rm -rf build/staticcheck |
| 329 |
|
| 330 |
|
| 331 |
# Vendored template targets (see template/README.md) |
| 332 |
|
| 333 |
TEMPLATE_GO_VERSION := go$(shell cat .go-version 2>/dev/null) |
| 334 |
|
| 335 |
update-template: |
| 336 |
@if [ "$$(go env GOVERSION)" != "$(TEMPLATE_GO_VERSION)" ]; then \ |
| 337 |
echo "ERROR: local Go $$(go env GOVERSION) != $(TEMPLATE_GO_VERSION) pinned in .go-version."; \ |
| 338 |
echo "Bump .go-version and install that toolchain first: go install golang.org/dl/$(TEMPLATE_GO_VERSION)@latest && $(TEMPLATE_GO_VERSION) download"; \ |
| 339 |
exit 1; \ |
| 340 |
fi |
| 341 |
src="$$(go env GOROOT)/src"; \ |
| 342 |
rm -f template/gotext/*.go template/gotext/fmtsort/*.go; \ |
| 343 |
for f in $$(go list -f '{{range .GoFiles}}{{.}} {{end}}' text/template); do cp "$$src/text/template/$$f" template/gotext/; done; \ |
| 344 |
for f in $$(go list -f '{{range .GoFiles}}{{.}} {{end}}' internal/fmtsort); do cp "$$src/internal/fmtsort/$$f" template/gotext/fmtsort/; done; \ |
| 345 |
sed -i 's/^package template$$/package gotext/' template/gotext/*.go; \ |
| 346 |
sed -i 's#"internal/fmtsort"#"heckel.io/ntfy/v2/template/gotext/fmtsort"#' template/gotext/*.go; \ |
| 347 |
( cd template/gotext && for p in patches/*.patch; do echo "Applying $$p"; git apply "$$p" || exit 1; done ) |
| 348 |
go env GOVERSION > template/gotext/GENERATED_FROM |
| 349 |
@echo "Regenerated template/gotext/ from $(TEMPLATE_GO_VERSION) (files enumerated via 'go list'); review with 'git diff'." |
| 350 |
|
| 351 |
template-check: FORCE |
| 352 |
@if [ "$$(cat template/gotext/GENERATED_FROM)" != "$(TEMPLATE_GO_VERSION)" ]; then \ |
| 353 |
echo "ERROR: template/gotext was generated from $$(cat template/gotext/GENERATED_FROM), but .go-version pins $(TEMPLATE_GO_VERSION). Run 'make update-template' on the pinned Go."; \ |
| 354 |
exit 1; \ |
| 355 |
fi |
| 356 |
@if [ "$$(go env GOVERSION)" != "$(TEMPLATE_GO_VERSION)" ]; then \ |
| 357 |
echo "SKIP: local Go $$(go env GOVERSION) != pinned $(TEMPLATE_GO_VERSION); skipping vendored template content check (version marker already verified)."; \ |
| 358 |
exit 0; \ |
| 359 |
fi |
| 360 |
@tmp=$$(mktemp -d); src="$$(go env GOROOT)/src"; \ |
| 361 |
mkdir -p "$$tmp/gotext/fmtsort"; \ |
| 362 |
for f in $$(go list -f '{{range .GoFiles}}{{.}} {{end}}' text/template); do cp "$$src/text/template/$$f" "$$tmp/gotext/"; done; \ |
| 363 |
for f in $$(go list -f '{{range .GoFiles}}{{.}} {{end}}' internal/fmtsort); do cp "$$src/internal/fmtsort/$$f" "$$tmp/gotext/fmtsort/"; done; \ |
| 364 |
sed -i 's/^package template$$/package gotext/' "$$tmp/gotext/"*.go; \ |
| 365 |
sed -i 's#"internal/fmtsort"#"heckel.io/ntfy/v2/template/gotext/fmtsort"#' "$$tmp/gotext/"*.go; \ |
| 366 |
cp template/gotext/patches/*.patch "$$tmp/"; \ |
| 367 |
( cd "$$tmp/gotext" && for p in "$$tmp"/*.patch; do git apply "$$p" || exit 1; done ); \ |
| 368 |
if diff -rq -x 'README.md' -x 'GENERATED_FROM' -x 'patches' "$$tmp/gotext" template/gotext >/dev/null 2>&1; then \ |
| 369 |
rm -rf "$$tmp"; \ |
| 370 |
else \ |
| 371 |
echo "ERROR: template/gotext/ drifted from GOROOT+patches (or its file set changed). Run 'make update-template' on Go $(TEMPLATE_GO_VERSION):"; \ |
| 372 |
diff -rq -x 'README.md' -x 'GENERATED_FROM' -x 'patches' "$$tmp/gotext" template/gotext; \ |
| 373 |
rm -rf "$$tmp"; exit 1; \ |
| 374 |
fi |
| 375 |
|
| 376 |
# go-check is advisory only (never fails): it warns when the pinned Go (.go-version) is behind the |
| 377 |
# latest upstream release, so template/gotext doesn't silently fall behind on text/template fixes. |
| 378 |
go-check: FORCE |
| 379 |
@latest=$$(curl -s --max-time 10 'https://go.dev/VERSION?m=text' 2>/dev/null | head -1); \ |
| 380 |
if [ -n "$$latest" ] && [ "$$latest" != "$(TEMPLATE_GO_VERSION)" ]; then \ |
| 381 |
echo ""; \ |
| 382 |
echo "note: latest Go is $$latest, but template/gotext is pinned to $(TEMPLATE_GO_VERSION) (.go-version)."; \ |
| 383 |
echo " to bump: install $$latest, set .go-version to $${latest#go}, then run 'make update-template'."; \ |
| 384 |
fi |
| 385 |
|
| 386 |
|
| 387 |
# Releasing targets |
| 388 |
|
| 389 |
release: clean cli-deps release-checks docs web check |
| 390 |
goreleaser release --clean |
| 391 |
|
| 392 |
release-snapshot: clean cli-deps docs web check |
| 393 |
goreleaser release --snapshot --clean |
| 394 |
|
| 395 |
release-checks: |
| 396 |
$(eval LATEST_TAG := $(shell git describe --abbrev=0 --tags | cut -c2-)) |
| 397 |
if [ "$$(go env GOVERSION)" != "go$$(cat .go-version)" ]; then\ |
| 398 |
echo "ERROR: releases must use the pinned Go toolchain (go$$(cat .go-version) from .go-version), but this is $$(go env GOVERSION). This also ensures 'make check' enforces (not skips) the template/gotext drift check.";\ |
| 399 |
exit 1;\ |
| 400 |
fi |
| 401 |
if ! grep -q $(LATEST_TAG) docs/install.md; then\ |
| 402 |
echo "ERROR: Must update docs/install.md with latest tag first.";\ |
| 403 |
exit 1;\ |
| 404 |
fi |
| 405 |
if ! grep -q $(LATEST_TAG) docs/releases.md; then\ |
| 406 |
echo "ERROR: Must update docs/releases.md with latest tag first.";\ |
| 407 |
exit 1;\ |
| 408 |
fi |
| 409 |
if [ -n "$(shell git status -s)" ]; then\ |
| 410 |
echo "ERROR: Git repository is in an unclean state.";\ |
| 411 |
exit 1;\ |
| 412 |
fi |
| 413 |
|
| 414 |
|
| 415 |
# Installing targets |
| 416 |
|
| 417 |
install-linux-amd64: remove-binary |
| 418 |
sudo cp -a dist/ntfy_linux_amd64_linux_amd64_v1/ntfy /usr/bin/ntfy |
| 419 |
|
| 420 |
install-linux-armv6: remove-binary |
| 421 |
sudo cp -a dist/ntfy_linux_armv6_linux_arm_6/ntfy /usr/bin/ntfy |
| 422 |
|
| 423 |
install-linux-armv7: remove-binary |
| 424 |
sudo cp -a dist/ntfy_linux_armv7_linux_arm_7/ntfy /usr/bin/ntfy |
| 425 |
|
| 426 |
install-linux-arm64: remove-binary |
| 427 |
sudo cp -a dist/ntfy_linux_arm64_linux_arm64/ntfy /usr/bin/ntfy |
| 428 |
|
| 429 |
remove-binary: |
| 430 |
sudo rm -f /usr/bin/ntfy |
| 431 |
|
| 432 |
install-linux-amd64-deb: purge-package |
| 433 |
sudo dpkg -i dist/ntfy_*_linux_amd64.deb |
| 434 |
|
| 435 |
install-linux-armv6-deb: purge-package |
| 436 |
sudo dpkg -i dist/ntfy_*_linux_armv6.deb |
| 437 |
|
| 438 |
install-linux-armv7-deb: purge-package |
| 439 |
sudo dpkg -i dist/ntfy_*_linux_armv7.deb |
| 440 |
|
| 441 |
install-linux-arm64-deb: purge-package |
| 442 |
sudo dpkg -i dist/ntfy_*_linux_arm64.deb |
| 443 |
|
| 444 |
purge-package: |
| 445 |
sudo systemctl stop ntfy || true |
| 446 |
sudo apt-get purge ntfy || true |