From b3a12aed85f6862861bc7e7526ccf31fcfda483b Mon Sep 17 00:00:00 2001 From: Sung Won Cho Date: Sat, 1 Sep 2018 16:30:15 +1000 Subject: [PATCH] Deprecate upgrade (#99) * Deprecate upgrade * Automate using goreleaser * Fix name and version * Automate --- .gitignore | 1 + .goreleaser.yml | 25 +++++++++++++++++++++++++ COMMANDS.md | 5 ----- Makefile | 14 ++++---------- cmd/upgrade/upgrade.go | 11 +++++++---- cmd/version/version.go | 2 +- core/core.go | 2 +- main.go | 2 +- 8 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.gitignore b/.gitignore index 23776dd3..77f01ca0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ main tmp/ /vendor test-dnote +/dist diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..309246af --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,25 @@ +archive: + format: binary + name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" + +builds: +- + binary: dnote + ldflags: + - -X core.Version={{.Version}} + - -X main.apiEndpoint=https://api.dnote.io + goos: + - darwin + - linux + - windows + - openbsd + goarch: + - amd64 + - 386 + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^refactor:' diff --git a/COMMANDS.md b/COMMANDS.md index b168e9b3..5552f09e 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -4,7 +4,6 @@ - [view](#dnote-view) - [edit](#dnote-edit) - [remove](#dnote-remove) -- [upgrade](#dnote-upgrade) - [login](#dnote-login) - [sync](#dnote-sync) @@ -68,10 +67,6 @@ $ dnote remove JS 1 $ dnote remove -b JS ``` -## dnote upgrade - -Upgrade the Dnote if newer release is available - ## dnote sync _Dnote Cloud only_ diff --git a/Makefile b/Makefile index d3aa6efe..70cf6577 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,14 @@ release: @echo "** Releasing version $(VERSION)..." - @echo "** Building..." - @$(MAKE) build @echo "** Tagging and pushing..." @git tag -a $(VERSION) -m "$(VERSION)" @git push --tags + @goreleaser .PHONY: release -build: install-gox - @$(GOPATH)/bin/gox -ldflags "-X main.apiEndpoint=https://api.dnote.io" -osarch="darwin/386 darwin/amd64 linux/386 linux/amd64 openbsd/386 openbsd/amd64 window/386 windows/amd64" -output="dnote-{{.OS}}-{{.Arch}}" ./... -.PHONY: build - -install-gox: - @echo "** Installing Gox..." - @go get github.com/mitchellh/gox -.PHONY: install-gox +build-snapshot: + @goreleaser --snapshot --rm-dist +.PHONY: build-snapshot clean: @git clean -f diff --git a/cmd/upgrade/upgrade.go b/cmd/upgrade/upgrade.go index 4a403f09..c3332ea5 100644 --- a/cmd/upgrade/upgrade.go +++ b/cmd/upgrade/upgrade.go @@ -11,12 +11,15 @@ import ( var example = ` dnote upgrade` +var deprecationWarning = `see https://github.com/dnote/cli/issues/96.` + func NewCmd(ctx infra.DnoteCtx) *cobra.Command { cmd := &cobra.Command{ - Use: "upgrade", - Short: "Upgrades dnote", - Example: example, - RunE: newRun(ctx), + Use: "upgrade", + Short: "Upgrades dnote", + Example: example, + RunE: newRun(ctx), + Deprecated: deprecationWarning, } return cmd diff --git a/cmd/version/version.go b/cmd/version/version.go index 7305eef1..0804a2aa 100644 --- a/cmd/version/version.go +++ b/cmd/version/version.go @@ -14,7 +14,7 @@ func NewCmd(ctx infra.DnoteCtx) *cobra.Command { Short: "Print the version number of Dnote", Long: "Print the version number of Dnote", Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("dnote v%s\n", core.Version) + fmt.Printf("dnote %s\n", core.Version) }, } diff --git a/core/core.go b/core/core.go index 48f20acc..57a36f38 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( const ( // Version is the current version of dnote - Version = "0.4.0" + Version = "master" // TimestampFilename is the name of the file containing upgrade info TimestampFilename = "timestamps" diff --git a/main.go b/main.go index eea765c5..e6b690c1 100644 --- a/main.go +++ b/main.go @@ -17,11 +17,11 @@ import ( "github.com/dnote/cli/cmd/edit" "github.com/dnote/cli/cmd/login" "github.com/dnote/cli/cmd/ls" - "github.com/dnote/cli/cmd/view" "github.com/dnote/cli/cmd/remove" "github.com/dnote/cli/cmd/sync" "github.com/dnote/cli/cmd/upgrade" "github.com/dnote/cli/cmd/version" + "github.com/dnote/cli/cmd/view" ) // apiEndpoint is populated during link time