diff --git a/.gitignore b/.gitignore index ba077a4..e493dd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ bin +dist diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..efae3cd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +## v0.1.0 [2017-05-14] + +# Release Notes + +This is the initial release of Mangaeden. diff --git a/Makefile b/Makefile index 7904b0e..b9b32e4 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,40 @@ +VERSION := $(shell sh -c 'git describe --always --tags') +LDFLAGS := -ldflags "-X main.version=$(VERSION)" + all: build -build: *.go cmd/mangaeden/*.go - mkdir -p bin - cd cmd/mangaeden/ && go build - mv cmd/mangaeden/mangaeden bin/mangaeden +build: *.go cmd/mangaeden/*.go clean-build + cd cmd/mangaeden/ && go build -o ../../bin/mangaeden $(LDFLAGS) + +define go_dist + mkdir -p dist/mangaeden-$(VERSION)_$1_$2/ + cd dist/mangaeden-$(VERSION)_$1_$2/ && GOOS=$1 GOARCH=$2 go build -v $(LDFLAGS) github.com/kmwenja/mangaeden/cmd/mangaeden + if [ "$1" = "windows" ]; then \ + cd dist/ && zip mangaeden-$(VERSION)_$1_$2.zip mangaeden-$(VERSION)_$1_$2/*; \ + else \ + cd dist/ && tar -cvzf mangaeden-$(VERSION)_$1_$2.tar.gz mangaeden-$(VERSION)_$1_$2/*; \ + fi +endef + +dist: clean-dist dist-linux dist-macos dist-windows + +dist-macos: + $(call go_dist,darwin,amd64) + +dist-linux: + $(call go_dist,linux,amd64) + $(call go_dist,linux,386) + +dist-windows: + go get -v github.com/inconshreveable/mousetrap + $(call go_dist,windows,amd64) + +clean: clean-build clean-dist + +clean-build: + rm -rf ./bin -clean: - rm -r bin +clean-dist: + rm -rf ./dist -.PHONY = clean +.PHONY = clean clean-build clean-dist dist dist-linux dist-macos dist-windows diff --git a/README.md b/README.md index 6444e71..561c9b8 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ Make sure to checkout [Mangaeden](www.mangaeden.com). All manga content belongs Install ------- +**Prebuilt binaries** + +See [Releases](https://github.com/kmwenja/mangaeden/releases) for Linux, Windows and Mac OS X binaries. + +**From Source** + 1. `go get -v github.com/kmwenja/mangaeden/cmd/mangaeden/` 2. `go install github.com/kmwenja/mangaeden/cmd/mangaeden/` @@ -44,6 +50,7 @@ Hacking 3. Hack hack hack. 4. Build binary: `make` 5. Run the binary: `bin/mangaeden` +6. Make release: `make dist` `github.com/kmwenja/mangaeden` has the client and supporting structs. `github.com/kmwenja/mangaeden/cmd/mangaeden/` has the cli code, built with [Cobra](https://github.com/spf13/cobra). diff --git a/cmd/mangaeden/download.go b/cmd/mangaeden/download.go index 1768111..5688cfc 100644 --- a/cmd/mangaeden/download.go +++ b/cmd/mangaeden/download.go @@ -30,7 +30,7 @@ func DownloadCmd() *cobra.Command { var cmd = &cobra.Command{ Use: "download [manga id]", - Short: "Download a manga", + Short: "Download the manga with the id provided", Run: func(ccmd *cobra.Command, args []string) { if len(args) < 1 { ccmd.HelpFunc()(ccmd, args) diff --git a/cmd/mangaeden/main.go b/cmd/mangaeden/main.go index 093e978..4bf217d 100644 --- a/cmd/mangaeden/main.go +++ b/cmd/mangaeden/main.go @@ -7,17 +7,27 @@ import ( "github.com/spf13/cobra" ) +var version string + func main() { var RootCmd = &cobra.Command{ Use: "mangaeden", Short: "Mangaeden is a CLI for the Mangaeden API", - Long: `Mangeden is a simple lookup and download CLI - for the Mangaeden API`, + Long: `Mangeden is a simple lookup and download CLI for the Mangaeden API. Make sure to checkout www.mangaeden.com`, + } + + var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print out the version of this app", + Run: func(ccmd *cobra.Command, args []string) { + fmt.Printf("%s\n", version) + }, } RootCmd.AddCommand(ListCmd()) RootCmd.AddCommand(InfoCmd()) RootCmd.AddCommand(DownloadCmd()) + RootCmd.AddCommand(versionCmd) if err := RootCmd.Execute(); err != nil { fmt.Println(err)