2022-07-13 16:16:47 +01:00
|
|
|
SHELL := /bin/bash
|
2022-07-16 00:53:50 +01:00
|
|
|
PRODUCT_NAME := wappcityuni
|
|
|
|
BIN := dist/${PRODUCT_NAME}
|
|
|
|
ENTRY_POINT := ./cmd/${PRODUCT_NAME}
|
2022-07-13 16:16:47 +01:00
|
|
|
HASH := $(shell git rev-parse --short HEAD)
|
|
|
|
COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
|
|
|
|
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
|
|
|
|
VERSION := ${HASH}
|
2022-07-16 00:53:50 +01:00
|
|
|
LD_FLAGS := -s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}' -X 'main.buildName=${PRODUCT_NAME}'
|
2022-07-13 16:16:47 +01:00
|
|
|
COMP_BIN := go
|
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
BIN := $(BIN).exe
|
|
|
|
endif
|
|
|
|
|
2022-07-16 22:20:56 +01:00
|
|
|
.PHONY: build dev test clean deploy
|
2022-07-13 16:16:47 +01:00
|
|
|
|
|
|
|
build:
|
|
|
|
mkdir -p dist/
|
|
|
|
${COMP_BIN} build -o "${BIN}" -ldflags="${LD_FLAGS}" ${ENTRY_POINT}
|
|
|
|
|
|
|
|
dev:
|
|
|
|
mkdir -p dist/
|
|
|
|
${COMP_BIN} build -tags debug -o "${BIN}" -ldflags="${LD_FLAGS}" ${ENTRY_POINT}
|
|
|
|
./${BIN}
|
|
|
|
|
|
|
|
test:
|
2022-07-16 16:07:57 +01:00
|
|
|
${COMP_BIN} test
|
2022-07-13 16:16:47 +01:00
|
|
|
|
|
|
|
clean:
|
2022-07-16 16:07:57 +01:00
|
|
|
${COMP_BIN} clean
|
2022-07-13 16:16:47 +01:00
|
|
|
rm -r -f dist/
|
2022-07-15 15:46:58 +01:00
|
|
|
|
2022-07-16 22:20:56 +01:00
|
|
|
deploy: build
|
2022-07-16 16:15:06 +01:00
|
|
|
sudo systemctl stop wappcityuni
|
|
|
|
sudo cp "${BIN}" /usr/local/bin
|
2022-07-28 01:56:00 +01:00
|
|
|
sudo cp *.go.html cnf
|
|
|
|
sudo cp *.go.yml cnf
|
|
|
|
sudo cp *.css cdn
|
|
|
|
sudo cp *.js cdn
|
2022-07-16 16:15:06 +01:00
|
|
|
sudo systemctl start wappcityuni
|