Merge pull request #40 from kenjones-cisco/task/releasing

Task: Add release process
This commit is contained in:
Kenny Jones 2017-09-24 21:13:06 -04:00 committed by GitHub
commit 3b03a0852a
4 changed files with 48 additions and 0 deletions

View File

@ -107,6 +107,10 @@ build-docs: prepare mkdocs.yml mkdocs/*
@find docs -type d -exec chmod 755 {} \; || : @find docs -type d -exec chmod 755 {} \; || :
@find docs -type f -exec chmod 644 {} \; || : @find docs -type f -exec chmod 644 {} \; || :
.PHONY: release
release: xcompile
${DOCKRUN} bash ./scripts/publish.sh
# ---------------------------------------------- # ----------------------------------------------
# utilities # utilities

View File

@ -8,6 +8,8 @@ LDFLAGS :=
LDFLAGS += -X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} LDFLAGS += -X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}
LDFLAGS += -X main.GitDescribe=${GIT_DESCRIBE} LDFLAGS += -X main.GitDescribe=${GIT_DESCRIBE}
GITHUB_TOKEN ?=
# Windows environment? # Windows environment?
CYG_CHECK := $(shell hash cygpath 2>/dev/null && echo 1) CYG_CHECK := $(shell hash cygpath 2>/dev/null && echo 1)
ifeq ($(CYG_CHECK),1) ifeq ($(CYG_CHECK),1)
@ -29,6 +31,7 @@ DEV_IMAGE := ${PROJECT}_dev
DOCKRUN := docker run --rm \ DOCKRUN := docker run --rm \
-e LDFLAGS="${LDFLAGS}" \ -e LDFLAGS="${LDFLAGS}" \
-e GITHUB_TOKEN="${GITHUB_TOKEN}" \
-v ${ROOT}/vendor:/go/src \ -v ${ROOT}/vendor:/go/src \
-v ${ROOT}:/${PROJECT}/src/${IMPORT_PATH} \ -v ${ROOT}:/${PROJECT}/src/${IMPORT_PATH} \
-w /${PROJECT}/src/${IMPORT_PATH} \ -w /${PROJECT}/src/${IMPORT_PATH} \

View File

@ -4,6 +4,7 @@ go get -u github.com/alecthomas/gometalinter
go get -u golang.org/x/tools/cmd/goimports go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/mitchellh/gox go get -u github.com/mitchellh/gox
go get -u github.com/kardianos/govendor go get -u github.com/kardianos/govendor
go get -u github.com/aktau/github-release
# install all the linters # install all the linters
gometalinter --install --update gometalinter --install --update

40
scripts/publish.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
GITHUB_TOKEN="${GITHUB_TOKEN:?missing required input \'GITHUB_TOKEN\'}"
CURRENT="$(git describe --tags --abbrev=0)"
PREVIOUS="$(git describe --tags --abbrev=0 --always "${CURRENT}"^)"
OWNER="mikefarah"
REPO="yaml"
release() {
mapfile -t logs < <(git log --pretty=oneline --abbrev-commit "${PREVIOUS}".."${CURRENT}")
description="$(printf '%s\n' "${logs[@]}")"
github-release release \
--user "$OWNER" \
--repo "$REPO" \
--tag "$CURRENT" \
--description "$description" ||
github-release edit \
--user "$OWNER" \
--repo "$REPO" \
--tag "$CURRENT" \
--description "$description"
}
upload() {
mapfile -t files < <(find ./build -mindepth 1 -maxdepth 1)
for file in "${files[@]}"; do
BINARY=$(basename "${file}")
echo "--> ${BINARY}"
github-release upload \
--user "$OWNER" \
--repo "$REPO" \
--tag "$CURRENT" \
--name "${BINARY}" \
--file "$file"
done
}
release
upload