-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (44 loc) · 2.15 KB
/
Makefile
File metadata and controls
55 lines (44 loc) · 2.15 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
VERSION ?= dev
BUILD_DIR = build
.PHONY: all
all: build
.PHONY: build
build:
go build -o dnote-pg2sqlite
.PHONY: test
test:
go test -v
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
rm -f dnote-pg2sqlite
.PHONY: release
release: clean
ifndef VERSION
$(error VERSION is required. Usage: make VERSION=1.0.0 release)
endif
@echo "==> Building binaries for version $(VERSION)"
@mkdir -p $(BUILD_DIR)
# Linux AMD64
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o $(BUILD_DIR)/dnote-pg2sqlite-linux-amd64
cd $(BUILD_DIR) && tar -czf dnote-pg2sqlite-$(VERSION)-linux-amd64.tar.gz dnote-pg2sqlite-linux-amd64
cd $(BUILD_DIR) && shasum -a 256 dnote-pg2sqlite-$(VERSION)-linux-amd64.tar.gz >> checksums.txt
# Linux ARM64
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=$(VERSION)" -o $(BUILD_DIR)/dnote-pg2sqlite-linux-arm64
cd $(BUILD_DIR) && tar -czf dnote-pg2sqlite-$(VERSION)-linux-arm64.tar.gz dnote-pg2sqlite-linux-arm64
cd $(BUILD_DIR) && shasum -a 256 dnote-pg2sqlite-$(VERSION)-linux-arm64.tar.gz >> checksums.txt
# macOS AMD64 (Intel)
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o $(BUILD_DIR)/dnote-pg2sqlite-darwin-amd64
cd $(BUILD_DIR) && tar -czf dnote-pg2sqlite-$(VERSION)-darwin-amd64.tar.gz dnote-pg2sqlite-darwin-amd64
cd $(BUILD_DIR) && shasum -a 256 dnote-pg2sqlite-$(VERSION)-darwin-amd64.tar.gz >> checksums.txt
# macOS ARM64 (M1/M2)
GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.version=$(VERSION)" -o $(BUILD_DIR)/dnote-pg2sqlite-darwin-arm64
cd $(BUILD_DIR) && tar -czf dnote-pg2sqlite-$(VERSION)-darwin-arm64.tar.gz dnote-pg2sqlite-darwin-arm64
cd $(BUILD_DIR) && shasum -a 256 dnote-pg2sqlite-$(VERSION)-darwin-arm64.tar.gz >> checksums.txt
# Windows AMD64
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o $(BUILD_DIR)/dnote-pg2sqlite-windows-amd64.exe
cd $(BUILD_DIR) && zip dnote-pg2sqlite-$(VERSION)-windows-amd64.zip dnote-pg2sqlite-windows-amd64.exe
cd $(BUILD_DIR) && shasum -a 256 dnote-pg2sqlite-$(VERSION)-windows-amd64.zip >> checksums.txt
@echo "==> Binaries built in $(BUILD_DIR)/"
@echo "==> Checksums:"
@cat $(BUILD_DIR)/checksums.txt