This repository has been archived by the owner on Jul 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
76 lines (61 loc) · 2.19 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
70
71
72
73
74
75
76
-include .env.local
VERSION="v1.0.3"
ifeq "$(shell git status --porcelain=v1 2>/dev/null)" ""
GIT_REVISION=$(shell git rev-parse --short HEAD)
BUILD_TIME=$(shell git show -s --format=%ci HEAD)
else
GIT_REVISION="$(shell git rev-parse --short HEAD)-devel"
BUILD_TIME=$(shell date)
endif
# get the current OS and arch
OS=$(shell GOOS= go env GOOS)
ARCH=$(shell GOARCH= go env GOARCH)
# get the target OS and arch
GOOS?=$(shell go env GOOS)
GOARCH?=$(shell go env GOARCH)
all: release
lint-web:
cd web && \
npm run lint -- --fix
lint-daemon:
golangci-lint run
lint: lint-web lint-daemon
install-dependencies:
cd web && \
npm i
build-web: install-dependencies
cd web && \
rm -rf dist && \
npm run build
run: build-web
go run ./dashboard --data-path ./data
static:
CGO_ENABLED=0 go build -trimpath -ldflags="-X 'github.com/siacentral/sia-host-dashboard/dashboard/build.version=${VERSION}' -X 'github.com/siacentral/sia-host-dashboard/dashboard/build.gitRevision=${GIT_REVISION}' -X 'github.com/siacentral/sia-host-dashboard/dashboard/build.buildTime=${BUILD_TIME}' -s -w" -tags='netgo timetzdata' -o ./bin/ ./dashboard
package: static
mkdir -p dist
@if [ "${GOOS}" = "darwin" ] && [ "${OS}" != "darwin" ]; then \
echo "darwin must be packaged on macOS"; \
elif [ "${GOOS}" = "darwin" ] && [ "${OS}" = "darwin" ]; then \
codesign --deep -s $(APPLE_CERT_ID) -o runtime bin/dashboard; \
ditto -ck bin dist/host_dashboard_$(VERSION)_$(GOOS)_$(GOARCH).zip; \
xcrun altool --notarize-app --primary-bundle-id com.siacentral.sia-host-dashboard --apiKey $(APPLE_API_KEY) --apiIssuer $(APPLE_API_ISSUER) --file dist/host_dashboard_$(VERSION)_$(GOOS)_$(GOARCH).zip; \
rm -rf bin; \
else \
zip -qj dist/host_dashboard_$(VERSION)_$(GOOS)_$(GOARCH).zip bin/*; \
rm -rf bin; \
fi
# must be run on macOS
apple-notarize-status:
@if [ "${OS}" = "darwin" ]; then \
xcrun altool --notarization-info $(APPLE_NOTARIZE_UUID) --apiKey $(APPLE_API_KEY) --apiIssuer $(APPLE_API_ISSUER); \
else \
echo "Notarization is only supported on macOS"; \
fi
release: build-web
rm -rf bin dist
@for OS in linux darwin windows; do \
for ARCH in amd64 arm64; do \
GOOS=$$OS GOARCH=$$ARCH make package; \
done; \
done
rm -rf bin