mirror of
https://github.com/bakito/adguardhome-sync.git
synced 2025-03-03 18:47:40 +08:00
add build time to version
This commit is contained in:
parent
5c2e0b966e
commit
484cf26119
6 changed files with 19 additions and 8 deletions
11
.github/workflows/publish.yml
vendored
11
.github/workflows/publish.yml
vendored
|
@ -11,6 +11,9 @@ jobs:
|
|||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "::set-output name=date::$(date --utc +%Y-%m-%dT%H:%M:%SZ)"
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
|
@ -29,7 +32,9 @@ jobs:
|
|||
push: true
|
||||
tags: quay.io/bakito/adguardhome-sync:latest,quay.io/bakito/adguardhome-sync:${{ github.event.release.tag_name }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
build-args: VERSION=${{ github.event.release.tag_name }}
|
||||
build-args: |
|
||||
VERSION=${{ github.event.release.tag_name }}
|
||||
BUILD=${{ steps.date.outputs.date }}
|
||||
|
||||
- name: Build and push main
|
||||
id: docker_build_main
|
||||
|
@ -39,6 +44,8 @@ jobs:
|
|||
push: true
|
||||
tags: quay.io/bakito/adguardhome-sync:main
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
build-args: VERSION=main
|
||||
build-args: |
|
||||
VERSION=main
|
||||
BUILD=${{ steps.date.outputs.date }}
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
|
|
@ -4,7 +4,7 @@ builds:
|
|||
- env:
|
||||
- CGO_ENABLED=0
|
||||
ldflags:
|
||||
- -s -w -X github.com/bakito/adguardhome-sync/version.Version={{.Version}}
|
||||
- -s -w -X github.com/bakito/adguardhome-sync/version.Version={{.Version}} -X github.com/bakito/adguardhome-sync/version.Build={{.Date}}
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
|
|
|
@ -5,6 +5,8 @@ WORKDIR /go/src/app
|
|||
RUN apt-get update && apt-get install -y upx
|
||||
|
||||
ARG VERSION=main
|
||||
ARG BUILD="N/A"
|
||||
|
||||
ENV GOPROXY=https://goproxy.io \
|
||||
GO111MODULE=on \
|
||||
CGO_ENABLED=0 \
|
||||
|
@ -12,7 +14,7 @@ ENV GOPROXY=https://goproxy.io \
|
|||
|
||||
ADD . /go/src/app/
|
||||
|
||||
RUN go build -a -installsuffix cgo -ldflags="-w -s -X github.com/bakito/adguardhome-sync/version.Version=${VERSION}" -o adguardhome-sync . \
|
||||
RUN go build -a -installsuffix cgo -ldflags="-w -s -X github.com/bakito/adguardhome-sync/version.Version=${VERSION} -X github.com/bakito/adguardhome-sync/version.Build=${BUILD}" -o adguardhome-sync . \
|
||||
&& upx -q adguardhome-sync
|
||||
|
||||
# application image
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/bakito/adguardhome-sync/pkg/log"
|
||||
"github.com/bakito/adguardhome-sync/version"
|
||||
)
|
||||
|
||||
func (w *worker) handleSync(rw http.ResponseWriter, req *http.Request) {
|
||||
|
@ -62,7 +61,7 @@ func use(h http.HandlerFunc, middleware ...func(http.HandlerFunc) http.HandlerFu
|
|||
}
|
||||
|
||||
func (w *worker) listenAndServe() {
|
||||
l.With("version", version.Version, "port", w.cfg.API.Port).Info("Starting API server")
|
||||
l.With("port", w.cfg.API.Port).Info("Starting API server")
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
mux := http.NewServeMux()
|
||||
|
|
|
@ -27,6 +27,7 @@ func Sync(cfg *types.Config) error {
|
|||
return fmt.Errorf("no replicas configured")
|
||||
}
|
||||
|
||||
l.With("version", version.Version, "build", version.Build).Info("AdGuardHome sync")
|
||||
cfg.Origin.AutoSetup = false
|
||||
|
||||
w := &worker{
|
||||
|
@ -37,7 +38,7 @@ func Sync(cfg *types.Config) error {
|
|||
}
|
||||
if cfg.Cron != "" {
|
||||
w.cron = cron.New()
|
||||
cl := l.With("version", version.Version, "cron", cfg.Cron)
|
||||
cl := l.With("cron", cfg.Cron)
|
||||
_, err := w.cron.AddFunc(cfg.Cron, func() {
|
||||
w.sync()
|
||||
})
|
||||
|
@ -53,7 +54,7 @@ func Sync(cfg *types.Config) error {
|
|||
}
|
||||
}
|
||||
if cfg.RunOnStart {
|
||||
l.With("version", version.Version).Info("Run on startup")
|
||||
l.Info("Running sync on startup")
|
||||
w.sync()
|
||||
}
|
||||
if cfg.API.Port != 0 {
|
||||
|
|
|
@ -3,4 +3,6 @@ package version
|
|||
var (
|
||||
// Version the module version
|
||||
Version = "devel"
|
||||
// Build the build time
|
||||
Build = "N/A"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue