Improve CI

* CI: Move sassc to own image
* Get version from git
* Drop makefile, move sass and bindata generation completly to go generate
parent 9a0b5116
clone:
git:
image: plugins/git
tags: true
pipeline:
sass:
image: codycraven/sassc
pull: true
commands:
- sassc -t compressed sass/main.scss sass/main.css
build:
image: golang
pull: true
environment:
- CGO_ENABLED=0
commands:
- apt update && apt install -y --no-install-recommends sassc go-bindata
- make deploy
- apt update && apt install -y --no-install-recommends go-bindata
- go generate --run "go-bindata"
- go build -ldflags "-X main.VERSION=$(git describe --tags) -X main.BUILD_DATE=$(date --iso-8601=seconds) -X main.GIN_MODE=release" -o bin/hashworksNET *.go
- go test --covermode=atomic --coverprofile=coverage.out ./server
- ./bin/hashworksNET --version
coverage:
image: golang
......
css
sass/*.css
bin
server/bindata
BINARY_PRE=*.go server/*.go css/main.css server/bindata/bindata.go
BINARY_SOURCE=*.go
BINDATA_DATA=css/main.css static/pgp_public_key.asc templates/* img/*
BINDATA_FLAGS=-pkg bindata
BINDATA_FLAGS_DEBUG=-pkg bindata -debug
SASS_PRE=sass/*.scss
SASS_SOURCE=sass/main.scss
SASS_FLAGS=-t compressed
SASS_FLAGS_DEBUG=-t nested -l
VERSION := $(shell git describe --tags)
DATE := $(shell date --iso-8601=seconds)
build: GIN_MODE=debug
build: CGO_ENABLED=1
build: bin/hashworksNET
deploy: GIN_MODE=release
deploy: CGO_ENABLED=0
deploy: bin/hashworksNET
run: build
bin/hashworksNET
generate: $(BINARY_PRE)
clean:
rm -Rf ./bin ./css ./server/bindata.go
debug: SASS_FLAGS=$(SASS_FLAGS_DEBUG)
debug: BINDATA_FLAGS=$(BINDATA_FLAGS_DEBUG)
debug: bin/hashworksNET
bin/hashworksNET --debug
debug-css: SASS_FLAGS=$(SASS_FLAGS_DEBUG)
debug-css: css
css/main.css: $(SASS_PRE)
mkdir -p css
sassc $(SASS_FLAGS) $(SASS_SOURCE) $@
debug-bindata: BINDATA_FLAGS=$(BINDATA_FLAGS_DEBUG)
debug-bindata: server/bindata.go
server/bindata/bindata.go: $(BINDATA_DATA)
go-bindata $(BINDATA_FLAGS) -o $@ $(BINDATA_DATA)
bin/hashworksNET: $(BINARY_PRE)
mkdir -p bin
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags '-X main.VERSION=$(VERSION) -X main.BUILD_DATE=$(DATE) -X main.GIN_MODE=$(GIN_MODE)' -o bin/hashworksNET $(BINARY_SOURCE)
//go:generate make generate
//go:generate sassc -t compressed sass/main.scss sass/main.css
//go:generate go-bindata -pkg bindata -o server/bindata/bindata.go sass/main.css static templates img
package main
import (
......
......@@ -49,7 +49,7 @@ func NewServer(config Config) (Server, error) {
}
gin.SetMode(config.GinMode)
cssBytes := bindata.MustAsset("css/main.css")
cssBytes := bindata.MustAsset("sass/main.css")
cssSha256 := sha256.Sum256(cssBytes)
s := Server{
......
......@@ -13,7 +13,7 @@ func (s Server) templateFunctionMap() template.FuncMap {
if !s.config.Debug {
return s.css
} else { // On debug mode we normally don't include the CSS in our binary. This means we can edit it live
return template.CSS(bindata.MustAsset("css/main.css"))
return template.CSS(bindata.MustAsset("sass/main.css"))
}
},
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment