-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.sh
executable file
·69 lines (55 loc) · 2.08 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
npm run build
# Get the version of supertokens-auth-react from package.json
version=$(grep -o '"supertokens-auth-react": "[^"]*"' package.json | sed -E 's/.*: "([^"]+)".*/\1/')
if [ -z "$version" ]; then
echo "Error: supertokens-auth-react version not found in package.json"
exit 1
fi
# Get the new file name from the build folder
new_file_name=$(grep -o '"main.js": "[^"]*"' build/asset-manifest.json | sed -E 's/.*: "([^"]+)".*/\1/')
if [ -z "$new_file_name" ]; then
echo "Error: main.js file not found in build/asset-manifest.json"
exit 1
fi
# Remove the leading slash from the file name
new_file_name=${new_file_name#/}
# Update the README.md file
old_pattern="https://cdn.jsdelivr.net/gh/supertokens/prebuiltui.*\""
new_pattern="https://cdn.jsdelivr.net/gh/supertokens/prebuiltui@v${version}/build/${new_file_name}\""
if grep -q "$old_pattern" README.md; then
sed -i.bak "s|$old_pattern|$new_pattern|g" README.md
if [ $? -eq 0 ]; then
rm README.md.bak
echo "README.md has been updated with the new version and file name"
else
echo "Error: Failed to update README.md"
exit 1
fi
else
echo "Error: Old pattern not found in README.md"
exit 1
fi
# Commit the changes
git add --all
git commit -m "Release prep"
# Create and push the new tag
git tag "v${version}"
git push origin "v${version}"
git push
# set $SUPERTOKENS_API_KEY based on reading ./releasePassword file
SUPERTOKENS_API_KEY=$(cat ./releasePassword)
responseStatus=$(curl -o /dev/null -s -w "%{http_code}" -X PUT \
https://api.supertokens.io/0/frontend/auth-react \
-H 'Content-Type: application/json' \
-H 'api-version: 0' \
-d "{
\"uri\": \"https://cdn.jsdelivr.net/gh/supertokens/prebuiltui@v${version}/build/${new_file_name}\",
\"password\": \"$SUPERTOKENS_API_KEY\"
}")
if [ "$responseStatus" -ne 200 ]
then
echo "failed PUT API to update js deliver uri on server with status code: $responseStatus. You need to manually call this API with the right url!"
exit 1
fi
echo "Successfully created and pushed tag v${version}"