Skip to content

Commit

Permalink
Add dry run flag to create-release for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
DTCurrie committed Sep 18, 2022
1 parent da0dc10 commit 4988c5d
Showing 1 changed file with 41 additions and 17 deletions.
58 changes: 41 additions & 17 deletions etc/create-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,56 @@ bump() {

# Set package.json version to next version and commit
echo "Bumping version to $next_ver"
npm pkg set version=$next_ver
git add .
git commit -m "Bump version to $next_ver"


# Get commits
latest_commit=$(git rev-parse "v${latest_ver}" 2>/dev/null )
head_commit=$(git rev-parse HEAD)

# Tag commits
if [ "$latest_commit" = "$head_commit" ]; then
echo "refusing to tag; $latest_ver already tagged for HEAD ($head_commit)"
if [ $dry != true ] ; then
npm pkg set version=$next_ver
git add .
git commit -m "Bump version to $next_ver"

# Get commits
latest_commit=$(git rev-parse "v${latest_ver}" 2>/dev/null )
head_commit=$(git rev-parse HEAD)

# Tag commits
if [ "$latest_commit" = "$head_commit" ]; then
echo "refusing to tag; $latest_ver already tagged for HEAD ($head_commit)"
else
echo "tagging v$next_ver $head_commit"
git tag "v$next_ver" $head_commit
fi
else
echo "tagging v$next_ver $head_commit"
git tag "v$next_ver" $head_commit
echo "EXECUTING DRY RUN - NO CHANGES WILL BE COMMITTED"

echo "npm pkg set version=$next_ver"
echo "git add ."
echo "git commit -m \"Bump version to $next_ver\""

# Get commits
echo "latest_commit=$(git rev-parse \"v${latest_ver}\" 2>/dev/null )"
echo "head_commit=DRY_RUN_NO_COMMIT"

# Tag commits
echo "tagging v$next_ver DRY_RUN_NO_COMMIT"
echo "git tag \"v$next_ver\" DRY_RUN_NO_COMMIT"
fi
}

usage() {
echo "Pass a bump type: major|minor|patch"
echo "Pass a bump type with the -t flag: major|minor|patch"
exit 1
}

case $1 in
while getopts t:d: flag
do
echo "flag: $flag ${OPTARG}"
case "${flag}" in
t) type=${OPTARG};;
d) dry=${OPTARG};;
esac
done

case $type in
major) bump 1 0 0;;
minor) bump 0 1 0;;
patch) bump 0 0 1;;
*) usage
esac
esac

0 comments on commit 4988c5d

Please sign in to comment.