forked from dfinity/keysmith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (55 loc) · 1.96 KB
/
Makefile
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
MAJOR ?= 1
MINOR ?= 4
PATCH ?= 0
LDFLAGS := -X=main.MAJOR=$(MAJOR)
LDFLAGS += -X=main.MINOR=$(MINOR)
LDFLAGS += -X=main.PATCH=$(PATCH)
PRIVATE_KEY ?= $(HOME)/.openssl/private.key
.PHONY: all
all: build
.PHONY: build
build:
$(eval BUILD ?= $(shell git describe --always --dirty))
$(eval LDFLAGS += -X=main.BUILD=$(BUILD))
$(eval GOFLAGS := -ldflags="$(LDFLAGS)")
go build $(GOFLAGS)
.PHONY: release
release:
$(eval BUILD ?= release)
$(eval LDFLAGS += -X=main.BUILD=$(BUILD))
$(eval GOFLAGS := -ldflags="$(LDFLAGS)")
# Create release directory.
mkdir -p release
# Create checksum file.
> SHA256.SUM
# Create release for darwin/amd64.
GOOS=darwin GOARCH=amd64 go build $(GOFLAGS)
tar -c -f keysmith-darwin-amd64.tar.gz -z keysmith
openssl dgst -sha256 keysmith-darwin-amd64.tar.gz >> SHA256.SUM
mv keysmith-darwin-amd64.tar.gz release
# Create release for darwin/arm64.
GOOS=darwin GOARCH=arm64 go build $(GOFLAGS)
tar -c -f keysmith-darwin-arm64.tar.gz -z keysmith
openssl dgst -sha256 keysmith-darwin-arm64.tar.gz >> SHA256.SUM
mv keysmith-darwin-arm64.tar.gz release
# Create release for linux/amd64.
GOOS=linux GOARCH=amd64 go build $(GOFLAGS)
tar -c -f keysmith-linux-amd64.tar.gz -z keysmith
openssl dgst -sha256 keysmith-linux-amd64.tar.gz >> SHA256.SUM
mv keysmith-linux-amd64.tar.gz release
# Create release for linux/arm64.
GOOS=linux GOARCH=arm64 go build $(GOFLAGS)
tar -c -f keysmith-linux-arm64.tar.gz -z keysmith
openssl dgst -sha256 keysmith-linux-arm64.tar.gz >> SHA256.SUM
mv keysmith-linux-arm64.tar.gz release
# Create release for windows/amd64.
GOOS=windows GOARCH=amd64 go build $(GOFLAGS)
tar -c -f keysmith-windows-amd64.tar.gz -z keysmith.exe
openssl dgst -sha256 keysmith-windows-amd64.tar.gz >> SHA256.SUM
mv keysmith-windows-amd64.tar.gz release
# Sign release binaries.
openssl dgst -out SHA256.SIG -sha256 -sign $(PRIVATE_KEY) SHA256.SUM
mv SHA256.SIG SHA256.SUM release
.PHONY: clean
clean:
rm -f -r keysmith keysmith.exe release