-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (91 loc) · 3.44 KB
/
Makefile
File metadata and controls
109 lines (91 loc) · 3.44 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
.EXPORT_ALL_VARIABLES:
GO111MODULE ?= on
LOCALS := $(shell find . -type f -name '*.go' -not -name favicon.go)
BIN ?= diecast-$(shell go env GOOS)-$(shell go env GOARCH)
VERSION = $(shell grep 'const ApplicationVersion' version.go | cut -d= -f2 | tr -d '`' | tr -d ' ')
CGO_ENABLED ?= 0
all: deps build test docs
deps:
go get ./...
fmt: gofmt
go mod tidy
go vet ./...
go generate ./...
gofmt: $(LOCALS)
$(LOCALS):
@gofmt -s -w $(@)
test:
go test -count=1 ./...
favicon.go:
@convert -background transparent -define icon:auto-resize=16 contrib/diecast-ico-source.svg contrib/favicon.ico
@echo 'package diecast' > favicon.go
@echo '' >> favicon.go
@echo 'func DefaultFavicon() []byte {' >> favicon.go
@echo ' // autogenerated from github.com/ghetzel/diecast:contrib/favicon.ico' >> favicon.go
@echo ' return []byte{' >> favicon.go
@hexdump -v -e '8/1 "0x%02x, " "\n"' contrib/favicon.ico | sed -e 's/0x ,//g' >> favicon.go
@echo ' }' >> favicon.go
@echo '}' >> favicon.go
@echo '' >> favicon.go
@gofmt -w favicon.go
build: fmt
go build --ldflags '-extldflags "-static"' -installsuffix cgo -ldflags '-s' -o bin/$(BIN) cmd/diecast/main.go
which diecast && cp -v bin/$(BIN) $(shell which diecast) || true
which codesign && codesign --sign - --force --preserve-metadata=entitlements,requirements,flags,runtime $(shell which diecast)
docs:
@true
# @test -d docs || mkdir docs
# @cd docs && make
package:
-rm -rf pkg
mkdir -p pkg/usr/bin
cp bin/$(BIN) pkg/usr/bin/diecast
fpm \
--input-type dir \
--output-type deb \
--deb-user root \
--deb-group root \
--name diecast \
--version `./pkg/usr/bin/diecast -v | cut -d' ' -f3` \
-C pkg
clients.csr:
openssl req -new -newkey rsa:4096 -nodes -keyout clients.key -out clients.csr -subj '/O=ghetzel/CN=diecast'
clients.crt: clients.csr
openssl x509 -req -days 3650 -in clients.csr -signkey clients.key -out clients.crt
sign-client: clients.crt
test -n "$(NAME)" || $(error NAME (client name) is not set)
# Generate new client private key and signing request (CSR)
openssl req \
-new \
-nodes \
-keyout $(NAME).key \
-out $(NAME).csr \
-days 3650 \
-subj '/O=diecast/CN=$(NAME)' \
-extensions v3_req
# Sign client certificate with clients CA
openssl x509 \
-req \
-days 3650 \
-in $(NAME).csr \
-CA clients.crt \
-CAkey clients.key \
-CAcreateserial \
-out $(NAME).crt \
-extensions v3_req
# Also generate a PKCS#12 encoded bundle of the newly generated cert+key
openssl pkcs12 \
-export \
-in $(NAME).crt \
-inkey $(NAME).key \
-out $(NAME).p12
docker-build:
docker build --no-cache -t ghetzel/diecast:build -f Dockerfile.build .
docker run --rm -it -v ${PWD}:/project -v ${HOME}/pkg:/go/pkg -v ${HOME}/src:/go/src ghetzel/diecast:build
docker:
@echo "Building Docker image for v$(VERSION)"
docker build -t ghetzel/diecast:$(VERSION) .
docker tag ghetzel/diecast:$(VERSION) ghetzel/diecast:latest
docker push ghetzel/diecast:$(VERSION)
docker push ghetzel/diecast:latest
.PHONY: test deps docs build $(LOCALS)