birdbot/Makefile

94 lines
2.1 KiB
Makefile
Raw Normal View History

2022-10-27 03:55:23 +02:00
PROJECTNAME="Bird Bot"
PROJECT_BIN="birdbot"
VERSION="DEV"
2022-10-30 05:06:39 +01:00
BUILD_NUMBER:=$(shell git rev-parse --short HEAD)
2022-10-27 03:55:23 +02:00
# Go related variables.
2022-10-27 04:24:19 +02:00
GOBASE=$(shell pwd)
GOBIN=$(GOBASE)/build
2022-10-27 03:55:23 +02:00
GOFILES=$(wildcard *.go)
# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent
go-full-build: go-clean go-get go-build
go-build:
@echo " > Building binary..."
@mkdir -p $(GOBIN)
@GOOS=linux CGO_ENABLED=1 go build -ldflags "-X github.com/yeslayla/birdbot/app.Version=$(VERSION) -X github.com/yeslayla/birdbot/app.Build=$(BUILD_NUMBER)" -o $(GOBIN)/$(PROJECT_BIN) $(GOFILES)
2022-10-27 03:55:23 +02:00
@chmod 755 $(GOBIN)/$(PROJECT_BIN)
go-generate:
@echo " > Generating dependency files..."
@go generate $(generate)
go-get:
@echo " > Checking if there is any missing dependencies..."
@go get $(get)
go-get-upgrade:
@echo " > Updating dependencies..."
@go get $(get) -u
2022-10-27 03:55:23 +02:00
go-install:
@echo " > Running go install..."
@go install $(GOFILES)
go-clean:
@echo " > Cleaning build cache"
@go clean
go-test: clean
@echo " > Running tests..."
@go test -coverprofile=coverage.out ./*/
go-run:
@echo " > Running ${PROJECTNAME}"
@-(cd $(GOBIN); ./$(PROJECT_BIN))
docker-build:
@docker build . -t yeslayla/birdbot:latest
docker-run: docker-build
@docker run -it -v `pwd`/build:/etc/birdbot yeslayla/birdbot:latest
2022-10-27 05:17:34 +02:00
docker-push: docker-build
@docker push yeslayla/birdbot:latest
2022-10-27 03:55:23 +02:00
## install: Download and install dependencies
install: go-get
## upgrade: Update Go packages
upgrade: go-get-upgrade
2022-10-27 03:55:23 +02:00
# clean: Runs go clean
clean: go-clean
## full-build: cleans project, installs dependencies, and builds project
full-build: go-full-build
## build: Runs go build
build: go-build
## package: Builds lambda zip
package: go-full-build
@echo " > Zipping package..."
@cd $(GOBIN) && zip $(PROJECTNAME).zip $(PROJECTNAME)
## clean: Runs go clean
clean:
@rm -rf build
## run: full-builds and executes project binary
run: go-build go-run
## test: Run unit tests
test: go-test
## help: Displays help text for make commands
.DEFAULT_GOAL := help
all: help
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'