From b3e0397a2020a234b74efec7b98e4698909ea01d Mon Sep 17 00:00:00 2001 From: Prasad Ghangal Date: Wed, 15 Jan 2020 11:22:52 +0530 Subject: [PATCH] Add release script (#17) Signed-off-by: Prasad Ghangal --- .release | 1 + hack/release.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .release create mode 100755 hack/release.sh diff --git a/.release b/.release new file mode 100644 index 0000000..cc03ca2 --- /dev/null +++ b/.release @@ -0,0 +1 @@ +release=v0.0.0 diff --git a/hack/release.sh b/hack/release.sh new file mode 100755 index 0000000..125aadc --- /dev/null +++ b/hack/release.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +set -o errexit +set -e + +version=$(cut -d'=' -f2- .release) +if [[ -z ${version} ]]; then + echo "Invalid version set in .release" + exit 1 +fi + + +if [[ -z ${GITHUB_TOKEN} ]]; then + echo "GITHUB_TOKEN not set. Usage: GITHUB_TOKEN= ./hack/release.sh" + exit 1 +fi + +echo "Publishing release ${version}" + +generate_changelog() { + local version=$1 + + # generate changelog from github + github_changelog_generator infracloudio/msbotbuilder-go -t ${GITHUB_TOKEN} --future-release ${version} -o CHANGELOG.md + sed -i '$d' CHANGELOG.md +} + +publish_release() { + local version=$1 + + # create gh release + gothub release \ + --user infracloudio \ + --repo msbotbuilder-go \ + --tag $version \ + --name "$version" \ + --description "$version" +} + +make_release() { + local version=$1 + + # tag release + git add .release CHANGELOG.md + git commit -m "Release $version" ; + git tag $version ; + git push --tags origin develop; + echo 'Git tag pushed successfully' ; +} + +generate_changelog $version +make_release $version +publish_release $version + +echo "=========================== Done =============================" +echo "Congratulations!! Release ${version} published." +echo "Don't forget to add changelog in the release description." +echo "=============================================================="