Skip to content

Commit

Permalink
Merge pull request #70 from masutaka/golang
Browse files Browse the repository at this point in the history
Introduce golang
  • Loading branch information
masutaka authored Oct 13, 2017
2 parents 6df9438 + a49f090 commit 0005fe6
Show file tree
Hide file tree
Showing 47 changed files with 1,376 additions and 1,084 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.gem
/.bundle
/.envrc
/.yardoc
/doc
/vendor/bundle
/github-nippou
/lib/bindata.go
/pkg
/vendor
2 changes: 0 additions & 2 deletions .rspec

This file was deleted.

20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
language: ruby
rvm:
- 2.4.1
- 2.3.4
before_install: gem install -N bundler
before_script: bin/validate-version.sh
language: go

go:
- 1.9.1

os:
- linux
- osx

install:
- echo "skipping travis default"

script:
- make test-all
9 changes: 0 additions & 9 deletions Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions Gemfile

This file was deleted.

70 changes: 0 additions & 70 deletions Gemfile.lock

This file was deleted.

75 changes: 75 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
branch = "master"
name = "github.com/google/go-github"

[[constraint]]
branch = "master"
name = "github.com/skratchdot/open-golang"

[[constraint]]
branch = "master"
name = "github.com/spf13/cobra"

[[constraint]]
branch = "master"
name = "golang.org/x/oauth2"

[[constraint]]
branch = "v2"
name = "gopkg.in/yaml.v2"
115 changes: 115 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
NAME := github-nippou
SRCS := $(shell find . -type f ! -path ./lib/bindata.go -name '*.go')
CONFIGS := $(wildcard config/*)
VERSION := v$(shell grep 'const Version ' lib/version.go | sed -E 's/.*"(.+)"$$/\1/')
PACKAGES := $(shell go list ./...)

all: $(NAME)

# Install dependencies for development
.PHONY: deps
deps: dep go-bindata gox ghr
dep ensure

.PHONY: dep
dep:
ifeq ($(shell command -v dep 2> /dev/null),)
go get github.com/golang/dep/cmd/dep
endif

.PHONY: go-bindata
go-bindata:
ifeq ($(shell command -v go-bindata 2> /dev/null),)
go get github.com/jteeuwen/go-bindata/...
endif

.PHONY: gox
gox:
ifeq ($(shell command -v gox 2> /dev/null),)
go get github.com/mitchellh/gox
endif

.PHONY: ghr
ghr:
ifeq ($(shell command -v ghr 2> /dev/null),)
go get github.com/tcnksm/ghr
endif

# Build binary
$(NAME): lib/bindata.go $(SRCS)
go build -o $(NAME)

lib/bindata.go: $(CONFIGS)
go-bindata -nocompress -pkg lib -o lib/bindata.go config

# Install binary to $GOPATH/bin
.PHONY: install
install:
go install

# Clean binary
.PHONY: clean
clean:
rm -f $(NAME)

# Test for development
.PHONY: test
test:
go test -v $(PACKAGES)

# Test for CI
.PHONY: test-all
test-all: deps-ci vet lint test

.PHONY: deps-ci
deps-ci: golint

.PHONY: golint
golint:
ifeq ($(shell command -v golint 2> /dev/null),)
go get github.com/golang/lint/golint
endif

.PHONY: vet
vet:
go vet $(PACKAGES)

.PHONY: lint
lint:
echo $(PACKAGES) | xargs -n1 golint

# Generate binary archives for GitHub release
.PHONY: dist
dist: cross-build
if [ -d pkg ]; then \
rm -rf pkg/dist; \
fi

mkdir -p pkg/dist/$(VERSION)

for PLATFORM in $$(find pkg -mindepth 1 -maxdepth 1 -type d); do \
PLATFORM_NAME=$$(basename $$PLATFORM); \
ARCHIVE_NAME=$(NAME)_$(VERSION)_$${PLATFORM_NAME}; \
\
if [ $$PLATFORM_NAME = "dist" ]; then \
continue; \
fi; \
\
pushd $$PLATFORM; \
zip $(CURDIR)/pkg/dist/$(VERSION)/$${ARCHIVE_NAME}.zip *; \
popd; \
done

pushd pkg/dist/$(VERSION); \
shasum -a 256 * > $(VERSION)_SHASUMS; \
popd

.PHONY: cross-build
cross-build: deps lib/bindata.go
rm -rf pkg/*
gox -os="darwin linux windows" -arch="386 amd64" -output "pkg/{{.OS}}_{{.Arch}}/{{.Dir}}"

# Release binary archives to GitHub
.PHONY: release
release:
ghr $(VERSION) pkg/dist/$(VERSION)
Loading

0 comments on commit 0005fe6

Please sign in to comment.