From ac88fa99fe38dd276be5e52f41d03909bccc4620 Mon Sep 17 00:00:00 2001 From: itchyny Date: Tue, 7 Jan 2020 19:52:49 +0900 Subject: [PATCH] initialize repository --- .github/workflows/ci.yaml | 20 ++++++++++ .github/workflows/release.yaml | 36 ++++++++++++++++++ .gitignore | 2 + LICENSE | 21 +++++++++++ Makefile | 69 ++++++++++++++++++++++++++++++++++ README.md | 1 + cmd/mmv/main.go | 7 ++++ go.mod | 3 ++ mmv.go | 1 + 9 files changed, 160 insertions(+) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 cmd/mmv/main.go create mode 100644 go.mod create mode 100644 mmv.go diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..fe7af90 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,20 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Setup Go + uses: actions/setup-go@v1 + with: + go-version: 1.x + - name: Test + run: make test + - name: Lint + run: | + export PATH=$PATH:$(go env GOPATH)/bin # will be removed + make lint diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..fb15c81 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,36 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@master + - name: Setup Go + uses: actions/setup-go@v1 + with: + go-version: 1.x + - name: Cross build + run: | + export PATH=$PATH:$(go env GOPATH)/bin # remove when actions/setup-go does this + make cross + - name: Create Release + id: create_release + uses: actions/create-release@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + - name: Upload + run: | + export PATH=$PATH:$(go env GOPATH)/bin # remove when actions/setup-go does this + make upload + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72fd037 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/goxz +/mmv diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7085e92 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 itchyny + +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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..18989f7 --- /dev/null +++ b/Makefile @@ -0,0 +1,69 @@ +BIN := mmv +VERSION := $$(make -s show-version) +VERSION_PATH := cmd/$(BIN) +BUILD_LDFLAGS := "-s -w" +GOBIN ?= $(shell go env GOPATH)/bin +export GO111MODULE=on + +.PHONY: all +all: clean build + +.PHONY: build +build: + go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) ./cmd/$(BIN) + +.PHONY: install +install: + go install -ldflags=$(BUILD_LDFLAGS) ./... + +.PHONY: show-version +show-version: $(GOBIN)/gobump + @gobump show -r $(VERSION_PATH) + +$(GOBIN)/gobump: + @cd && go get github.com/motemen/gobump/cmd/gobump + +.PHONY: cross +cross: $(GOBIN)/goxz + goxz -n $(BIN) -pv=v$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN) + +$(GOBIN)/goxz: + cd && go get github.com/Songmu/goxz/cmd/goxz + +.PHONY: test +test: build + go test -v ./... + +.PHONY: lint +lint: $(GOBIN)/golint + go vet ./... + golint -set_exit_status ./... + +$(GOBIN)/golint: + cd && go get golang.org/x/lint/golint + +.PHONY: clean +clean: + rm -rf $(BIN) goxz + go clean + +.PHONY: bump +bump: $(GOBIN)/gobump +ifneq ($(shell git status --porcelain),) + $(error git workspace is dirty) +endif +ifneq ($(shell git rev-parse --abbrev-ref HEAD),master) + $(error current branch is not master) +endif + @gobump up -w "$(VERSION_PATH)" + git commit -am "bump up version to $(VERSION)" + git tag "v$(VERSION)" + git push origin master + git push origin "refs/tags/v$(VERSION)" + +.PHONY: upload +upload: $(GOBIN)/ghr + ghr "v$(VERSION)" goxz + +$(GOBIN)/ghr: + cd && go get github.com/tcnksm/ghr diff --git a/README.md b/README.md new file mode 100644 index 0000000..80cf135 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# mmv [![CI Status](https://github.com/itchyny/mmv/workflows/CI/badge.svg)](https://github.com/itchyny/mmv/actions) diff --git a/cmd/mmv/main.go b/cmd/mmv/main.go new file mode 100644 index 0000000..f5ce850 --- /dev/null +++ b/cmd/mmv/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Print("mmv") +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..662f6f9 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/itchyny/mmv + +go 1.13 diff --git a/mmv.go b/mmv.go new file mode 100644 index 0000000..84e0e4b --- /dev/null +++ b/mmv.go @@ -0,0 +1 @@ +package mmv