Update the release script

This updates the release script to add the changelog gem as well as
clean up some of the scripts.

This also updates the binaries being uploaded and the messages being
passed onto the tag description on GitHub.
This commit is contained in:
Charlie Drage 2017-01-27 15:56:15 -05:00
parent 3f10691838
commit 576e2c7d37

View File

@ -23,9 +23,9 @@ usage() {
echo "" echo ""
echo "Requirements:" echo "Requirements:"
echo " git" echo " git"
echo " tar - you should already have this on your system"
echo " hub" echo " hub"
echo " github-release" echo " github-release"
echo " github_changelog_generator"
echo " GITHUB_TOKEN in your env variable" echo " GITHUB_TOKEN in your env variable"
echo " " echo " "
echo "Not only that, but you must have permission for:" echo "Not only that, but you must have permission for:"
@ -44,6 +44,11 @@ requirements() {
return 1 return 1
fi fi
if [ ! -f /usr/local/bin/github_changelog_generator ]; then
echo "github_changelog_generator required to generate the change log. Please run 'gem install github_changelog_generator"
return 1
fi
if [ ! -f /usr/bin/hub ]; then if [ ! -f /usr/bin/hub ]; then
echo "Hub needed in order to create the relevant PR's. Please install hub @ https://github.com/github/hub" echo "Hub needed in order to create the relevant PR's. Please install hub @ https://github.com/github/hub"
return 1 return 1
@ -74,9 +79,13 @@ replaceversion() {
cd $CLI cd $CLI
echo "1. Replaced version in version.go" echo "1. Replaced version in version.go"
find . -name 'version.go' -maxdepth 3 -type f -exec sed -i "s/$1/$2/g" {} \; sed -i "s/$1/$2/g" cmd/version.go
echo "2. Replaced README.md versioning" echo "2. Replace GITCOMMIT value in version.go"
VERSION=`git log -1 --pretty=format:%h`
sed -i "s|.*GITCOMMIT = .*|\tGITCOMMIT = \"$VERSION\"|" cmd/version.go
echo "3. Replaced README.md versioning"
sed -i "s/$1/$2/g" README.md sed -i "s/$1/$2/g" README.md
cd .. cd ..
@ -84,25 +93,20 @@ replaceversion() {
changelog() { changelog() {
cd $CLI cd $CLI
echo "Getting commit changes. Writing to ../changes.txt" echo "Generating changelog using github-changelog-generator"
LOG=`git shortlog --email --no-merges --pretty=%s v${1}..` github_changelog_generator $UPSTREAM_REPO/$CLI -t $GITHUB_TOKEN --future-release v$1
echo -e "\`\`\`\n$LOG\n\`\`\`" > ../changes.txt
echo "Changelog has been written to changes.txt"
echo "!!PLEASE REVIEW BEFORE CONTINUING!!"
echo "Open changes.txt and add the release information"
echo "to the beginning of the file before the git shortlog"
cd .. cd ..
} }
changelog_md() { changelog_github() {
echo "Generating CHANGELOG.md" touch changes.txt
CHANGES=$(cat changes.txt) echo "Write your GitHub changelog here" >> changes.txt
$EDITOR changes.txt
}
build_binaries() {
cd $CLI cd $CLI
DATE=$(date +"%m-%d-%Y") make cross
CHANGELOG=$(cat CHANGELOG.md)
HEADER="## $CLI $1 ($DATE)"
echo -e "$HEADER\n\n$CHANGES\n\n$CHANGELOG" >CHANGELOG.md
echo "Changes have been written to CHANGELOG.md"
cd .. cd ..
} }
@ -137,6 +141,8 @@ git_pull() {
push() { push() {
CHANGES=$(cat changes.txt) CHANGES=$(cat changes.txt)
# Release it! # Release it!
echo "Creating GitHub tag"
github-release release \ github-release release \
--user $UPSTREAM_REPO \ --user $UPSTREAM_REPO \
--repo $CLI \ --repo $CLI \
@ -144,24 +150,30 @@ push() {
--name "v$1" \ --name "v$1" \
--description "$CHANGES" --description "$CHANGES"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo RELEASE UPLOAD OK echo UPLOAD OK
else else
echo RELEASE UPLOAD FAIL echo UPLOAD FAIL
exit exit
fi fi
# Upload all the binaries generated in bin/
for f in $CLI/bin/*
do
echo "Uploading $f binary"
NAME=`echo $f | sed "s,$CLI/bin/,,g"`
github-release upload \ github-release upload \
--user $UPSTREAM_REPO \ --user $UPSTREAM_REPO \
--repo $CLI \ --repo $CLI \
--tag $1 \ --tag v$1 \
--name "$CLI-$1.tar.gz" \ --file $f \
--file $CLI-$1.tar.gz --name $NAME
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo TARBALL UPLOAD OK echo UPLOAD OK
else else
echo TARBALL UPLOAD FAIL echo UPLOAD FAIL
exit exit
fi fi
done
echo "DONE" echo "DONE"
echo "DOUBLE CHECK IT:" echo "DOUBLE CHECK IT:"
@ -207,10 +219,10 @@ main() {
"Git clone master" "Git clone master"
"Replace version number" "Replace version number"
"Generate changelog" "Generate changelog"
"Generate changelog for release" "Generate GitHub changelog"
"Create PR" "Create PR"
"Git pull most recent changes" "Build binaries"
"Upload the tarball and push to Github release page" "Upload the binaries and push to GitHub release page"
"Clean" "Clean"
"Quit") "Quit")
select opt in "${options[@]}" select opt in "${options[@]}"
@ -224,18 +236,18 @@ main() {
replaceversion $PREV_VERSION $VERSION replaceversion $PREV_VERSION $VERSION
;; ;;
"Generate changelog") "Generate changelog")
changelog $PREV_VERSION changelog $VERSION
;; ;;
"Generate changelog for release") "Generate GitHub changelog")
changelog_md $VERSION changelog_github $VERSION
;; ;;
"Create PR") "Create PR")
git_commit $VERSION git_commit $VERSION
;; ;;
"Git pull most recent changes") "Build binaries")
git_pull build_binaries
;; ;;
"Upload the tarball and push to Github release page") "Upload the binaries and push to GitHub release page")
push $VERSION push $VERSION
;; ;;
"Clean") "Clean")