Directly embedding version inside the app instead of injecting it at

build time, so there is always only one source of truth
This commit is contained in:
2025-08-03 15:41:16 +03:00
parent 9913e614ec
commit 3feffc0f77
5 changed files with 5 additions and 8 deletions

View File

@@ -22,9 +22,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set RELEASE_TAG env
run: echo RELEASE_TAG=$(echo ${GITHUB_REF/refs\/tags\//}) >> ${GITHUB_ENV}
- name: Set COMMIT env
run: echo COMMIT=$(git rev-parse --short=7 HEAD) >> ${GITHUB_ENV}
@@ -38,7 +35,6 @@ jobs:
goarch: ${{ matrix.goarch }}
binary_name: eko
ldflags: >
-X "github.com/kyren223/eko/embeds.Version=${{ env.RELEASE_TAG }}"
-X "github.com/kyren223/eko/embeds.Commit=${{ env.COMMIT }}"
-X "github.com/kyren223/eko/embeds.BuildDate=${{ env.BUILD_DATE }}"
project_path: ./cmd/client

View File

@@ -1 +0,0 @@
v0.1.0

1
embeds/VERSION Normal file
View File

@@ -0,0 +1 @@
v0.0.11

View File

@@ -21,8 +21,10 @@ import (
"sync/atomic"
)
//go:embed VERSION
var Version string
var (
Version string = "unknown"
Commit string = "unknown"
BuildDate string = "unknown"
)

View File

@@ -21,7 +21,7 @@
pkgs = import inputs.nixpkgs {
inherit system overlays;
};
version = (builtins.readFile ./VERSION);
version = (builtins.readFile ./embeds/VERSION);
buildDate = toString self.lastModified;
commit = if (builtins.hasAttr "rev" self) then (builtins.substring 0 7 self.rev) else "unknown";
# vendorHash = pkgs.lib.fakeHash;
@@ -37,7 +37,6 @@
in
(if (debug-tracing) then pkgs.lib.sources.trace source-files else source-files);
ldflags = [
"-X github.com/kyren223/eko/embeds.Version=${version}"
"-X github.com/kyren223/eko/embeds.Commit=${commit}"
"-X github.com/kyren223/eko/embeds.BuildDate=${buildDate}"
];