diff --git a/README.md b/README.md index 935377b..f9a2a9e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Gokapi [![Go Report Card](https://goreportcard.com/badge/github.com/forceu/gokapi)](https://goreportcard.com/report/github.com/forceu/gokapi) +![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-62%25-brightgreen.svg?longCache=true&style=flat) [![Docker Pulls](https://img.shields.io/docker/pulls/f0rc3/gokapi.svg)](https://hub.docker.com/r/f0rc3/gokapi/) diff --git a/build/go.mod b/build/go.mod index 4ddcae5..65c723f 100644 --- a/build/go.mod +++ b/build/go.mod @@ -1,8 +1,9 @@ -module SingleDownload +module Gokapi go 1.16 require ( + github.com/otiai10/copy v1.5.1 golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect ) diff --git a/build/setVersionTemplate.sh b/build/setVersionTemplate.sh index 3702e68..4fdbc12 100755 --- a/build/setVersionTemplate.sh +++ b/build/setVersionTemplate.sh @@ -1,4 +1,5 @@ #!/bin/sh #Called by go generate #Sets the version number in the template automatically - sed -i 's/{{define "version"}}.*{{end}}/{{define "version"}}'$1'{{end}}/g' ../../internal/webserver/web/templates/string_constants.tmpl +sed -i 's/{{define "version"}}.*{{end}}/{{define "version"}}'$1'{{end}}/g' ../../internal/webserver/web/templates/string_constants.tmpl +echo "Set version in web template" diff --git a/build/updateCoverage.sh b/build/updateCoverage.sh new file mode 100755 index 0000000..73b8203 --- /dev/null +++ b/build/updateCoverage.sh @@ -0,0 +1,14 @@ +#!/bin/sh +#Called by go generate +#Creates the coverage for the README.md file if gopherbadger is installed +cd ../../ +#Grep is used to hide output + +which gopherbadger > /dev/null +if [ $? -eq 0 ]; then + gopherbadger -png=false -md=README.md -tags "test" > /dev/null + rm coverage.out + echo "Updated coverage in readme file" +else + echo "Gopherbadger not installed, not updating coverage" +fi diff --git a/cmd/gokapi/Main.go b/cmd/gokapi/Main.go index 27f41e8..c80023e 100644 --- a/cmd/gokapi/Main.go +++ b/cmd/gokapi/Main.go @@ -66,3 +66,9 @@ const logo = ` ██  ██ ██  ██ ██  ██  ██   ██ ██      ██   ██████   ██████  ██  ██ ██  ██ ██  ██                                       ` + +// Generates coverage badge +//go:generate sh "../../build/updateCoverage.sh" + +// Copy go mod file to docker image builder +//go:generate cp "../../go.mod" "../../build/go.mod"