aboutsummaryrefslogtreecommitdiff
path: root/macos/Makefile
blob: 216ccbee5805b0d16c9190c13c60827f49d30c34 (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
ARCHITECTURE=$(shell cat architecture.txt)
VERSION=$(shell cat version.txt)
BASE=pandoc-$(VERSION)-$(ARCHITECTURE)
DEST=pandoc/usr/local
ALL=$(BASE)-macOS.pkg $(BASE)-macOS.zip

all: $(ALL) notarize

signed.txt: $(DEST)
	chmod +x $(DEST)/bin/pandoc
	codesign --force --options runtime -s "5U2WKE6DES" $(DEST)/bin/pandoc
	echo "SIGNED" > signed.txt

$(DEST)/bin/pandoc-server:
	cd $(DEST)/bin && ln -s pandoc pandoc-server

$(DEST)/bin/pandoc-lua:
	cd $(DEST)/bin && ln -s pandoc pandoc-lua

pandoc.pkg: $(DEST)/bin/pandoc-server $(DEST)/bin/pandoc-lua signed.txt
	pkgbuild --root pandoc --identifier net.johnmacfarlane.pandoc --version $(VERSION) --ownership recommended $@

$(BASE)-macOS.pkg: pandoc.pkg
	productbuild --distribution distribution.xml --resources Resources --package-path $< --version $(VERSION) --sign 'Developer ID Installer: John Macfarlane' $@

$(BASE)-macOS.zip: $(DEST)/bin/pandoc-server $(DEST)/bin/pandoc-lua signed.txt
	mv $(DEST) $(BASE)
	zip --symlinks -r $@ $(BASE)

# gon.hcl: version.txt
# 	echo "notarize {\n  path = \"$(BASE)-macOS.pkg\"\n  bundle_id = \"org.pandoc.pandoc\"\n  staple = true\n}\napple_id {\n  username = \"[email protected]\"\n  password = \"@env:AC_PASSWORD\"\n}" > $@

#notarize: gon.hcl $(BASE)-macOS.pkg
#	gon -log-level=warn ./gon.hcl

notarize: $(BASE)-macOS.pkg
	xcrun notarytool submit $< --keychain-profile=pandoc --wait && \
    xcrun stapler staple $<

clean:
	rm signed.txt $(BASE) pandoc.pkg # gon.hcl

distclean: clean
	rm $(ALL)

.PHONY: all clean distclean