Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
set app version from git tag (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
brusynska committed Aug 4, 2023
1 parent d488ffb commit ca6019f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
extra_files: README.md
release_tag: ${{ steps.previoustag.outputs.tag }}
goversion: "go.mod"
ldflags: -X "github.com/xdbfoundation/go/support/app.version=${{ steps.previoustag.outputs.tag }}"
overwrite: "true"
retry: 100

Expand Down Expand Up @@ -131,6 +132,7 @@ jobs:
extra_files: README.md
release_tag: ${{ steps.previoustag.outputs.tag }}
goversion: "go.mod"
ldflags: -X "github.com/xdbfoundation/go/support/app.version=${{ steps.previoustag.outputs.tag }}"
overwrite: "true"
retry: 100

Expand All @@ -148,6 +150,7 @@ jobs:
extra_files: README.md
release_tag: ${{ steps.previoustag.outputs.tag }}
goversion: "go.mod"
ldflags: -X "github.com/xdbfoundation/go/support/app.version=${{ steps.previoustag.outputs.tag }}"
overwrite: "true"
retry: 100

Expand All @@ -165,6 +168,7 @@ jobs:
extra_files: README.md
release_tag: ${{ steps.previoustag.outputs.tag }}
goversion: "go.mod"
ldflags: -X "github.com/xdbfoundation/go/support/app.version=${{ steps.previoustag.outputs.tag }}"
overwrite: "true"
retry: 100

Expand Down Expand Up @@ -201,8 +205,8 @@ jobs:
export GO111MODULE=on
go env -w GOBIN=/home/runner/go/bin
sudo cp -Rf ./* /go/src/github.com/xdbfoundation/go/
sudo go install github.com/xdbfoundation/go/services/...
sudo go install github.com/xdbfoundation/go/tools/digitalbits-archivist
sudo go install -ldflags="-X 'github.com/xdbfoundation/go/support/app.version=${{ steps.previoustag.outputs.tag }}'" github.com/xdbfoundation/go/services/...
sudo go install -ldflags="-X 'github.com/xdbfoundation/go/support/app.version=${{ steps.previoustag.outputs.tag }}'" github.com/xdbfoundation/go/tools/digitalbits-archivist
- name: Make .deb package
run: |
Expand Down
5 changes: 3 additions & 2 deletions services/frontier/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM golang:1.17 AS builder

WORKDIR /go/src/github.com/xdbfoundation/go
ARG FRONTIER_VERSION
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN go install github.com/xdbfoundation/go/services/frontier
RUN go install github.com/xdbfoundation/go/exp/services/captivecore
RUN go install -ldflags="-X 'github.com/xdbfoundation/go/support/app.version=$FRONTIER_VERSION'" github.com/xdbfoundation/go/services/frontier
RUN go install -ldflags="-X 'github.com/xdbfoundation/go/support/app.version=$FRONTIER_VERSION'" github.com/xdbfoundation/go/exp/services/captivecore

FROM ubuntu:20.04
ENV DIGITALBITS_CORE_BINARY_PATH /usr/local/bin/digitalbits-core
Expand Down
5 changes: 3 additions & 2 deletions services/frontier/docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM golang:1.17 AS builder

WORKDIR /go/src/github.com/xdbfoundation/go
ARG FRONTIER_VERSION
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN go install github.com/xdbfoundation/go/services/frontier
RUN go install github.com/xdbfoundation/go/exp/services/captivecore
RUN go install -ldflags="-X 'github.com/xdbfoundation/go/support/app.version=$FRONTIER_VERSION'" github.com/xdbfoundation/go/services/frontier
RUN go install -ldflags="-X 'github.com/xdbfoundation/go/support/app.version=$FRONTIER_VERSION'" github.com/xdbfoundation/go/exp/services/captivecore

FROM ubuntu:20.04
ENV DIGITALBITS_CORE_VERSION=1.0.65-beta.5
Expand Down
16 changes: 9 additions & 7 deletions support/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
// provide global application metadata, such as build time or version.
package app

import "time"
import "github.com/xdbfoundation/go/support/errors"
import (
"time"

"github.com/xdbfoundation/go/support/errors"
)

var (
// ErrNoBuildTime is the error returned when no build time for the current
// binary was set.
ErrNoBuildTime = errors.New("build time not known")

// buildTime and version variables are now exported, so they can be set via linker flags.
buildTime string
version string
)

// BuildTime returns the time that the binary of the current process was built.
Expand Down Expand Up @@ -36,8 +43,3 @@ func Version() string {

return version
}

var (
buildTime string
version string
)

0 comments on commit ca6019f

Please sign in to comment.