File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11on :
22 release :
3- types : [created ]
3+ types : [published ]
44
55jobs :
66 releases-matrix :
@@ -18,11 +18,20 @@ jobs:
1818 goos : windows
1919 steps :
2020 - uses : actions/checkout@v3
21+
22+ - name : Set APP_VERSION env
23+ run : echo APP_VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV}
24+ - name : Set BUILD_TIME env
25+ run : echo BUILD_TIME=$(date --iso-8601=seconds) >> ${GITHUB_ENV}
26+ - name : Environment Printer
27+ uses : managedkaos/print-env@v1.0
28+
2129 - uses : wangyoucao577/go-release-action@v1
2230 with :
2331 github_token : ${{ secrets.GITHUB_TOKEN }}
2432 goos : ${{ matrix.goos }}
2533 goarch : ${{ matrix.goarch }}
2634 project_path : " ./app/main"
2735 binary_name : " git-webhook-receiver"
28- extra_files : LICENSE README.md
36+ extra_files : config.json.example LICENSE README.md
37+ ldflags : -X "main.version=${{ env.APP_VERSION }}" -X "main.buildTime=${{ env.BUILD_TIME }}" -X main.gitCommit=${{ github.sha }}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package main
22
33import (
44 "context"
5+ "flag"
56 "fmt"
67 "net/http"
78 "os"
@@ -21,9 +22,25 @@ import (
2122 goLoggerEchoMiddlerware "github.com/pobyzaarif/go-logger/rest/framework/echo/v4/middleware"
2223)
2324
24- var logger = goLogger .NewLog ("MAIN" )
25+ var (
26+ logger = goLogger .NewLog ("MAIN" )
27+
28+ version string
29+ buildTime string
30+ gitCommit string
31+ )
2532
2633func main () {
34+ v := flag .Bool ("v" , false , "print version info" )
35+ flag .Parse ()
36+
37+ if * v {
38+ fmt .Println ("Version: " + version )
39+ fmt .Println ("Build time: " + buildTime )
40+ fmt .Println ("Git commit: " + gitCommit )
41+ return
42+ }
43+
2744 conf := config .LoadConfig ("./config.json" )
2845
2946 e := echo .New ()
You can’t perform that action at this time.
0 commit comments