Skip to content

Commit

Permalink
pl - fix publish script (stripe#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
pololi-stripe authored Aug 30, 2023
1 parent 2dbb980 commit cc0640c
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions scripts/publish
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,31 @@ 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
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" ]; then
valid=false

for type in "${ALLOWED_PRERELEASE_TYPES[@]}"; do
if [ "$type" = "$RELEASE_TYPE" ]; then
valid=true
break
fi
done

if [ "$valid" = false ]; 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
fi

# Make sure our working dir is the repo root directory
Expand Down

0 comments on commit cc0640c

Please sign in to comment.