mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
set version from git tag.
This commit is contained in:
parent
1064cc4eb5
commit
e181abf577
@ -17,8 +17,9 @@ RUN set -eux; \
|
|||||||
apt-get clean -y; \
|
apt-get clean -y; \
|
||||||
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
||||||
|
|
||||||
ARG GIT_COMMIT=dev
|
ARG GIT_COMMIT
|
||||||
ARG GIT_BRANCH=dev
|
ARG GIT_BRANCH
|
||||||
|
ARG GIT_TAG
|
||||||
|
|
||||||
#
|
#
|
||||||
# build server
|
# build server
|
||||||
@ -49,8 +50,8 @@ RUN set -eux; \
|
|||||||
# needed for profile upload preStop hook
|
# needed for profile upload preStop hook
|
||||||
zip curl \
|
zip curl \
|
||||||
#
|
#
|
||||||
# file chooser handler, clipboard
|
# file chooser handler, clipboard, drop
|
||||||
xdotool xclip \
|
xdotool xclip libgtk-3-0 \
|
||||||
#
|
#
|
||||||
# gst
|
# gst
|
||||||
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
|
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
|
||||||
|
10
build
10
build
@ -13,10 +13,11 @@ fi
|
|||||||
|
|
||||||
#
|
#
|
||||||
# set git build variables if git exists
|
# set git build variables if git exists
|
||||||
if git version > /dev/null && [ -z $GIT_COMMIT ] && [ -z $GIT_COMMIT ];
|
if git version > /dev/null && [ -z $GIT_COMMIT ] && [ -z $GIT_BRANCH ] && [ -z $GIT_TAG ];
|
||||||
then
|
then
|
||||||
GIT_COMMIT=`git rev-parse --short HEAD`
|
GIT_COMMIT=`git rev-parse --short HEAD`
|
||||||
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
|
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
|
||||||
|
GIT_TAG=`git tag --points-at $GIT_COMMIT | head -n 1`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -29,9 +30,10 @@ go build \
|
|||||||
-o bin/neko \
|
-o bin/neko \
|
||||||
-ldflags "
|
-ldflags "
|
||||||
-s -w
|
-s -w
|
||||||
-X 'demodesk/neko.buildDate=`date -u +'%Y-%m-%dT%H:%M:%SZ'`'
|
-X 'gitlab.com/demodesk/neko/server.buildDate=`date -u +'%Y-%m-%dT%H:%M:%SZ'`'
|
||||||
-X 'demodesk/neko.gitCommit=${GIT_COMMIT}'
|
-X 'gitlab.com/demodesk/neko/server.gitCommit=${GIT_COMMIT}'
|
||||||
-X 'demodesk/neko.gitBranch=${GIT_BRANCH}'
|
-X 'gitlab.com/demodesk/neko/server.gitBranch=${GIT_BRANCH}'
|
||||||
|
-X 'gitlab.com/demodesk/neko/server.gitTag=${GIT_TAG}'
|
||||||
" \
|
" \
|
||||||
cmd/neko/main.go;
|
cmd/neko/main.go;
|
||||||
|
|
||||||
|
35
neko.go
35
neko.go
@ -3,6 +3,7 @@ package neko
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Header = `&34
|
const Header = `&34
|
||||||
@ -11,7 +12,7 @@ const Header = `&34
|
|||||||
/ |/ / _ \/ //_/ __ \ ) ( ')
|
/ |/ / _ \/ //_/ __ \ ) ( ')
|
||||||
/ /| / __/ ,< / /_/ / ( / )
|
/ /| / __/ ,< / /_/ / ( / )
|
||||||
/_/ |_/\___/_/|_|\____/ \(__)|
|
/_/ |_/\___/_/|_|\____/ \(__)|
|
||||||
&1&37 nurdism/m1k1o &33%s v%s&0
|
&1&37 nurdism/m1k1o &33%s %s&0
|
||||||
`
|
`
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -21,21 +22,14 @@ var (
|
|||||||
gitCommit = "dev"
|
gitCommit = "dev"
|
||||||
//
|
//
|
||||||
gitBranch = "dev"
|
gitBranch = "dev"
|
||||||
|
//
|
||||||
// Major version when you make incompatible API changes.
|
gitTag = "dev"
|
||||||
major = "dev"
|
|
||||||
// Minor version when you add functionality in a backwards-compatible manner.
|
|
||||||
minor = "dev"
|
|
||||||
// Patch version when you make backwards-compatible bug fixes.
|
|
||||||
patch = "dev"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = &version{
|
var Version = &version{
|
||||||
Major: major,
|
|
||||||
Minor: minor,
|
|
||||||
Patch: patch,
|
|
||||||
GitCommit: gitCommit,
|
GitCommit: gitCommit,
|
||||||
GitBranch: gitBranch,
|
GitBranch: gitBranch,
|
||||||
|
GitTag: gitTag,
|
||||||
BuildDate: buildDate,
|
BuildDate: buildDate,
|
||||||
GoVersion: runtime.Version(),
|
GoVersion: runtime.Version(),
|
||||||
Compiler: runtime.Compiler,
|
Compiler: runtime.Compiler,
|
||||||
@ -43,11 +37,9 @@ var Version = &version{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type version struct {
|
type version struct {
|
||||||
Major string
|
|
||||||
Minor string
|
|
||||||
Patch string
|
|
||||||
GitCommit string
|
GitCommit string
|
||||||
GitBranch string
|
GitBranch string
|
||||||
|
GitTag string
|
||||||
BuildDate string
|
BuildDate string
|
||||||
GoVersion string
|
GoVersion string
|
||||||
Compiler string
|
Compiler string
|
||||||
@ -55,18 +47,23 @@ type version struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *version) String() string {
|
func (i *version) String() string {
|
||||||
return fmt.Sprintf("%s.%s.%s %s", i.Major, i.Minor, i.Patch, i.GitCommit)
|
version := i.GitTag
|
||||||
|
if version == "" || version == "dev" {
|
||||||
|
version = i.GitBranch
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s@%s", version, i.GitCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *version) Details() string {
|
func (i *version) Details() string {
|
||||||
return fmt.Sprintf(
|
return "\n" + strings.Join([]string{
|
||||||
"%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
|
fmt.Sprintf("Version %s", i.String()),
|
||||||
fmt.Sprintf("Version %s.%s.%s", i.Major, i.Minor, i.Patch),
|
|
||||||
fmt.Sprintf("GitCommit %s", i.GitCommit),
|
fmt.Sprintf("GitCommit %s", i.GitCommit),
|
||||||
fmt.Sprintf("GitBranch %s", i.GitBranch),
|
fmt.Sprintf("GitBranch %s", i.GitBranch),
|
||||||
|
fmt.Sprintf("GitTag %s", i.GitTag),
|
||||||
fmt.Sprintf("BuildDate %s", i.BuildDate),
|
fmt.Sprintf("BuildDate %s", i.BuildDate),
|
||||||
fmt.Sprintf("GoVersion %s", i.GoVersion),
|
fmt.Sprintf("GoVersion %s", i.GoVersion),
|
||||||
fmt.Sprintf("Compiler %s", i.Compiler),
|
fmt.Sprintf("Compiler %s", i.Compiler),
|
||||||
fmt.Sprintf("Platform %s", i.Platform),
|
fmt.Sprintf("Platform %s", i.Platform),
|
||||||
)
|
}, "\n") + "\n"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user