-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
59 lines (47 loc) · 1.77 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
.PHONY: all test build yarn air docker go-build go-alpine-build run-air run-air-alone
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
AIRCMD=~/go/bin/air
TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell git log -1 --format=%cd --date=iso)
VERSION := $(TAG:v%=%)
ifneq ($(COMMIT), $(TAG_COMMIT))
VERSION := 0.0.0-dev
endif
ifeq ($(VERSION),)
VERSION := $(COMMIT)-$(DATE)
endif
ifneq ($(shell git status --porcelain),)
VERSION := $(VERSION)-dirty
endif
GOBUILD_FLAGS=-ldflags="-X 'github.com/sonatype-nexus-community/the-cla/buildversion.BuildVersion=$(VERSION)' \
-X 'github.com/sonatype-nexus-community/the-cla/buildversion.BuildTime=$(DATE)' \
-X 'github.com/sonatype-nexus-community/the-cla/buildversion.BuildCommit=$(COMMIT)'"
all: test
docker:
yarn version --patch
docker build -t the-cla .
docker image prune --force --filter label=stage=builder
build: yarn go-build
yarn:
corepack yarn && NODE_OPTIONS=--openssl-legacy-provider corepack yarn build
# && corepack yarn version --new-version $(VERSION)
go-build:
echo "VERSION: $(VERSION)"
echo "DATE: $(DATE)"
echo "COMMIT: $(COMMIT)"
$(GOBUILD) -o the-cla $(GOBUILD_FLAGS) ./server.go
go-alpine-build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o the-cla $(GOBUILD_FLAGS) ./server.go
air: yarn
$(GOBUILD) -o ./tmp/the-cla $(GOBUILD_FLAGS) ./server.go
run-air: air
docker run --name the_cla_postgres -p 55432:5432 -e POSTGRES_PASSWORD=the_cla -e POSTGRES_DB=db -d postgres
$(AIRCMD) -c .air.toml && docker stop the_cla_postgres && docker rm the_cla_postgres
run-air-alone: yarn
$(AIRCMD) -c .air.toml
test: build
$(GOTEST) -v ./... 2>&1