Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preid support in publish script #434

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions scripts/publish
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ set -euo pipefail
IFS=$'\n\t'

RELEASE_TYPE=${1:-}
PREID=${2:-}

echo_help() {
cat << EOF
USAGE:
./scripts/publish <release_type>
./scripts/publish <release_type> <pre_id>

ARGS:
<release_type>
A Semantic Versioning release type used to bump the version number. Either "patch", "minor", "major", "prepatch", "preminor", "premajor", or "prerelease".
<pre_id>
Adds an identifier to be used to prefix premajor, preminor, prepatch or prerelease version increments. Either "alpha" or "beta".
EOF
}

Expand Down Expand Up @@ -105,6 +108,24 @@ case $RELEASE_TYPE in
;;
esac

# validate preid if passed
ALLOWED_PRERELEASE_TYPES=(prepatch preminor premajor prerelease)
if [ -n "$PREID" ]; then
if [ "$PREID" != "alpha" ] && [ "$PREID" != "beta" ]; then
echo "Invalid pre_id. It should be either 'alpha' or 'beta'"
echo ""
echo_help
exit 1
fi
if [ -n "$RELEASE_TYPE" ] && [[ ! " ${ALLOWED_PRERELEASE_TYPES[*]} " =~ "${RELEASE_TYPE}" ]]; then
ALLOWED_PRERELEASE_TYPES_STRING=$(printf "'%s', " "${ALLOWED_PRERELEASE_TYPES[@]}")
echo "Invalid release_type. It should be one of: $ALLOWED_PRERELEASE_TYPES_STRING when pre_id is set"
echo ""
echo_help
exit 1
fi
fi

# Make sure our working dir is the repo root directory
cd "$(git rev-parse --show-toplevel)"

Expand Down Expand Up @@ -134,8 +155,14 @@ yarn -s install --frozen-lockfile
echo "Running tests"
yarn -s run test

echo "Bumping package.json $RELEASE_TYPE version and tagging commit"
yarn -s version --$RELEASE_TYPE
if [ -n "$PREID" ]; then
echo "Bumping package.json $RELEASE_TYPE, $PREID version and tagging commit"
yarn -s version --$RELEASE_TYPE --preid $PREID
else
echo "Bumping package.json $RELEASE_TYPE version and tagging commit"
yarn -s version --$RELEASE_TYPE
fi


create_github_release
verify_commit_is_signed
Expand Down
Loading