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