diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 82a0f1b..50e45f1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,8 +1,9 @@ name: goreleaser on: - pull_request: - push: + create: + tags: + - v* jobs: goreleaser: diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..c24c755 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,45 @@ +# .goreleaser.yml +project_name: resh + +# resh_template: '{{ ProjectName }}_{{ .Version }}' +env: + - GO111MODULE=on +before: + hooks: + - go mod tidy + +builds: + # You can have multiple builds defined as a yaml list + - + # ID of the build. + # Defaults to the project name. + id: "daemon" + + # Path to main.go file or main package. + # Default is `.`. + main: ./cmd/daemon/main.go + + # Binary name. + # Can be a path (e.g. `bin/app`) to wrap the binary in a directory. + # Default is the name of the project directory. + binary: resh-daemon + + # Hooks can be used to customize the final binary, + # for example, to run generators. + # Those fields allow templates. + # Default is both hooks empty. + # hooks: + # pre: rice embed-go + # post: ./script.sh + +signs: + - artifacts: checksum + +release: + draft: true + # If set to auto, will mark the release as not ready for production + # in case there is an indicator for this in the tag e.g. v1.0.0-rc1 + # If set to true, will mark the release as not ready for production. + # Default is false. + prerelease: auto + # disable: true \ No newline at end of file diff --git a/cmd/collect/main.go b/cmd/collect/main.go index 49ccbde..f6972b9 100644 --- a/cmd/collect/main.go +++ b/cmd/collect/main.go @@ -17,11 +17,11 @@ import ( "strconv" ) -// Version from git set during build -var Version string +// version tag from git set during build +var version string -// Revision from git set during build -var Revision string +// Commit hash from git set during build +var commit string func main() { usr, _ := user.Current() @@ -104,23 +104,23 @@ func main() { flag.Parse() if *showVersion == true { - fmt.Println(Version) + fmt.Println(version) os.Exit(0) } if *showRevision == true { - fmt.Println(Revision) + fmt.Println(commit) os.Exit(0) } - if *requireVersion != "" && *requireVersion != Version { + if *requireVersion != "" && *requireVersion != version { fmt.Println("Please restart/reload this terminal session " + - "(resh version: " + Version + + "(resh version: " + version + "; resh version of this terminal session: " + *requireVersion + ")") os.Exit(3) } - if *requireRevision != "" && *requireRevision != Revision { + if *requireRevision != "" && *requireRevision != commit { fmt.Println("Please restart/reload this terminal session " + - "(resh revision: " + Revision + + "(resh revision: " + commit + "; resh revision of this terminal session: " + *requireRevision + ")") os.Exit(3) @@ -234,8 +234,8 @@ func main() { PartOne: true, ReshUUID: collect.ReadFileContent(reshUUIDPath), - ReshVersion: Version, - ReshRevision: Revision, + ReshVersion: version, + ReshRevision: commit, RecallActionsRaw: *recallActions, RecallPrefix: *recallPrefix, diff --git a/cmd/control/main.go b/cmd/control/main.go index 7b03c2f..633f5e5 100644 --- a/cmd/control/main.go +++ b/cmd/control/main.go @@ -6,11 +6,11 @@ import ( "github.com/curusarn/resh/cmd/control/cmd" ) -// Version from git set during build -var Version string +// version from git set during build +var version string -// Revision from git set during build -var Revision string +// commit from git set during build +var commit string func main() { os.Exit(int(cmd.Execute())) diff --git a/cmd/daemon/main.go b/cmd/daemon/main.go index 8045c5c..56ff608 100644 --- a/cmd/daemon/main.go +++ b/cmd/daemon/main.go @@ -17,16 +17,16 @@ import ( "github.com/curusarn/resh/pkg/cfg" ) -// Version from git set during build -var Version string +// version from git set during build +var version string -// Revision from git set during build -var Revision string +// commit from git set during build +var commit string func main() { log.Println("Daemon starting... \n" + - "version: " + Version + - " revision: " + Revision) + "version: " + version + + " commit: " + commit) usr, _ := user.Current() dir := usr.HomeDir pidfilePath := filepath.Join(dir, ".resh/resh.pid") @@ -85,8 +85,8 @@ func main() { } func statusHandler(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("OK; version: " + Version + - "; revision: " + Revision + "\n")) + w.Write([]byte("OK; version: " + version + + "; commit: " + commit + "\n")) log.Println("Status OK") } diff --git a/cmd/evaluate/main.go b/cmd/evaluate/main.go index 7ae217f..3b94f19 100644 --- a/cmd/evaluate/main.go +++ b/cmd/evaluate/main.go @@ -13,11 +13,11 @@ import ( "github.com/curusarn/resh/pkg/strat" ) -// Version from git set during build -var Version string +// version from git set during build +var version string -// Revision from git set during build -var Revision string +// commit from git set during build +var commit string func main() { const maxCandidates = 50 @@ -50,11 +50,11 @@ func main() { // handle show{Version,Revision} options if *showVersion == true { - fmt.Println(Version) + fmt.Println(version) os.Exit(0) } if *showRevision == true { - fmt.Println(Revision) + fmt.Println(commit) os.Exit(0) } diff --git a/cmd/inspect/main.go b/cmd/inspect/main.go index 4edc41e..2c5bc94 100644 --- a/cmd/inspect/main.go +++ b/cmd/inspect/main.go @@ -18,11 +18,11 @@ import ( "strconv" ) -// Version from git set during build -var Version string +// version from git set during build +var version string -// Revision from git set during build -var Revision string +// commit from git set during build +var commit string func main() { usr, _ := user.Current() diff --git a/cmd/postcollect/main.go b/cmd/postcollect/main.go index 6029bff..f343834 100644 --- a/cmd/postcollect/main.go +++ b/cmd/postcollect/main.go @@ -17,11 +17,11 @@ import ( "strconv" ) -// Version from git set during build -var Version string +// version from git set during build +var version string -// Revision from git set during build -var Revision string +// commit from git set during build +var commit string func main() { usr, _ := user.Current() @@ -66,23 +66,23 @@ func main() { flag.Parse() if *showVersion == true { - fmt.Println(Version) + fmt.Println(version) os.Exit(0) } if *showRevision == true { - fmt.Println(Revision) + fmt.Println(commit) os.Exit(0) } - if *requireVersion != "" && *requireVersion != Version { + if *requireVersion != "" && *requireVersion != version { fmt.Println("Please restart/reload this terminal session " + - "(resh version: " + Version + + "(resh version: " + version + "; resh version of this terminal session: " + *requireVersion + ")") os.Exit(3) } - if *requireRevision != "" && *requireRevision != Revision { + if *requireRevision != "" && *requireRevision != commit { fmt.Println("Please restart/reload this terminal session " + - "(resh revision: " + Revision + + "(resh revision: " + commit + "; resh revision of this terminal session: " + *requireRevision + ")") os.Exit(3) @@ -141,8 +141,8 @@ func main() { PartOne: false, ReshUUID: collect.ReadFileContent(reshUUIDPath), - ReshVersion: Version, - ReshRevision: Revision, + ReshVersion: version, + ReshRevision: commit, }, } collect.SendRecord(rec, strconv.Itoa(config.Port), "/record") diff --git a/cmd/sanitize/main.go b/cmd/sanitize/main.go index e5630de..5b888cd 100644 --- a/cmd/sanitize/main.go +++ b/cmd/sanitize/main.go @@ -23,11 +23,11 @@ import ( giturls "github.com/whilp/git-urls" ) -// Version from git set during build -var Version string +// version from git set during build +var version string -// Revision from git set during build -var Revision string +// commit from git set during build +var commit string func main() { usr, _ := user.Current() @@ -45,11 +45,11 @@ func main() { flag.Parse() if *showVersion == true { - fmt.Println(Version) + fmt.Println(version) os.Exit(0) } if *showRevision == true { - fmt.Println(Revision) + fmt.Println(commit) os.Exit(0) } sanitizer := sanitizer{hashLength: *trimHashes} diff --git a/cmd/session-init/main.go b/cmd/session-init/main.go index b7c4516..75f5298 100644 --- a/cmd/session-init/main.go +++ b/cmd/session-init/main.go @@ -16,11 +16,11 @@ import ( "strconv" ) -// Version from git set during build -var Version string +// version from git set during build +var version string -// Revision from git set during build -var Revision string +// commit from git set during build +var commit string func main() { usr, _ := user.Current() @@ -83,23 +83,23 @@ func main() { flag.Parse() if *showVersion == true { - fmt.Println(Version) + fmt.Println(version) os.Exit(0) } if *showRevision == true { - fmt.Println(Revision) + fmt.Println(commit) os.Exit(0) } - if *requireVersion != "" && *requireVersion != Version { + if *requireVersion != "" && *requireVersion != version { fmt.Println("Please restart/reload this terminal session " + - "(resh version: " + Version + + "(resh version: " + version + "; resh version of this terminal session: " + *requireVersion + ")") os.Exit(3) } - if *requireRevision != "" && *requireRevision != Revision { + if *requireRevision != "" && *requireRevision != commit { fmt.Println("Please restart/reload this terminal session " + - "(resh revision: " + Revision + + "(resh revision: " + commit + "; resh revision of this terminal session: " + *requireRevision + ")") os.Exit(3) @@ -178,8 +178,8 @@ func main() { OsReleasePrettyName: *osReleasePrettyName, ReshUUID: collect.ReadFileContent(reshUUIDPath), - ReshVersion: Version, - ReshRevision: Revision, + ReshVersion: version, + ReshRevision: commit, }, } collect.SendRecord(rec, strconv.Itoa(config.Port), "/session_init")