Skip to content

Commit

Permalink
feat(gemini): add version info
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kropachev committed Jun 18, 2023
1 parent 4481c8e commit 0512a10
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name:
uses: actions/checkout@v2

uses: actions/checkout@v3
- name: Pull tags and refs
run: git fetch --prune --unshallow
- name: Check if version is updated
run: |
export ExpectedVersion=$(git describe --tags --abbrev=0)
export DefinedVersion=$(cat cmd/gemini/Version)
if [ "$ExpectedVersion" != "$DefinedVersion" ]; then
echo "Expect to have '$ExpectedVersion', but got '$DefinedVersion'"
exit 1
fi
- name: Setup Go
uses: actions/setup-go@v2
with:
Expand Down
1 change: 1 addition & 0 deletions cmd/gemini/Version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.8.3
24 changes: 21 additions & 3 deletions cmd/gemini/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
package main

import (
_ "embed"
"fmt"
"os"
"runtime/debug"
)

//go:generate sh -c "git describe --tags --abbrev=0 | tr -d '\n' > ./Version"
//go:embed Version
var version string

var (
commit = "none"
version = "dev"
date = "unknown"
commit = "none"
date = "unknown"
)

func main() {
Expand All @@ -30,3 +35,16 @@ func main() {
os.Exit(1)
}
}

func init() {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
switch setting.Key {
case "vcs.revision":
commit = setting.Value
case "vcs.time":
date = setting.Value
}
}
}
}

0 comments on commit 0512a10

Please sign in to comment.