Skip to content

Commit 7271337

Browse files
committed
added version in debug mode
1 parent 3d7babd commit 7271337

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
- uses: actions/setup-go@v3
1919
with:
2020
go-version-file: "go.mod"
21-
- run: env GOOS=linux GOARCH=amd64 go build -o dly-linux-amd64 .
22-
- run: env GOOS=windows GOARCH=amd64 go build -o dly-windows-amd64.exe .
21+
- run: env GOOS=linux GOARCH=amd64 go build -ldflags "-X main.compiledVersion=${{ GITHUB.REF_NAME }}" -o dly-linux-amd64 .
22+
- run: env GOOS=windows GOARCH=amd64 go build -ldflags "-X main.compiledVersion=${{ GITHUB.REF_NAME }}" -o dly-windows-amd64.exe .
2323

2424
- name: release
2525
uses: softprops/action-gh-release@v1

dly.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ import (
88
"io/fs"
99
"os"
1010
"path/filepath"
11+
"runtime"
1112
"strings"
1213
"time"
1314

1415
"github.com/rs/zerolog"
1516
"gopkg.in/yaml.v3"
1617
)
1718

19+
// version extracted from tag added during compilation
20+
var compiledVersion string
21+
1822
type Configuration struct {
1923
DailyNotesPath string `yaml:"DailyNotesPath"`
2024
FilenameFormat string `yaml:"FilenameFormat"`
@@ -43,6 +47,7 @@ func init() {
4347
}
4448

4549
log = zerolog.New(output).With().Timestamp().Logger()
50+
log.Debug().Msgf("debugging initialized, version %s %s/%s", compiledVersion, runtime.GOOS, runtime.GOARCH)
4651
}
4752

4853
func main() {

0 commit comments

Comments
 (0)