summaryrefslogtreecommitdiff
path: root/Makefile
blob: e221cd8f63343da74e262c70bdac0156a6c68bb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Makefile

#/***************************************************************************
# *   Copyright (C) 2017-2019 The Nitrocli Developers                       *
# *                                                                         *
# *   This program is free software: you can redistribute it and/or modify  *
# *   it under the terms of the GNU General Public License as published by  *
# *   the Free Software Foundation, either version 3 of the License, or     *
# *   (at your option) any later version.                                   *
# *                                                                         *
# *   This program is distributed in the hope that it will be useful,       *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
# *   GNU General Public License for more details.                          *
# *                                                                         *
# *   You should have received a copy of the GNU General Public License     *
# *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
# ***************************************************************************/

SHELL := bash

PS2PDF ?= ps2pdf

NITROCLI_MAN := doc/nitrocli.1
NITROCLI_PDF := $(addsuffix .pdf,$(NITROCLI_MAN))

.PHONY: doc
doc: $(NITROCLI_PDF) $(NITROCLI_HTML)

# We assume and do not check existence of man, which, false, and echo
# commands.
$(NITROCLI_PDF): $(NITROCLI_MAN)
	@which $(PS2PDF) &> /dev/null || \
		(echo "$(PS2PDF) command not found, unable to generate documentation"; false)
	@man --local-file --troff $(<) | $(PS2PDF) - $(@)

KEY ?= 0x952DD6F8F34D8B8E

.PHONY: sign
sign:
	@test -n "$(REL)" || \
		(echo "Please set REL environment variable to the release to verify (e.g., '0.2.1')."; false)
	@mkdir -p pkg/
	wget --quiet "https://github.com/d-e-s-o/nitrocli/archive/v$(REL).zip" \
		-O "pkg/nitrocli-$(REL).zip"
	@set -euo pipefail && DIR1=$$(mktemp -d) && DIR2=$$(mktemp -d) && \
		unzip -q pkg/nitrocli-$(REL).zip -d $${DIR1} && \
		git -C $$(git rev-parse --show-toplevel) archive --prefix=nitrocli-$(REL)/ v$(REL) | \
			tar -x -C $${DIR2} && \
		diff -u -r $${DIR1} $${DIR2} && \
		echo "Github zip archive verified successfully" && \
		(rm -r $${DIR1} && rm -r $${DIR2})
	wget --quiet "https://github.com/d-e-s-o/nitrocli/archive/v$(REL).tar.gz" \
		-O "pkg/nitrocli-$(REL).tar.gz"
	@set -euo pipefail && DIR1=$$(mktemp -d) && DIR2=$$(mktemp -d) && \
		tar -xz -C $${DIR1} -f pkg/nitrocli-$(REL).tar.gz && \
		git -C $$(git rev-parse --show-toplevel) archive --prefix=nitrocli-$(REL)/ v$(REL) | \
			tar -x -C $${DIR2} && \
		diff -u -r $${DIR1} $${DIR2} && \
		echo "Github tarball verified successfully" && \
		(rm -r $${DIR1} && rm -r $${DIR2})
	@cd pkg && sha256sum nitrocli-$(REL).tar.gz nitrocli-$(REL).zip > nitrocli-$(REL).sha256.DIGEST
	@gpg --sign --armor --detach-sign --default-key=$(KEY) --yes \
		--output pkg/nitrocli-$(REL).sha256.DIGEST.sig pkg/nitrocli-$(REL).sha256.DIGEST
	@gpg --verify pkg/nitrocli-$(REL).sha256.DIGEST.sig
	@cd pkg && sha256sum --check < nitrocli-$(REL).sha256.DIGEST
	@echo "All checks successful. Please attach"
	@echo "  pkg/nitrocli-$(REL).sha256.DIGEST"
	@echo "  pkg/nitrocli-$(REL).sha256.DIGEST.sig"
	@echo "to https://github.com/d-e-s-o/nitrocli/releases/tag/v$(REL)"