scripts/prepare-release in recurly-3.28.0 vs scripts/prepare-release in recurly-4.0.0
- old
+ new
@@ -1,50 +1,36 @@
#!/usr/bin/env bash
-
-# Usage
-#
-# ./prepare-release major|minor|patch [--notes-out <path>] [--tag-out <path>]
-#
-
set -e
-if [ -n "$(git status --porcelain)" ]; then
- echo "Working directory is not clean. Aborting."
- exit 1
-fi
+# major,minor,patch
+PART=${1}
+NEXT_VERSION=$(./scripts/bump --next-version "$PART")
+UNRELEASED_LOG="/tmp/ruby-pending-changes.md"
-if [ -z "$GITHUB_TOKEN" ]; then
- echo "GITHUB_TOKEN must be set. Aborting."
- exit 1
-fi
+if [ -z "$NEXT_VERSION" ]; then
+ echo "Failed to get next version"
+else
+ # Generate pending changes in tmpfile
+ ./scripts/changelog --pending $UNRELEASED_LOG
+ # Add a git message header of Release X.Y.Z
+ printf "Release %s\n\n$(cat $UNRELEASED_LOG)" "$NEXT_VERSION" > $UNRELEASED_LOG
+ # Delete credit line
+ sed -i '' -e '$ d' $UNRELEASED_LOG
-# Bump version
-# major|minor|patch
-part=${1}
-if [ "$part" != "patch" ] && [ "$part" != "minor" ] && [ "$part" != "major" ]; then
- echo "'$part' is not a valid option: major|minor|patch"
- exit 1
-fi
-new_version=$(bump2version --list "$part" | grep new_version | cut -d "=" -f 2)
+ git checkout -b "release-$NEXT_VERSION"
-# Generate Changelog
-changelogly --future-release "$new_version"
+ # Actually bump the version
+ ./scripts/bump "$PART"
-while [[ "$#" -gt 0 ]]; do
- case $1 in
- # Create release notes artifact
- -n|--notes-out)
- echo "$new_version
+ # Rebuild docs
+ ./scripts/build
- $(
- cat CHANGELOG.md | sed -n "/^## \[$new_version\]/,/^##/p" | sed '$d;1d'
- )" | awk '{$1=$1};1' > $2
- shift
- ;;
+ # Make the commit
+ git add . --all
+ git commit -F "$UNRELEASED_LOG"
- # Create release notes artifact
- -t|--tag-out)
- echo "$new_version" > $2
- ;;
- esac
- shift
-done
+ # Push up this branch for PR
+ git push origin "release-$NEXT_VERSION"
+
+ # Create PR
+ hub pull-request -c -F "$UNRELEASED_LOG"
+fi