You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

57 lines
1.2 KiB

BINARYNAME=go-blog
TMP=tmp
DIST=release
GITHASH=$(shell git rev-parse HEAD)
BUILD_VERSION=$(shell git describe --tags)
ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif
RELEASE="releases"
LDFLAGS=-ldflags '-X main.BuildVersion=${BUILD_VERSION} -X main.GitHash=${GITHASH}'
.PHONY: clean build-release build lint install package vet fmt test
build-release: clean tidy fmt vet test build package
build:
go build ${LDFLAGS} -o ${GOPATH}/bin/go-blog
cd clt/createuser && go build -o ${GOPATH}/bin/create_user ${LDFLAGS}
cd clt/initdatabase && go build -o ${GOPATH}/bin/init_database ${LDFLAGS}
install:
go install ${LDFLAGS}
cd clt/createuser && go install ${LDFLAGS}
cd clt/initdatabase && go install ${LDFLAGS}
package:
-rm -r ${TMP}
mkdir -p ${TMP}/clt
-mkdir -p releases/custom
cp ${GOPATH}/bin/go-blog ${TMP}/
cp ${GOPATH}/bin/create_user ${TMP}/clt
cp ${GOPATH}/bin/init_database ${TMP}/clt
cp go-blog.conf ${TMP}/
cp -r examples/ ${TMP}/
cp -r templates/ ${TMP}/
cp -r assets/ ${TMP}/
cp README.md ${TMP}/
cd ${TMP} && tar -czvf ../releases/$(BINARYNAME)-$(BUILD_VERSION).tar.gz * && cd -
vet:
go vet ./...
fmt:
go fmt ./...
test:
go test ./...
clean:
go clean -i ./...
tidy:
go mod tidy