File tree Expand file tree Collapse file tree 6 files changed +51
-6
lines changed
Expand file tree Collapse file tree 6 files changed +51
-6
lines changed Original file line number Diff line number Diff line change 2828 ${{ runner.os }}-go-
2929
3030 - name : Build
31- run : go build -v ./...
31+ run : make build
3232
3333 # - name: Test
3434 # run: go test -v ./...
Original file line number Diff line number Diff line change 2323 github_token : ${{ secrets.GITHUB_TOKEN }}
2424 goos : ${{ matrix.goos }}
2525 goarch : ${{ matrix.goarch }}
26+ build_command : " make"
27+ build_flags : " build"
2628 extra_files : LICENSE README.md gof.example.yaml
Original file line number Diff line number Diff line change 1+ VERSION := $(shell git describe --tags --abbrev=0)
2+ BUILDTIME := $(shell date -u '+% Y-% m-% dT% H:% M:% SZ')
3+
4+ GOLDFLAGS += -X main.Version=$(VERSION )
5+ GOLDFLAGS += -X main.Buildtime=$(BUILDTIME )
6+ GOFLAGS = -ldflags "$(GOLDFLAGS ) "
7+
8+ run : build
9+ ./gof
10+
11+ dry-run : build
12+ ./gof -dry-run
13+
14+ build :
15+ go build -o gof $(GOFLAGS ) .
Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "fmt"
45 "log"
56 "os"
67 "time"
78
89 "gopkg.in/yaml.v2"
910)
1011
11- const (
12- HttpUserAgent = "gof"
13- )
14-
1512var (
13+ Version string
14+ Buildtime string
1615 configFile string
1716)
1817
@@ -28,6 +27,13 @@ type config struct {
2827 Accounts []account
2928 LastUpdated time.Time
3029 HttpConfig httpConfig
30+ Meta meta
31+ }
32+
33+ type meta struct {
34+ Name string
35+ Version string
36+ Buildtime string
3137}
3238
3339type account struct {
@@ -56,7 +62,11 @@ func readConfig(fileName string) *config {
5662 if debug {
5763 log .Printf ("Config:\n \n %v" , config )
5864 }
59- config .HttpConfig .UserAgent = HttpUserAgent
65+ config .Meta .Name = "gof"
66+ config .Meta .Version = Version
67+ config .Meta .Buildtime = Buildtime
68+ config .HttpConfig .UserAgent = fmt .Sprintf ("%s/%s" ,
69+ config .Meta .Name , config .Meta .Version )
6070 return config
6171}
6272
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ func main() {
3636
3737 log .Println ("gof starting up..." )
3838 conf = readConfig (configFile )
39+ log .Printf ("Version: %s\n " , conf .Meta .Version )
40+ log .Printf ("Build time: %s\n " , conf .Meta .Buildtime )
3941
4042 var tpls = make (map [string ]* template.Template )
4143 var formats = make (map [string ]string )
You can’t perform that action at this time.
0 commit comments