Skip to content

Commit

Permalink
Makefile instead of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ltheinrich committed Feb 17, 2019
1 parent c78b2ec commit 920c1a7
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 46 deletions.
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
NAME=gorum
BINARY=${NAME}
INSTALL_DIR=/usr/local/bin

VERSION=v1.0.13
BUILD_TIME=`date +%FT%T%z`

LDFLAGS=-ldflags "-X github.com/ltheinrich/gorum/cmd.Version=${VERSION} -X github.com/ltheinrich/gorum/cmd.BuildTime=${BUILD_TIME}"
GO_FILES=./...

WEB_DIR=web
WEB_DIST=${WEB_DIR}/dist
WEB_MODULES=${WEB_DIR}/node_modules
WEB_LOCK=${WEB_DIR}/yarn.lock

ASSETS_DIR=assets
ASSETS_PKG=assets
ASSETS_FILE=../internal/pkg/assets/assets.go

WEBASSETS_DIR=${WEB_DIST}/gorum
WEBASSETS_PKG=webassets
WEBASSETS_FILE=../../../internal/pkg/webassets/webassets.go

build: clean fmt test buildng assetsng assetsgo buildgo sign

install: gorum
cp ${BINARY} ${INSTALL_DIR}

run: assetsgo buildgo
clear
./${BINARY}

serve:
clear
cd ${WEB_DIR} && \
ng serve

fmt:
go fmt ${GO_FILES}

test:
go vet -v ${GO_FILES}
go test -v -race ${GO_FILES}

buildng:
cd ${WEB_DIR} && \
yarn install && \
ng build --prod

assetsng:
cd ${WEBASSETS_DIR} && \
go-bindata -o ${WEBASSETS_FILE} -pkg ${WEBASSETS_PKG} .

assetsgo:
cd ${ASSETS_DIR} && \
go-bindata -o ${ASSETS_FILE} -pkg ${ASSETS_PKG} .

buildgo:
go build ${LDFLAGS} -o ${BINARY}

sign:
gpg2 -a --detach-sign ${BINARY}

installgo:
go install ${LDFLAGS}

clean:
if [ -f ${WEB_DIST} ] ; then rm -r ${WEB_DIST} ; fi
if [ -f ${WEB_MODULES} ; then rm -r ${WEB_MODULES} ; fi
if [ -f ${WEB_LOCK} ] ; then rm ${WEB_LOCK} ; fi
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi
if [ -f ${BINARY}.asc ] ; then rm ${BINARY}.asc ; fi
11 changes: 0 additions & 11 deletions build.sh

This file was deleted.

10 changes: 8 additions & 2 deletions cmd/gorum.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"crypto/tls"
"encoding/json"
"fmt"
"log"
"net/http"
"strings"
Expand All @@ -16,6 +15,14 @@ import (
"github.com/ltheinrich/gorum/internal/pkg/db"
)

var (
// Version string generated using Makefile
Version string

// BuildTime string generated using Makefile
BuildTime string
)

// Init startup
func Init() (err error) {
// load config
Expand All @@ -40,7 +47,6 @@ func Init() (err error) {

// register handlers
handle()
fmt.Println("Gorum (c) 2018 Lennart Heinrich")

// https listen
return listen()
Expand Down
2 changes: 2 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarn global add @angular/cli
GO111MODULE=off go get -u github.com/go-bindata/go-bindata/...
Binary file removed go-bindata
Binary file not shown.
10 changes: 5 additions & 5 deletions internal/pkg/assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions internal/pkg/webassets/webassets.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE
`

func main() {
fmt.Printf("Gorum %v (c) 2018 Lennart Heinrich\n", cmd.Version)

if err := cmd.Init(); err != nil {
fmt.Println(err)
}
Expand Down
4 changes: 0 additions & 4 deletions start.sh

This file was deleted.

3 changes: 0 additions & 3 deletions web/start.sh

This file was deleted.

0 comments on commit 920c1a7

Please sign in to comment.