Skip to content

Commit 6c19e60

Browse files
Merge pull request #319 from stripe/updated-web-sdk-release-script
chore: updated web-sdk release script
2 parents 8e7f936 + 4f68b6e commit 6c19e60

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

firestore-stripe-web-sdk/deploy.sh

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,37 @@ RED_BG=$(tput setab 1)
88
YELLOW=$(tput setaf 3)
99
RESET=$(tput sgr 0)
1010
BOLD=$(tput bold)
11+
FIREBASE_WEB_SDK_DIR="firestore-stripe-web-sdk"
12+
MIN_NODE_VERSION="12"
13+
14+
# verify we are in the correct directory for the script
15+
if [[ "${PWD##*/}" != "${FIREBASE_WEB_SDK_DIR}" ]]; then
16+
echo "${RED}ERROR:${RESET} Please run this script in the ${FIREBASE_WEB_SDK_DIR} directory"
17+
exit 1
18+
fi
1119

1220
# verify we meant to run this script
1321
read -r -n 1 -p "${YELLOW}WARNING:${RESET} running this script deploys changes publicly. Are you sure you want to continue? [y/n] "
1422
echo
1523
echo
1624
if [[ ! "${REPLY}" =~ ^[Yy]$ ]]; then exit 1; fi
1725

18-
# verify the user has required permissions
26+
# verify that we have updated the patch/release version
27+
public_sdk_version=$(npm view @stripe/firestore-stripe-payments version)
28+
local_sdk_version=$(npm version | sed -n '2'p | cut -d : -f 2 | cut -d , -f 1 | cut -d \' -f 2)
29+
if [[ "${public_sdk_version}" == "${local_sdk_version}" ]]; then
30+
echo "${RED}ERROR:${RESET} Your local web-sdk version matches the public web-sdk version. Please bump the version with ${BOLD}npm version patch${RESET} or a similar command"
31+
exit 1
32+
fi
33+
34+
echo "${GREEN}SUCCESS:${RESET} your local web-sdk version is different from the public web-sdk version"
35+
echo
36+
echo "local web-sdk version is ${YELLOW}${local_sdk_version}${RESET}"
37+
echo "public web-sdk version is ${GREEN}${public_sdk_version}${RESET}"
38+
echo
39+
echo
40+
41+
# verify the user has required npm permissions
1942
read -r -n 1 -p "Do you have a stripe npm account with 2FA? [y/n] "
2043
echo
2144
echo
@@ -25,14 +48,14 @@ if [[ ! "${REPLY}" =~ ^[Yy]$ ]]; then
2548
fi
2649

2750
version=$(nodenv version | cut -d . -f 1)
28-
if [ ! "${version}" -gt "12" ]; then
29-
echo "${RED}ERROR:${RESET} must have node version 12 or greater"
51+
if [ ! "${version}" -gt "${MIN_NODE_VERSION}" ]; then
52+
echo "${RED}ERROR:${RESET} must have node version ${MIN_NODE_VERSION} or greater"
3053
echo "current version is ${YELLOW}$(nodenv version | cut -d ' ' -f 1)${RESET}"
3154
echo
32-
echo "set new node version with ${BOLD}nodenv shell 14.7.0${RESET} or any other installed version 12 or greater to continue"
55+
echo "set new node version with ${BOLD}nodenv shell 14.7.0${RESET} or any other installed version ${MIN_NODE_VERSION} or greater to continue"
3356
exit 1
3457
fi
35-
echo "${GREEN}SUCCESS:${RESET} your current node version is 12 or greater (${GREEN}$(nodenv version | cut -d ' ' -f 1)${RESET})"
58+
echo "${GREEN}SUCCESS:${RESET} your current node version is ${MIN_NODE_VERSION} or greater (${GREEN}$(nodenv version | cut -d ' ' -f 1)${RESET})"
3659
echo
3760

3861
if ! npm team ls @stripe:developers &> /dev/null; then
@@ -76,10 +99,12 @@ echo
7699
echo "${GREEN}SUCCESS:${RESET} all tests have passed"
77100
echo
78101

79-
if ! rm stripe-firestore-stripe-payments-*.tgz; then
80-
echo
81-
echo "${RED}ERROR:${RESET} encountered an error removing old release artifacts"
82-
exit 1
102+
if [[ $(ls stripe-firestore-stripe-payments-*.tgz) ]]; then
103+
if ! rm stripe-firestore-stripe-payments-*.tgz; then
104+
echo
105+
echo "${RED}ERROR:${RESET} encountered an error removing old release artifacts"
106+
exit 1
107+
fi
83108
fi
84109

85110
if ! npm run build; then
@@ -98,6 +123,7 @@ echo
98123
echo "${GREEN}SUCCESS:${RESET} built the release artifact"
99124
echo
100125

126+
# verify one last time
101127
read -r -n 1 -p "Did you notify #developer-products and #developer-advocacy about this release? [y/n] "
102128
echo
103129
echo

0 commit comments

Comments
 (0)