File tree 2 files changed +30
-2
lines changed
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -9,8 +9,9 @@ pipeline {
9
9
stage(' Prepare' ) {
10
10
steps {
11
11
checkout scm
12
+ sh ' git fetch --depth=500'
12
13
sh ' go get github.com/mitchellh/gox'
13
- sh ' go get -u -v .'
14
+ sh ' go get -d - u -v ./cmd/protoplex '
14
15
sh ' mkdir -p builds'
15
16
}
16
17
}
@@ -19,7 +20,15 @@ pipeline {
19
20
CGO_ENABLED = ' 0'
20
21
}
21
22
steps {
22
- sh ' gox -parallel=2 -ldflags="-s -w" -output="builds/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/protoplex'
23
+ sh '''
24
+ version="$(git describe --tags --abbrev=0 HEAD || true)"
25
+ if [ -z "${version}" ]; then
26
+ version="v0.0.0"
27
+ fi
28
+ build="$(git rev-parse --short HEAD)"
29
+ fullver="${version}+${build}"
30
+ gox -parallel=2 -ldflags="-s -w -X main.version=${fullver}" -output="builds/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/protoplex
31
+ '''
23
32
}
24
33
}
25
34
stage(' Cleanup' ) {
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "fmt"
4
5
"os"
5
6
6
7
"github.com/Pandentia/protoplex/protoplex"
@@ -9,10 +10,24 @@ import (
9
10
"gopkg.in/alecthomas/kingpin.v2"
10
11
)
11
12
13
+ var version string
14
+
15
+ func printVersion () {
16
+ if version == "" {
17
+ fmt .Println ("Version has not been set." )
18
+ os .Exit (1 )
19
+ return
20
+ }
21
+ fmt .Println (version )
22
+ os .Exit (0 )
23
+ }
24
+
12
25
func main () {
13
26
app := kingpin .New ("protoplex" , "A fast and simple protocol multiplexer." )
14
27
logger := zerolog .New (os .Stdout ).With ().Timestamp ().Logger ()
15
28
29
+ version := app .Flag ("version" , "Prints the current program version" ).Short ('V' ).Bool ()
30
+
16
31
bind := app .Flag ("bind" , "The address to bind to" ).Short ('b' ).Default ("0.0.0.0:8443" ).String ()
17
32
verbose := app .Flag ("verbose" , "Enables debug logging" ).Short ('v' ).Bool ()
18
33
pretty := app .Flag ("pretty" , "Enables pretty logging" ).Short ('p' ).Bool ()
@@ -27,6 +42,10 @@ func main() {
27
42
28
43
app .Parse (os .Args [1 :])
29
44
45
+ if * version {
46
+ printVersion ()
47
+ }
48
+
30
49
if * pretty {
31
50
logger = logger .Output (zerolog.ConsoleWriter {Out : os .Stderr })
32
51
}
You can’t perform that action at this time.
0 commit comments