Skip to content

Commit

Permalink
Merge pull request #17 from yuuki/improve_release
Browse files Browse the repository at this point in the history
Improve release
  • Loading branch information
yuuki authored Jun 17, 2019
2 parents e272eba + 421460f commit 35f8d80
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: false
language: go

go:
- 1.10.x
- 1.12

script:
- make test
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM golang:1.10
FROM golang:1.12

RUN go get github.com/laher/goxc
RUN mkdir -p /src
WORKDIR /src
COPY go.mod .
COPY go.sum .

ENV USER root
WORKDIR /go/src/github.com/yuuki/gokc

ADD . /go/src/github.com/yuuki/gokc
RUN go mod download
COPY . .
42 changes: 29 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
BIN := gokc
export GO111MODULE=on

PKG = github.com/yuuki/gokc
COMMIT = $$(git describe --tags --always)
DATE = $$(date --utc '+%Y-%m-%d_%H:%M:%S')
BUILD_LDFLAGS = -X $(PKG).commit=$(COMMIT) -X $(PKG).date=$(DATE)
RELEASE_BUILD_LDFLAGS = -s -w $(BUILD_LDFLAGS)

all: build

yacc: deps
goyacc -o parser/parser.go -v parser/parser.output parser/parser.go.y

build: yacc
go build -o $(BIN) ./cmd/...

buildlinux: yacc
GOOS=linux GOARCH=amd64 make build
go build -ldflags="$(BUILD_LDFLAGS)" $(PKG)/cmd/...

test: yacc
go test -v $$(go list ./... | grep -v vendor)
Expand All @@ -18,19 +21,32 @@ testfiles: build
find ./testdata -type f | xargs -I{} ./$(BIN) -f {}
find ./keepalived/doc/samples/keepalived.conf.* -type f | xargs -I{} ./$(BIN) -f {}

patch: gobump
./script/release.sh patch

minor: gobump
./script/release.sh minor

gobump:
go get github.com/motemen/gobump/cmd/gobump
.PHONY: devel-deps
devel-deps:
GO111MODULE=off go get -v \
golang.org/x/tools/cmd/cover \
github.com/mattn/goveralls \
github.com/motemen/gobump/cmd/gobump \
github.com/Songmu/ghch/cmd/ghch \
github.com/Songmu/goxz/cmd/goxz \
github.com/tcnksm/ghr \
github.com/Songmu/gocredits/cmd/gocredits

deps:
go get golang.org/x/tools/cmd/goyacc
go get -d -v ./...

.PHONY: crossbuild
crossbuild: devel-deps
$(eval ver = $(shell gobump show -r))
goxz -pv=v$(ver) -os=linux,darwin -arch=386,amd64 -build-ldflags="$(RELEASE_BUILD_LDFLAGS)" \
-d=./dist/v$(ver)

.PHONY: release
release: devel-deps
_tools/release
_tools/upload_artifacts

clean:
go clean

Expand Down
39 changes: 39 additions & 0 deletions _tools/credits
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -e -o pipefail

ROOT=$(dirname "${BASH_SOURCE}")/..
cd "${ROOT}"

echo '=========================================================================================='
echo "= lstf licensed under: ="
echo "https://github.com/yuuki/lstf/"
echo
cat "${ROOT}"/LICENSE
echo
echo "= LICENSE $(cat ${ROOT}/LICENSE | md5sum | awk '{print $1}')"
echo '=========================================================================================='
echo

echo "= Go (the standard library) licensed under: ="
echo "https://golang.org/"
echo
curl -sS https://raw.githubusercontent.com/golang/go/release-branch.go1.9/LICENSE 2>/dev/null
echo
echo '=========================================================================================='
echo

find_names=(-iname 'licen[sc]e*')
for repo in $(dep status -json | jq -rM '.[].ProjectRoot'); do
echo
echo '=========================================================================================='
echo "= vendor/${repo} licensed under: ="
echo "https://${repo}/"
for lic in $(find vendor/${repo} -xdev -follow -maxdepth 1 -type f "${find_names[@]}"); do
echo
cat "${lic}"
echo
echo "= ${lic} $(cat ${lic} | md5sum | awk '{print $1}')"
done
echo '=========================================================================================='
echo
done
21 changes: 21 additions & 0 deletions _tools/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -e

if [[ $(git status -s) != "" ]]; then
echo 2>&1 "git is currently in a dirty state"
exit 1
fi

current_version=$(gobump show -r)

echo "current version: $current_version"
read -p "input next version: " next_version

echo "--> Bumping version $next_version"
gobump set "$next_version" -w
echo "--> Generating CHANGELOG"
ghch -w -N "v$next_version"

git commit -am "Bump version $next_version"
git tag "v$next_version"
git push && git push --tags
6 changes: 6 additions & 0 deletions _tools/upload_artifacts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

ver=v$(gobump show -r)
make crossbuild
ghr -username yuuki -replace ${ver} dist/${ver}
2 changes: 1 addition & 1 deletion cmd/gokc/gokc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func main() {
flag.Parse()

if isVersion {
log.Infof("gokc version %s", Version)
log.Infof("gokc version %s", version)
os.Exit(0)
}

Expand Down
12 changes: 11 additions & 1 deletion cmd/gokc/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
package main

var Version string = "0.4.2"
// name is application name.
const name = "gokc"

// version is application version.
const version = "0.4.2"

// commit describes latest git commit hash.
// This is automatically extracted by git describe --always.
var commit string

var date string
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/yuuki/gokc

go 1.12

require (
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 // indirect
)
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 h1:QjA/9ArTfVTLfEhClDCG7SGrZkZixxWpwNCDiwJfh88=
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
20 changes: 0 additions & 20 deletions script/build_in_container.sh

This file was deleted.

15 changes: 0 additions & 15 deletions script/build_release.sh

This file was deleted.

27 changes: 0 additions & 27 deletions script/release.sh

This file was deleted.

0 comments on commit 35f8d80

Please sign in to comment.