nimbus-eth2/beacon_chain/version.nim

51 lines
1.7 KiB
Nim
Raw Normal View History

# Copyright (c) 2018-2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
## This module implements the version tagging details of all binaries included
## in the Nimbus release process (i.e. beacon_node, validator_client, etc)
{.push raises: [].}
import strutils
when not defined(nimscript):
import times
let copyrights* = "Copyright (c) 2019-" & $(now().utc.year) & " Status Research & Development GmbH"
2019-11-11 14:43:12 +00:00
const
2023-01-18 17:39:55 +00:00
versionMajor* = 23
versionMinor* = 1
2023-01-26 13:37:03 +00:00
versionBuild* = 1
2020-11-20 20:31:03 +00:00
versionBlob* = "stateofus" # Single word - ends up in the default graffiti
2021-03-10 21:05:14 +00:00
gitRevision* = strip(staticExec("git rev-parse --short HEAD"))[0..5]
2022-09-20 15:52:24 +00:00
nimFullBanner* = staticExec("nim --version")
nimBanner* = staticExec("nim --version | grep Version")
versionAsStr* =
$versionMajor & "." & $versionMinor & "." & $versionBuild
2020-11-25 01:13:35 +00:00
fullVersionStr* = "v" & versionAsStr & "-" & gitRevision & "-" & versionBlob
2022-09-20 15:52:24 +00:00
func getNimGitHash*(): string =
const gitPrefix = "git hash: "
2022-09-20 15:52:24 +00:00
let tmp = splitLines(nimFullBanner)
if tmp.len == 0:
return
for line in tmp:
if line.startsWith(gitPrefix) and line.len > 8 + gitPrefix.len:
2022-09-20 15:52:24 +00:00
result = line[gitPrefix.len..<gitPrefix.len + 8]
2022-09-20 15:52:24 +00:00
func shortNimBanner*(): string =
let gitHash = getNimGitHash()
let tmp = splitLines(nimFullBanner)
if gitHash.len > 0:
tmp[0] & " (" & gitHash & ")"
else:
tmp[0]