Added go generate command for version number in templates

This commit is contained in:
Marc Ole Bulling
2021-04-02 12:36:59 +02:00
parent e0d351b5b0
commit 57752af405
3 changed files with 5 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ set -e
targets=${@-"darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 windows/amd64 windows/386"}
cd /usr/src/myapp
go generate
for target in $targets; do
os="$(echo $target | cut -d '/' -f1)"

View File

@@ -10,7 +10,7 @@ RUN cd /compile && go mod download
COPY . /compile
RUN cd /compile && CGO_ENABLED=0 go build -ldflags="-s -w -X 'Gokapi/src/environment.IsDocker=true' -X 'Gokapi/src/environment.Builder=Project Docker File' -X 'Gokapi/src/environment.BuildTime=$(date)'" -o /compile/gokapi
RUN cd /compile && go generate && CGO_ENABLED=0 go build -ldflags="-s -w -X 'Gokapi/src/environment.IsDocker=true' -X 'Gokapi/src/environment.Builder=Project Docker File' -X 'Gokapi/src/environment.BuildTime=$(date)'" -o /compile/gokapi
FROM alpine:3.13

View File

@@ -16,8 +16,10 @@ import (
"time"
)
// needs to be changed in ./templates/string_constants.tmpl as well
// Current version in readable form. Needs to be changed in ./templates/string_constants.tmpl as well,
// which can be done with "go generate"
const VERSION = "1.1.2"
//go:generate sed "-i" "s/{{define \"version\"}}.*{{end}}/{{define \"version\"}}1.1.2{{end}}/g" "./templates/string_constants.tmpl"
// Main routine that is called on startup
func main() {