This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yuriy Bogdanov
committed
Sep 8, 2015
0 parents
commit bbfacbb
Showing
438 changed files
with
65,586 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.git | ||
dist | ||
.dockerignore | ||
.rockertmp* | ||
Rockerfile | ||
pkg | ||
vendor/pkg | ||
Rockerfile.exec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dist | ||
bin | ||
*.a | ||
dev | ||
|
||
.iml | ||
.idea | ||
|
||
*.sublime-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(c) Copyright 2015 Grammarly, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
VERSION := 0.1.22 | ||
|
||
OSES := linux darwin | ||
ARCHS := amd64 | ||
BINARIES := rocker | ||
|
||
LAST_TAG = $(shell git describe --abbrev=0 --tags 2>/dev/null) | ||
GITCOMMIT = $(shell git rev-parse HEAD 2>/dev/null) | ||
GITBRANCH = $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) | ||
BUILDTIME = $(shell date "+%Y-%m-%d %H:%M GMT") | ||
|
||
GITHUB_USER := grammarly | ||
GITHUB_REPO := rocker | ||
GITHUB_RELEASE := docker run --rm -ti \ | ||
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \ | ||
-v /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt \ | ||
-v $(shell pwd)/dist:/dist \ | ||
dockerhub.grammarly.io/tools/github-release | ||
|
||
ALL_ARCHS := $(foreach os, $(OSES), $(foreach arch, $(ARCHS), $(os)/$(arch) )) | ||
ALL_BINARIES := $(foreach arch, $(ALL_ARCHS), $(foreach bin, $(BINARIES), dist/$(VERSION)/$(arch)/$(bin) )) | ||
OUT_BINARIES := $(foreach arch, $(ALL_ARCHS), $(foreach bin, $(BINARIES), dist/$(bin)_$(subst /,_,$(arch)) )) | ||
ALL_TARS := $(ALL_BINARIES:%=%.tar.gz) | ||
|
||
os = $(shell echo "$(1)" | awk -F/ '{print $$3}' ) | ||
arch = $(shell echo "$(1)" | awk -F/ '{print $$4}' ) | ||
bin = $(shell echo "$(1)" | awk -F/ '{print $$5}' ) | ||
|
||
UPLOAD_CMD = $(GITHUB_RELEASE) upload \ | ||
--user $(GITHUB_USER) \ | ||
--repo $(GITHUB_REPO) \ | ||
--tag $(VERSION) \ | ||
--name $(call bin,$(FILE))-$(VERSION)_$(call os,$(FILE))_$(call arch,$(FILE)).tar.gz \ | ||
--file $(FILE).tar.gz | ||
|
||
SRCS = $(shell git ls-files '*.go' | grep -v '^vendor/') | ||
PKGS := $(foreach pkg, $(sort $(dir $(SRCS))), ./$(pkg)) | ||
|
||
all: $(ALL_BINARIES) | ||
$(foreach BIN, $(BINARIES), $(shell cp dist/$(VERSION)/$(shell go env GOOS)/amd64/$(BIN) dist/$(BIN))) | ||
|
||
$(OUT_BINARIES): $(ALL_BINARIES) | ||
cp $< $@ | ||
|
||
release: $(ALL_TARS) | ||
git pull | ||
git push && git push --tags | ||
$(GITHUB_RELEASE) release \ | ||
--user $(GITHUB_USER) \ | ||
--repo $(GITHUB_REPO) \ | ||
--tag $(VERSION) \ | ||
--name $(VERSION) \ | ||
--description "https://github.com/$(GITHUB_USER)/$(GITHUB_REPO)/compare/$(LAST_TAG)...$(VERSION)" | ||
$(foreach FILE,$(ALL_BINARIES),$(UPLOAD_CMD);) | ||
|
||
tar: $(ALL_TARS) | ||
|
||
%.tar.gz: % | ||
COPYFILE_DISABLE=1 tar -jcvf $@ -C dist/$(VERSION)/$(call os,$<)/$(call arch,$<) $(call bin,$<) | ||
|
||
$(ALL_BINARIES): build_image | ||
docker run --rm -ti -v $(shell pwd)/dist:/src/dist \ | ||
-e GOOS=$(call os,$@) -e GOARCH=$(call arch,$@) -e GOPATH=/src:/src/vendor \ | ||
rocker-build:latest go build \ | ||
-ldflags "-X main.Version '$(VERSION)' -X main.GitCommit '$(GITCOMMIT)' -X main.GitBranch '$(GITBRANCH)' -X main.BuildTime '$(BUILDTIME)'" \ | ||
-v -o $@ src/cmd/$(call bin,$@)/main.go | ||
|
||
build_image: | ||
rocker build -f Rockerfile.build-cross | ||
|
||
docker_image: | ||
rocker build -var Version=$(VERSION) | ||
|
||
install: | ||
cp dist/$(VERSION)/$(shell go env GOOS)/amd64/rocker /usr/local/bin/rocker | ||
chmod +x /usr/local/bin/rocker | ||
|
||
clean: | ||
rm -Rf dist | ||
|
||
fmtcheck: | ||
$(foreach file,$(SRCS),gofmt $(file) | diff -u $(file) - || exit;) | ||
|
||
lint: | ||
@ go get -v github.com/golang/lint/golint | ||
$(foreach file,$(SRCS),golint $(file) || exit;) | ||
|
||
vet: | ||
@-go get -v golang.org/x/tools/cmd/vet | ||
$(foreach pkg,$(PKGS),go vet $(pkg);) | ||
|
||
gocyclo: | ||
@ go get -v github.com/fzipp/gocyclo | ||
gocyclo -over 25 ./src | ||
|
||
test: fmtcheck vet lint | ||
@ go get -v github.com/constabulary/gb/... | ||
gb test rocker/... | ||
|
||
.PHONY: clean build_image test fmtcheck lint vet gocyclo |
Oops, something went wrong.