-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
44 lines (38 loc) · 1.34 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
version := $(shell git describe --dirty=-changes)
build := $(shell git rev-parse HEAD)
build_date := $(shell date +"%Y-%m-%dT%H:%M:%S%z")
.PHONY: proto
proto:
buf generate
.PHONY: ui
ui: proto
cd ui && npm i
go generate ui/static.go
.PHONY: bin
bin: proto
go build -o shrls -ldflags="\
-X github.com/demophoon/shrls/pkg/version.Version=${version}-dev \
-X github.com/demophoon/shrls/pkg/version.Build=${build} \
-X github.com/demophoon/shrls/pkg/version.BuildDate=${build_date} \
" cmd/shrls/main.go
.PHONY: dist
dist: ui
CGO_ENABLED=0 GOOS=linux go build -o shrls -ldflags="\
-s -w \
-X github.com/demophoon/shrls/pkg/version.Version=${version} \
-X github.com/demophoon/shrls/pkg/version.Build=${build} \
-X github.com/demophoon/shrls/pkg/version.BuildDate=${build_date} \
" cmd/shrls/main.go
.PHONY: docker
docker:
docker build . \
--label "org.opencontainers.image.source=https://github.com/demophoon/shrls" \
--label "org.opencontainers.image.description=Simple and small url shortener" \
--label "org.opencontainers.image.licenses=Apache-2.0" \
--label "org.opencontainers.image.version=${version}" \
--label "org.opencontainers.image.ref.name=${build}" \
--label "org.opencontainers.image.created=${build_date}" \
-t ghcr.io/demophoon/shrls:${version}
.PHONY: publish
publish:
docker push ghcr.io/demophoon/shrls:${version}