Skip to content

Commit 3f3fca3

Browse files
author
Dusan Malusev
committed
Adding Makefile
Signed-off-by: Dusan Malusev <[email protected]>
1 parent a85e799 commit 3f3fca3

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.idea/
22
.vscode/
3+
bin/
4+
coverage.txt

Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
GOPATH ?= ${HOME}/go
2+
RACE ?= 0
3+
ENVIRONMENT ?= development
4+
VERSION ?= dev
5+
6+
.PHONY: all
7+
all: clean test build
8+
9+
.PHONY: test
10+
test:
11+
ifeq ($(RACE), 1)
12+
go test ./... -race -covermode=atomic -coverprofile=coverage.txt -timeout 5m
13+
else
14+
go test ./... -covermode=atomic -coverprofile=coverage.txt -timeout 1m
15+
endif
16+
17+
.PHONY: build
18+
build:
19+
ifeq ($(ENVIRONMENT),production)
20+
CGO_ENABLED=0 go build -ldflags="-s -w -X 'main.Version=${VERSION}'" -o ./bin/hosts cmd/hosts/main.go
21+
else ifeq ($(ENVIRONMENT),development)
22+
go build -o ./bin/hosts cmd/hosts/main.go
23+
else
24+
echo "Target ${ENVIRONMENT} is not supported"
25+
endif
26+
27+
.PHONY: git-setup
28+
git-setup:
29+
git config user.name GitHub
30+
git config user.email [email protected]
31+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/malusev998/dusanmalusev.git
32+
33+
.PHONY: commit
34+
commit:
35+
git add .
36+
ifneq ($(shell git status --porcelain),)
37+
git commit --author "github-actions[bot] <github-actions[bot]@users.noreply.github.com>" --message "${MESSAGE}"
38+
git push
39+
endif
40+
41+
.PHONY: clean
42+
clean:
43+
rm -rf ./bin

0 commit comments

Comments
 (0)