Skip to content

Commit

Permalink
Adding Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Malusev <malusevd99@gmail.com>
  • Loading branch information
Dusan Malusev committed Jan 29, 2021
1 parent a85e799 commit 3f3fca3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
.idea/
.vscode/
bin/
coverage.txt
43 changes: 43 additions & 0 deletions Makefile
@@ -0,0 +1,43 @@
GOPATH ?= ${HOME}/go
RACE ?= 0
ENVIRONMENT ?= development
VERSION ?= dev

.PHONY: all
all: clean test build

.PHONY: test
test:
ifeq ($(RACE), 1)
go test ./... -race -covermode=atomic -coverprofile=coverage.txt -timeout 5m
else
go test ./... -covermode=atomic -coverprofile=coverage.txt -timeout 1m
endif

.PHONY: build
build:
ifeq ($(ENVIRONMENT),production)
CGO_ENABLED=0 go build -ldflags="-s -w -X 'main.Version=${VERSION}'" -o ./bin/hosts cmd/hosts/main.go
else ifeq ($(ENVIRONMENT),development)
go build -o ./bin/hosts cmd/hosts/main.go
else
echo "Target ${ENVIRONMENT} is not supported"
endif

.PHONY: git-setup
git-setup:
git config user.name GitHub
git config user.email noreply@github.com
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/malusev998/dusanmalusev.git

.PHONY: commit
commit:
git add .
ifneq ($(shell git status --porcelain),)
git commit --author "github-actions[bot] <github-actions[bot]@users.noreply.github.com>" --message "${MESSAGE}"
git push
endif

.PHONY: clean
clean:
rm -rf ./bin

0 comments on commit 3f3fca3

Please sign in to comment.