-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (65 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
70
71
72
73
74
75
76
77
BIN := bsctl
ifeq ($(OS),Windows_NT)
BIN := $(BIN).exe
endif
VERSION := $$(make -s show-version)
CURRENT_REVISION := $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS := "-s -w -X main.revision=$(CURRENT_REVISION)"
GOOS := $(shell go env GOOS)
GOBIN ?= $(shell go env GOPATH)/bin
export GO111MODULE=on
GIT_SHA := $(shell git rev-parse HEAD)
GIT_SHA_SHORT := $(shell git rev-parse --short HEAD)
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
VERSION := $(shell git describe --tags)-$(GIT_SHA_SHORT)
LDFLAGS := -s -w \
-X 'github.com/jlewi/bsctl/pkg/version.Date=$(DATE)' \
-X 'github.com/jlewi/bsctl/pkg/version.Version=$(subst v,,$(VERSION))' \
-X 'github.com/jlewi/bsctl/pkg/version.Commit=$(GIT_SHA)' \
-X 'github.com/jlewi/bsctl/pkg/version.BuiltBy=$(GIT_SHA)'
.PHONY: all
all: clean build
.PHONY: build
build:
mkdir -p .build
go build -ldflags="$(LDFLAGS)" -o .build/$(BIN) .
.PHONY: pwa
pwa:
GOOS=js GOARCH=wasm go build -o web/app.wasm -ldflags="$(LDFLAGS)" ./pwa
go build -o .build/pwa-server -ldflags="$(LDFLAGS)" ./pwa
# Build a static website
.PHONY: pwa
static:
GOOS=js GOARCH=wasm go build -o .build/static/web/app.wasm -ldflags="$(LDFLAGS)" ./pwa
BUILD_STATIC=.build/static go run ./pwa
.PHONY: release
release:
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) .
zip -r bsky-$(GOOS)-$(VERSION).zip $(BIN)
.PHONY: install
install:
go install -ldflags=$(BUILD_LDFLAGS) .
.PHONY: show-version
show-version: $(GOBIN)/gobump
gobump show -r .
$(GOBIN)/gobump:
go install github.com/x-motemen/gobump/cmd/gobump@latest
.PHONY: test
test: build
go test -v ./...
.PHONY: clean
clean:
go clean
.PHONY: bump
bump: $(GOBIN)/gobump
ifneq ($(shell git status --porcelain),)
$(error git workspace is dirty)
endif
ifneq ($(shell git rev-parse --abbrev-ref HEAD),main)
$(error current branch is not main)
endif
@gobump up -w .
git commit -am "bump up version to $(VERSION)"
git tag "v$(VERSION)"
git push origin main
git push origin "refs/tags/v$(VERSION)"