-
-
Save rayrutjes/485d637adadb3898ed02313d420b9db3 to your computer and use it in GitHub Desktop.
Example of release-pr script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
readonly CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [ "$CURRENT_BRANCH" != master ]; then | |
echo "You must be on 'master' branch to publish a release, aborting..." | |
exit 1 | |
fi | |
if ! git diff-index --quiet HEAD --; then | |
echo "Working tree is not clean, aborting..." | |
exit 1 | |
fi | |
if ! yarn; then | |
echo "Failed to install yarn dependencies, aborting..." | |
exit 1 | |
fi | |
if ! yarn test; then | |
echo "Tests failed, aborting..." | |
exit 1 | |
fi | |
yarn run changelog:unreleased | |
# Only update the package.json version | |
# We need to update changelog before tagging | |
# And publishing. | |
yarn version --no-git-tag-version | |
if ! yarn run changelog; then | |
echo "Failed to update changelog, aborting..." | |
exit 1 | |
fi | |
readonly PACKAGE_VERSION=$(< package.json grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g' \ | |
| tr -d '[:space:]') | |
git checkout -b "chore/release-$PACKAGE_VERSION" | |
# Gives user a chance to review and eventually abort. | |
git add --patch | |
git commit --message="chore(release): v$PACKAGE_VERSION" | |
git push origin HEAD | |
echo "Your release branch 'chore/release-$PACKAGE_VERSION' is now ready for review..." | |
git open > /dev/null 2>&1 || echo "Install https://github.com/paulirish/git-open so that next times it opens the browser at the repository URL." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment