Create a Makefile, delete do script

This commit is contained in:
Matthias Loibl 2016-12-25 16:33:09 +01:00
parent 5824435243
commit c7c30e25f2
No known key found for this signature in database
GPG Key ID: B1C7DF661ABB2C1A
2 changed files with 58 additions and 25 deletions

58
Makefile Normal file
View File

@ -0,0 +1,58 @@
DIST := dist
EXECUTABLE := ana
IMPORT := github.com/dannyvankooten/ana
LDFLAGS += -extldflags "-static" -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')"
TARGETS ?= linux/*,darwin/*,windows/*
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)
ENV ?= $(shell export $(cat .env | xargs))
.PHONY: all
all: build
.PHONY: clean
clean:
go clean -i ./...
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA)
.PHONY: fmt
fmt:
go fmt $(PACKAGES)
.PHONY: vet
vet:
go vet $(PACKAGES)
.PHONY: errcheck
errcheck:
@which errcheck > /dev/null; if [ $$? -ne 0 ]; then \
go get -u github.com/kisielk/errcheck; \
fi
errcheck $(PACKAGES)
.PHONY: lint
lint:
@which golint > /dev/null; if [ $$? -ne 0 ]; then \
go get -u github.com/golang/lint/golint; \
fi
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
.PHONY: test
test:
for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
.PHONY: install
install: $(wildcard *.go)
CGO_ENABLED=0 go install -v -ldflags '-w $(LDFLAGS)'
.PHONY: build
build: $(EXECUTABLE)
$(EXECUTABLE): $(SOURCES)
CGO_ENABLED=0 go build -v -ldflags '-w $(LDFLAGS)' -o $@
.PHONY: docker
docker:
docker build -t metalmatze/ana:latest .

25
do
View File

@ -1,25 +0,0 @@
#!/bin/bash
install_dependencies() {
go get "github.com/gorilla/sessions"
go get "golang.org/x/crypto/bcrypt"
go get "github.com/mssola/user_agent"
go get "github.com/gorilla/mux"
go get "github.com/Pallinder/go-randomdata"
go get "github.com/gorilla/handlers"
go get "github.com/go-sql-driver/mysql"
go get -u "github.com/mattes/migrate"
go get "github.com/joho/godotenv"
}
bin() {
go build
}
database_migrate() {
export $(cat .env | xargs)
$GOPATH/bin/migrate -url mysql://$ANA_DATABASE_USER:$ANA_DATABASE_PASSWORD@$ANA_DATABSE_HOST/$ANA_DATABASE_NAME -path ./db/migrations $1 $2 $3
}
# call first argument
$1 $2 $3 $4