Skip to content

Commit

Permalink
Detected devel version
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Wooding committed Sep 7, 2022
1 parent 5b1594d commit a5632ca
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ builds:
- windows
- darwin
ldflags:
- -s -w -X 'github.com/richardwooding/powerdown/version/Version={{.Version}}' -X 'github.com/richardwooding/powerdown/version/CommitHash={{.Commit}}' -X github.com/richardwooding/powerdown/version/BuildTimestamp={{.Date}}'
- "-s -w -X 'github.com/richardwooding/powerdown/version/Version={{.Version}}' -X 'github.com/richardwooding/powerdown/version/CommitHash={{.Commit}}' -X github.com/richardwooding/powerdown/version/BuildTimestamp={{.Date}}'"
archives:
- replacements:
darwin: Darwin
Expand Down
3 changes: 0 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"fmt"
"github.com/fatih/color"
"github.com/richardwooding/powerdown/api"
"github.com/richardwooding/powerdown/version"
"github.com/rodaine/table"
"log"
"os"
Expand Down Expand Up @@ -85,8 +84,6 @@ func init() {
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
headerFmt = color.New(color.FgGreen, color.Underline).SprintfFunc()
columnFmt = color.New(color.FgYellow).SprintfFunc()

println("Powerdown " + version.BuildVersion())
}

// initConfig reads in config file and ENV variables if set.
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
github.com/fatih/color v1.13.0
github.com/icza/bitio v1.1.0
github.com/rodaine/table v1.0.1
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/icza/bitio v1.1.0 h1:ysX4vtldjdi3Ygai5m1cWy4oLkhWTAi+SyO6HC8L9T0=
github.com/icza/bitio v1.1.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A=
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6 h1:8UsGZ2rr2ksmEru6lToqnXgA8Mz1DP11X4zSJ159C3k=
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
Expand Down
15 changes: 5 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ THE SOFTWARE.
*/
package main

import "github.com/richardwooding/powerdown/cmd"

var (
version = "dev"
commit = ""
date = ""
import (
"github.com/richardwooding/powerdown/cmd"
"github.com/richardwooding/powerdown/version"
)

func GetVersionString() string {
return version
}

func main() {
println("Powerdown " + version.Version)
println()
cmd.Execute()
}
21 changes: 21 additions & 0 deletions model/area.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
Copyright © 2022 Richard Wooding [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package model

import "time"
Expand Down
21 changes: 21 additions & 0 deletions model/nearby.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
Copyright © 2022 Richard Wooding [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package model

type NearbyResponse struct {
Expand Down
49 changes: 47 additions & 2 deletions version/Version.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,58 @@
/*
Copyright © 2022 Richard Wooding [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package version

import "fmt"
import (
"fmt"
"runtime/debug"
"github.com/icza/bitio"
)


var (
Version = "dev"
Version = "devel"
CommitHash = ""
BuildTimestamp = ""
)

func init() {
if Version == "devel" {
_ = bitio.NewReader
bi, ok := debug.ReadBuildInfo()
if !ok {
return
}
for _, dep := range bi.Deps {
if dep.Path == "github.com/richardwooding/powerdown" {
Version = dep.Version
}
}
}
}

func BuildSimpleVersion() string {
return fmt.Sprintf("%s", Version)
}

func BuildVersion() string {
return fmt.Sprintf("%s-%s (%s)", Version, CommitHash, BuildTimestamp)
}

0 comments on commit a5632ca

Please sign in to comment.