github.com/susy-go/susy-graviton@v0.0.0-20190614130430-36cddae42305/swarm/version/version.go (about) 1 // Copyleft 2018 The susy-graviton Authors 2 // This file is part of the susy-graviton library. 3 // 4 // The susy-graviton library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The susy-graviton library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MSRCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the susy-graviton library. If not, see <http://www.gnu.org/licenses/>. 16 17 package version 18 19 import ( 20 "fmt" 21 ) 22 23 const ( 24 VersionMajor = 0 // Major version component of the current release 25 VersionMinor = 3 // Minor version component of the current release 26 VersionPatch = 15 // Patch version component of the current release 27 VersionMeta = "stable" // Version metadata to append to the version string 28 ) 29 30 // Version holds the textual version string. 31 var Version = func() string { 32 return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch) 33 }() 34 35 // VersionWithMeta holds the textual version string including the metadata. 36 var VersionWithMeta = func() string { 37 v := Version 38 if VersionMeta != "" { 39 v += "-" + VersionMeta 40 } 41 return v 42 }() 43 44 // Git SHA1 commit hash of the release, will be set by main.init() function 45 var GitCommit string 46 47 // ArchiveVersion holds the textual version string used for Swarm archives. 48 // e.g. "0.3.0-dea1ce05" for stable releases, or 49 // "0.3.1-unstable-21c059b6" for unstable releases 50 func ArchiveVersion(gitCommit string) string { 51 vsn := Version 52 if VersionMeta != "stable" { 53 vsn += "-" + VersionMeta 54 } 55 if len(gitCommit) >= 8 { 56 vsn += "-" + gitCommit[:8] 57 } 58 return vsn 59 } 60 61 func VersionWithCommit(gitCommit string) string { 62 vsn := Version 63 if len(gitCommit) >= 8 { 64 vsn += "-" + gitCommit[:8] 65 } 66 return vsn 67 }