From ba26e32d7a6763515b5446f00ddb22826f2f80b0 Mon Sep 17 00:00:00 2001 From: maximo tejeda Date: Fri, 15 Nov 2024 09:49:34 -0400 Subject: [PATCH] ADD image build and push --- .github/workflows/tags.yml | 10 ++++++---- cmd/main.go | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tags.yml b/.github/workflows/tags.yml index 11b998b..493e4c7 100644 --- a/.github/workflows/tags.yml +++ b/.github/workflows/tags.yml @@ -11,7 +11,8 @@ jobs: USERNAME: ${{ vars.USERNAME }} TAG_VERSION: ${{ github.ref_name }} steps: - - uses: actions/checkout@v4 + - name: Checkout Code + uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: @@ -23,13 +24,14 @@ jobs: run: | git rev-parse --short HEAD >> ./shortsha - - name: Build amd64 + - name: Build amd64 run: | - GOOS=linux GOARCH=amd64 go build -o bin/ddns_amd64_$TAG_VERSION ./cmd/... + export shortsha=`git rev-parse --short HEAD` + GOOS=linux GOARCH=amd64 go build -o bin/ddns_amd64_$TAG_VERSION "-X 'main.Shortsha=$shortsha' -X 'main.Version=$TAG_VERSION' -X 'main.Aarch=amd64'" ./cmd/... - name: Build arm64 run: | - GOOS=linux GOARCH=arm64 go build -o bin/ddns_arm64_$TAG_VERSION ./cmd/... + GOOS=linux GOARCH=arm64 go build -o bin/ddns_arm64_$TAG_VERSION "-X 'main.Shortsha=$shortsha' -X 'main.Version=$TAG_VERSION' -X 'main.Aarch=arm64'" ./cmd/... - name: push generic registry amd64 run: | diff --git a/cmd/main.go b/cmd/main.go index 9782673..e04f9c1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -22,6 +22,9 @@ var ( provider string rID string comment string + Version string + Shortsha string + Aarch string ) func init() { @@ -54,8 +57,8 @@ func main() { case "prod": lvl.Set(slog.LevelInfo) } - log := slog.New(slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{Level: lvl})) + log = log.With("version", Version, "shortsha", Shortsha, "aarch", Aarch) ctx := context.Background() helpmsg := "required flag not provided " if tok == "" {