diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7b5b677..d8d1145 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,8 +18,8 @@ jobs: - uses: actions/setup-go@v3 with: go-version-file: "go.mod" - - run: env GOOS=linux GOARCH=amd64 go build -o syncthing-map-linux-amd64 . - - run: env GOOS=windows GOARCH=amd64 go build -o syncthing-map-windows-amd64.exe . + - run: env GOOS=linux GOARCH=amd64 go build -ldflags "-X main.compiledVersion=${{ GITHUB.REF_NAME }}" -o syncthing-map-linux-amd64 . + - run: env GOOS=windows GOARCH=amd64 go build -ldflags "-X main.compiledVersion=${{ GITHUB.REF_NAME }}" -o syncthing-map-windows-amd64.exe . - name: release uses: softprops/action-gh-release@v1 diff --git a/syncthing-map.go b/syncthing-map.go index 35b3940..218da19 100644 --- a/syncthing-map.go +++ b/syncthing-map.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "runtime" "strings" "time" @@ -11,6 +12,9 @@ import ( "github.com/urfave/cli/v2" ) +// version will be added from tag during compilation +var compiledVersion string + type Device struct { ID string `xml:"id,attr" json:"id"` Name string `xml:"name,attr" json:"name"` @@ -58,18 +62,24 @@ func init() { } func main() { + if compiledVersion == "" { + log.Error().Msgf("compiledVersion not set at compile time") + compiledVersion = "(missing from compilation)" + } app := &cli.App{ - Name: "syncthing-map", - Version: "alpha", - Compiled: time.Now(), + Name: "syncthing-map", + Usage: "Syncthing devices and shared folders mapped in your browser", + Version: fmt.Sprintf("%s %s/%s", compiledVersion, runtime.GOOS, runtime.GOARCH), Authors: []*cli.Author{ { Name: "wsw70", Email: "1345886+wsw70@users.noreply.github.com", }, }, - Copyright: "WTFPL http://www.wtfpl.net/", + Copyright: "WTFPL (http://www.wtfpl.net)", + HideHelp: true, + UsageText: "syncthing-map clean\nsyncthing-map add --device --file | graph\nsyncthing-map server", Commands: []*cli.Command{ { Name: "add",