revert main.ReleaseVersion changes

This commit is contained in:
Sergio Moura 2023-09-12 15:55:41 -04:00
parent 0d30011a33
commit a8360efa67
3 changed files with 8 additions and 6 deletions

View File

@ -6,7 +6,7 @@ RUN go mod download
COPY . ./
ARG GOARCH
RUN apk add --update --no-cache --virtual .build-deps build-base && \
GOARCH=${GOARCH} go build -o /server -ldflags "-X release.Version=v0.`cat VERSION`" backend/server/server.go && \
GOARCH=${GOARCH} go build -o /server -ldflags "-X main.ReleaseVersion=v0.`cat VERSION`" backend/server/server.go && \
apk del .build-deps
FROM alpine:3.17

View File

@ -3,8 +3,6 @@ package main
import (
"context"
"fmt"
"github.com/ddworken/hishtory/internal/release"
"github.com/ddworken/hishtory/internal/server"
"log"
"os"
"runtime"
@ -12,6 +10,8 @@ import (
"github.com/DataDog/datadog-go/statsd"
"github.com/ddworken/hishtory/internal/database"
"github.com/ddworken/hishtory/internal/release"
"github.com/ddworken/hishtory/internal/server"
_ "github.com/lib/pq"
"gorm.io/gorm"
"gorm.io/gorm/logger"
@ -23,8 +23,9 @@ const (
)
var (
GLOBAL_DB *database.DB
GLOBAL_STATSD *statsd.Client
GLOBAL_DB *database.DB
GLOBAL_STATSD *statsd.Client
ReleaseVersion string
)
func isTestEnvironment() bool {
@ -96,6 +97,7 @@ func OpenDB() (*database.DB, error) {
}
func init() {
release.Version = ReleaseVersion
if release.Version == "UNKNOWN" && !isTestEnvironment() {
panic("server.go was built without a ReleaseVersion!")
}

View File

@ -228,7 +228,7 @@ func buildServer() string {
f, err := os.CreateTemp("", "server")
checkError(err)
fn := f.Name()
cmd := exec.Command("go", "build", "-o", fn, "-ldflags", fmt.Sprintf("-X release.Version=v0.%s", version), "backend/server/server.go")
cmd := exec.Command("go", "build", "-o", fn, "-ldflags", fmt.Sprintf("-X main.ReleaseVersion=v0.%s", version), "backend/server/server.go")
var stdout bytes.Buffer
cmd.Stdout = &stdout
var stderr bytes.Buffer