Skip to content

Commit

Permalink
auto version value
Browse files Browse the repository at this point in the history
  • Loading branch information
diginatu committed Jan 6, 2017
1 parent f05247e commit fc537d6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ _cgo_export.*

_testmain.go

release/*
nagome
*.exe
*.test
*.prof
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ notifications:
on_failure: always
email: false

before_deploy: gox -osarch "linux/amd64 darwin/amd64 windows/amd64" -output "release/{{.Dir}}_{{.OS}}_{{.Arch}}"
before_deploy: make cross
deploy:
provider: releases
api_key:
Expand Down
2 changes: 1 addition & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func RunCli() {
return
}
if *printVersion {
fmt.Println(App.Name, " ", App.Version)
fmt.Println(AppName, " ", Version)
return
}
if *mkplug != "" {
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package main

// Application holds app settings and valuables
type Application struct {
Name string
Version string
SavePath string
SettingsSlots SettingsSlots
}

// Application global information
var (
// App is global Application settings and valuables for this app
App = Application{Name: "Nagome", Version: "0.0.1"}
AppName = "Nagome"
Version string
App Application
)

func main() {
Expand Down
25 changes: 25 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SOURCEDIR=.
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')

BINARY=nagome

LDFLAGS=-ldflags "-X main.Version=`git describe`"

.DEFAULT_GOAL: $(BINARY)

$(BINARY): $(SOURCES)
go build ${LDFLAGS} -o ${BINARY}

.PHONY: install
install:
go install ${LDFLAGS} ./...


.PHONY: cross
cross:
gox -osarch "linux/amd64 darwin/amd64 windows/amd64" -output "release/{{.Dir}}_{{.OS}}_{{.Arch}}" ${LDFLAGS}

.PHONY: clean
clean:
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi

2 changes: 1 addition & 1 deletion user_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ func findUserConfigPath() string {
home := os.Getenv("HOME")
dir := filepath.Join(home, ".config")

return filepath.Join(dir, App.Name)
return filepath.Join(dir, AppName)
}
2 changes: 1 addition & 1 deletion user_path_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ func findUserConfigPath() string {
dir = filepath.Join(home, "Application Data")
}

return filepath.Join(dir, App.Name)
return filepath.Join(dir, AppName)
}

0 comments on commit fc537d6

Please sign in to comment.