Skip to content

Commit

Permalink
proper --version display
Browse files Browse the repository at this point in the history
  • Loading branch information
wsw70 committed Jan 17, 2023
1 parent de70dac commit a5ae529
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions syncthing-map.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import (
"fmt"
"io"
"os"
"runtime"
"strings"
"time"

"github.com/rs/zerolog"
"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"`
Expand Down Expand Up @@ -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 <device name> --file <configuration file> | graph\nsyncthing-map server",
Commands: []*cli.Command{
{
Name: "add",
Expand Down

0 comments on commit a5ae529

Please sign in to comment.