Skip to content

Commit

Permalink
release: simplify release script
Browse files Browse the repository at this point in the history
  • Loading branch information
sacry-dyn committed Oct 11, 2016
1 parent 6bc561c commit b77e783
Showing 1 changed file with 19 additions and 37 deletions.
56 changes: 19 additions & 37 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,47 @@
set -e

# Usage
# PUBLISH_GEM=true RELEASE_VERSION=1.2.7 ./release.sh
# PUBLISH_GEM=true GENERATE_LIB=true RELEASE_VERSION=1.3.1 ./release.sh

if [[ -z "$RELEASE_VERSION" ]]; then echo "forgot to set a release version e.g. RELEASE_VERSION=x.y.z - latest version: lib/phraseapp-ruby/version.rb"; exit 1; fi

PHRASE_RUBY_REPO=git@github.com:phrase/phraseapp-ruby.git
PHRASE_RUBY_TMP=$(mktemp -d /tmp/phraseapp-ruby-lib-XXXX)

if [[ -z "$PHRASE_RUBY_TMP" ]]; then echo "unable to create tmp dir"; exit 1; fi

trap "rm -Rf $PHRASE_RUBY_TMP" EXIT


function write_version {
cat > lib/phraseapp-ruby/version.rb <<EOF
module PhraseApp
VERSION = '${1}'
end
EOF
}

function push_to_git {
current_branch=$(git symbolic-ref --short HEAD)
if [[ "$current_branch" != "$1" ]]; then
git checkout -b $1
fi

git add .
git commit -m "version bump: $1"
git push origin $1
}
trap "rm -Rf $PHRASE_RUBY_TMP" EXIT


# Release
git clone $PHRASE_RUBY_REPO $PHRASE_RUBY_TMP

pushd $PHRASE_RUBY_TMP > /dev/null

# tese fails
rake test
git checkout -b $RELEASE_VERSION

if [[ -z "$RELEASE_VERSION" ]]; then
current_version=$(cat lib/phraseapp-ruby/version.rb | grep VERSION | cut -d "=" -f 2 | xargs | tr -d '\r')
if [[ -z ${current_version// /} ]]; then
echo "unable to get version from lib/phraseapp-ruby/version.rb"; exit 1;
fi
RELEASE_VERSION=$current_version
# only generates if pa-client-gen installed and explicitly set
if [[ "$GENERATE_LIB" == "true" ]]; then
pa-client-gen generate ruby lib
fi

# bump version in lib/phraseapp-ruby/version.rb
write_version $RELEASE_VERSION
cat > lib/phraseapp-ruby/version.rb <<EOF
module PhraseApp
VERSION = '${RELEASE_VERSION}'
end
EOF

rake test

# generate documentation with yard
yard doc

# push version bump and documentation to orign/$RELEASE_VERSION
push_to_git $RELEASE_VERSION

# build Gem
gem build phraseapp-ruby.gemspec
git add . && git commit -m "version bump: $RELEASE_VERSION" && git push origin $RELEASE_VERSION

# Publish gem on Ruby Gems
# only publish gem if explicitly set
if [[ "$PUBLISH_GEM" == "true" ]]; then
gem build phraseapp-ruby.gemspec
gem push phraseapp-ruby-$RELEASE_VERSION.gem
fi

Expand Down

0 comments on commit b77e783

Please sign in to comment.