It's not necessary to build commit info to ldflags now.

Signed-off-by: Odyssey <odyssey346@disroot.org>
This commit is contained in:
Odyssey
2022-12-17 20:09:19 +01:00
parent 721b0cd287
commit ebf23cfe36
2 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ RUN apk --no-cache add git
RUN git clone https://codeberg.org/gothub/gothub .
RUN go mod download
RUN GOOS=linux GOARCH=$TARGETARCH go build -ldflags "-X codeberg.org/gothub/gothub/pages.Version=$(git rev-parse --short HEAD)" -o /src/gothub
RUN GOOS=linux GOARCH=$TARGETARCH go build -o /src/gothub
FROM scratch as bin
+16 -2
View File
@@ -1,8 +1,22 @@
package pages
import "github.com/gofiber/fiber/v2"
import (
"runtime/debug"
var Version = "unknown"
"github.com/gofiber/fiber/v2"
)
// taken from https://git.vern.cc/pjals/bestofbot.
var Version = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value[:8]
}
}
}
return "AGPLVIOLATION"
}()
func HandleIndex(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{