This commit is contained in:
parent
13d8ead58b
commit
060b5705c8
4 changed files with 38 additions and 2 deletions
|
@ -21,6 +21,8 @@ jobs:
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
|
build-args: |
|
||||||
|
VERSION_STRING=${{ env.GITHUB_REF_NAME }}
|
||||||
- name: update hassio-addons
|
- name: update hassio-addons
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -18,7 +18,8 @@ FROM alpine:latest AS build
|
||||||
RUN apk add --no-cache go
|
RUN apk add --no-cache go
|
||||||
ADD . /go/lockserver
|
ADD . /go/lockserver
|
||||||
WORKDIR /go/lockserver
|
WORKDIR /go/lockserver
|
||||||
RUN CGO_ENABLED=0 go build ./cmd/lockserver
|
ARG VERSION_STRING
|
||||||
|
RUN CGO_ENABLED=0 go build -ldflags "-X git.devhack.net/devhack/member-services/config.Version=${VERSION_STRING}" ./cmd/lockserver
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=build /go/lockserver/lockserver /lockserver
|
COPY --from=build /go/lockserver/lockserver /lockserver
|
||||||
|
|
30
config/version.go
Normal file
30
config/version.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
BuildInfo *debug.BuildInfo
|
||||||
|
Version string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
var ok bool
|
||||||
|
BuildInfo, ok = debug.ReadBuildInfo()
|
||||||
|
if !ok {
|
||||||
|
logrus.Error("failed to read build info")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if Version == "" {
|
||||||
|
for _, setting := range BuildInfo.Settings {
|
||||||
|
if setting.Key == "vcs.revision" {
|
||||||
|
Version = setting.Value
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,8 +2,11 @@ package frontend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
|
||||||
|
"git.janky.solutions/finn/lockserver/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -16,7 +19,7 @@ var (
|
||||||
Templates *template.Template
|
Templates *template.Template
|
||||||
|
|
||||||
funcs = template.FuncMap{
|
funcs = template.FuncMap{
|
||||||
"version": func() string { return "better-zwave-locks v0.x.x aaaaaaaa" },
|
"version": func() string { return fmt.Sprintf("better-zwave-locks %s", config.Version) },
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue