3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-14 07:59:31 +01:00

Merge pull request #1040 from slingamn/build_again.2

tweak version strings again
This commit is contained in:
Shivaram Lingamneni 2020-05-21 10:49:53 -07:00 committed by GitHub
commit 4595ed68a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 34 deletions

View File

@ -30,10 +30,6 @@ builds:
goarch: arm64 goarch: arm64
flags: flags:
- -trimpath - -trimpath
# #1031: don't include the git hash in an official build
# default is: "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser"
ldflags:
- "-s -w -X main.build={{.Version}}"
archives: archives:
- -

View File

@ -1,6 +1,6 @@
.PHONY: all install build release capdefs test smoke .PHONY: all install build release capdefs test smoke
GIT_COMMIT := $(shell git rev-parse --short=16 HEAD 2> /dev/null) GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null)
capdef_file = ./irc/caps/defs.go capdef_file = ./irc/caps/defs.go

View File

@ -5,20 +5,7 @@
package irc package irc
import "fmt"
const ( const (
// SemVer is the semantic version of Oragono.
SemVer = "2.1.0-unreleased"
)
var (
// Commit is the current git commit.
Commit = ""
// Ver is the full version of Oragono, used in responses to clients.
Ver = fmt.Sprintf("oragono-%s", SemVer)
// maxLastArgLength is used to simply cap off the final argument when creating general messages where we need to select a limit. // maxLastArgLength is used to simply cap off the final argument when creating general messages where we need to select a limit.
// for instance, in MONITOR lists, RPL_ISUPPORT lists, etc. // for instance, in MONITOR lists, RPL_ISUPPORT lists, etc.
maxLastArgLength = 400 maxLastArgLength = 400

28
irc/version.go Normal file
View File

@ -0,0 +1,28 @@
// Copyright (c) 2020 Shivaram Lingamneni
// Released under the MIT license
package irc
import "fmt"
const (
// SemVer is the semantic version of Oragono.
SemVer = "2.1.0-unreleased"
)
var (
// Ver is the full version of Oragono, used in responses to clients.
Ver = fmt.Sprintf("oragono-%s", SemVer)
// Commit is the full git hash, if available
Commit string
)
// initialize version strings (these are set in package main via linker flags)
func SetVersionString(version, commit string) {
Commit = commit
if version != "" {
Ver = fmt.Sprintf("oragono-%s", version)
} else if len(Commit) == 40 {
Ver = fmt.Sprintf("oragono-%s-%s", SemVer, Commit[:16])
}
}

View File

@ -21,7 +21,9 @@ import (
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
) )
var commit = "" // set via linker flags, either by make or by goreleaser:
var commit = "" // git hash
var version = "" // tagged version
// get a password from stdin from the user // get a password from stdin from the user
func getPassword() string { func getPassword() string {
@ -89,7 +91,7 @@ func doMkcerts(configFile string, quiet bool) {
} }
func main() { func main() {
version := irc.SemVer irc.SetVersionString(version, commit)
usage := `oragono. usage := `oragono.
Usage: Usage:
oragono initdb [--conf <filename>] [--quiet] oragono initdb [--conf <filename>] [--quiet]
@ -105,7 +107,7 @@ Options:
-h --help Show this screen. -h --help Show this screen.
--version Show version.` --version Show version.`
arguments, _ := docopt.ParseArgs(usage, nil, version) arguments, _ := docopt.ParseArgs(usage, nil, irc.Ver)
// don't require a config file for genpasswd // don't require a config file for genpasswd
if arguments["genpasswd"].(bool) { if arguments["genpasswd"].(bool) {
@ -167,22 +169,11 @@ Options:
} }
} else if arguments["run"].(bool) { } else if arguments["run"].(bool) {
if !arguments["--quiet"].(bool) { if !arguments["--quiet"].(bool) {
logman.Info("server", fmt.Sprintf("Oragono v%s starting", irc.SemVer)) logman.Info("server", fmt.Sprintf("%s starting", irc.Ver))
if commit == "" {
logman.Debug("server", fmt.Sprintf("Could not get current commit"))
} else {
logman.Info("server", fmt.Sprintf("Running commit %s", commit))
}
}
// set current git commit
irc.Commit = commit
if commit != "" {
irc.Ver = fmt.Sprintf("%s-%s", irc.Ver, commit)
} }
// warning if running a non-final version // warning if running a non-final version
if strings.Contains(irc.SemVer, "unreleased") { if strings.Contains(irc.Ver, "unreleased") {
logman.Warning("server", "You are currently running an unreleased beta version of Oragono that may be unstable and could corrupt your database.\nIf you are running a production network, please download the latest build from https://oragono.io/downloads.html and run that instead.") logman.Warning("server", "You are currently running an unreleased beta version of Oragono that may be unstable and could corrupt your database.\nIf you are running a production network, please download the latest build from https://oragono.io/downloads.html and run that instead.")
} }