mirror of
https://github.com/Kyren223/eko.git
synced 2025-09-03 20:18:22 +00:00
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:
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -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
|
||||
|
1
embeds/VERSION
Normal file
1
embeds/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
v0.0.11
|
@@ -21,8 +21,10 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
//go:embed VERSION
|
||||
var Version string
|
||||
|
||||
var (
|
||||
Version string = "unknown"
|
||||
Commit string = "unknown"
|
||||
BuildDate string = "unknown"
|
||||
)
|
||||
|
@@ -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}"
|
||||
];
|
||||
|
Reference in New Issue
Block a user