mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-21 12:44:49 -05:00
014e533206
The release name, as provided by FORGEJO_RELEASE, is used to build OCI images and binary files. Although it can be the same as the Forgejo version, it is not a requirement. When the FORGEJO_RELEASE environment variable is set, use it as a default for naming the binary file instead of FORGEJO_VERSION. For instance, when building from the forgejo branch here is what is desired: FORGEJO_VERSION=7.0.0-g2343 GITEA_VERSION=1.22.0 VERSION=vforgejo-test The name of the release is also displayed with forgejo --version for sanity check purposes. Before: FORGEJO_VERSION is the computed version GITEA_VERSION is set manually VERSION defaults to FORGEJO_VERSION forgejo --help does not display VERSION After: FORGEJO_VERSION is the computed version GITEA_VERSION is set manually RELEASE_VERSION defaults to FORGEJO_VERSION VERSION defaults to RELEASE_VERSION forgejo --help displays VERSION
81 lines
1.9 KiB
Go
81 lines
1.9 KiB
Go
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
// Copyright 2016 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
"strings"
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/cmd"
|
|
"code.gitea.io/gitea/modules/log"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
// register supported doc types
|
|
_ "code.gitea.io/gitea/modules/markup/asciicast"
|
|
_ "code.gitea.io/gitea/modules/markup/console"
|
|
_ "code.gitea.io/gitea/modules/markup/csv"
|
|
_ "code.gitea.io/gitea/modules/markup/markdown"
|
|
_ "code.gitea.io/gitea/modules/markup/orgmode"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// these flags will be set by the build flags
|
|
var (
|
|
Version = "development" // program version for this build
|
|
Tags = "" // the Golang build tags
|
|
MakeVersion = "" // "make" program version if built with make
|
|
|
|
ReleaseVersion = ""
|
|
)
|
|
|
|
var ForgejoVersion = "1.0.0"
|
|
|
|
func init() {
|
|
setting.AppVer = Version
|
|
setting.ForgejoVersion = ForgejoVersion
|
|
setting.AppBuiltWith = formatBuiltWith()
|
|
setting.AppStartTime = time.Now().UTC()
|
|
}
|
|
|
|
func forgejoEnv() {
|
|
for _, k := range []string{"CUSTOM", "WORK_DIR"} {
|
|
if v, ok := os.LookupEnv("FORGEJO_" + k); ok {
|
|
os.Setenv("GITEA_"+k, v)
|
|
}
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
forgejoEnv()
|
|
cli.OsExiter = func(code int) {
|
|
log.GetManager().Close()
|
|
os.Exit(code)
|
|
}
|
|
app := cmd.NewMainApp(Version, formatReleaseVersion()+formatBuiltWith())
|
|
_ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp
|
|
log.GetManager().Close()
|
|
}
|
|
|
|
func formatReleaseVersion() string {
|
|
if len(ReleaseVersion) > 0 {
|
|
return " (release name " + ReleaseVersion + ")"
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func formatBuiltWith() string {
|
|
version := runtime.Version()
|
|
if len(MakeVersion) > 0 {
|
|
version = MakeVersion + ", " + runtime.Version()
|
|
}
|
|
if len(Tags) == 0 {
|
|
return " built with " + version
|
|
}
|
|
|
|
return " built with " + version + " : " + strings.ReplaceAll(Tags, " ", ", ")
|
|
}
|