Skip to content

Commit

Permalink
Merge pull request #40 from kenjones-cisco/task/releasing
Browse files Browse the repository at this point in the history
Task: Add release process
  • Loading branch information
kenjones-cisco authored Sep 25, 2017
2 parents 9d1a5b1 + a00e6c5 commit 3b03a08
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ build-docs: prepare mkdocs.yml mkdocs/*
@find docs -type d -exec chmod 755 {} \; || :
@find docs -type f -exec chmod 644 {} \; || :

.PHONY: release
release: xcompile
${DOCKRUN} bash ./scripts/publish.sh

# ----------------------------------------------
# utilities

Expand Down
3 changes: 3 additions & 0 deletions Makefile.variables
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ LDFLAGS :=
LDFLAGS += -X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}
LDFLAGS += -X main.GitDescribe=${GIT_DESCRIBE}

GITHUB_TOKEN ?=

# Windows environment?
CYG_CHECK := $(shell hash cygpath 2>/dev/null && echo 1)
ifeq ($(CYG_CHECK),1)
Expand All @@ -29,6 +31,7 @@ DEV_IMAGE := ${PROJECT}_dev

DOCKRUN := docker run --rm \
-e LDFLAGS="${LDFLAGS}" \
-e GITHUB_TOKEN="${GITHUB_TOKEN}" \
-v ${ROOT}/vendor:/go/src \
-v ${ROOT}:/${PROJECT}/src/${IMPORT_PATH} \
-w /${PROJECT}/src/${IMPORT_PATH} \
Expand Down
1 change: 1 addition & 0 deletions scripts/devtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go get -u github.com/alecthomas/gometalinter
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/mitchellh/gox
go get -u github.com/kardianos/govendor
go get -u github.com/aktau/github-release

# install all the linters
gometalinter --install --update
40 changes: 40 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3b03a08

Please sign in to comment.