-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.sh
executable file
·33 lines (29 loc) · 1.7 KB
/
version.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
SERVER_META_INFO_PATH='./src/utils/ServerMetaInfo.ts'
SERVER_META_INFO_TEST_PATH='./src/utils/ServerMetaInfo.test.ts'
EXAMPLE_APP_PACKAGE_JSON_PATH='./example-app/package.json'
EXAMPLE_APP_PACKAGE_JSON_LOCK_PATH='./example-app/package-lock.json'
NEW_VERSION=$npm_package_version
if [ -n "$NEW_VERSION" ]; then
if [[ -f $SERVER_META_INFO_PATH && -f $SERVER_META_INFO_TEST_PATH && -f $EXAMPLE_APP_PACKAGE_JSON_PATH && $EXAMPLE_APP_PACKAGE_JSON_LOCK_PATH ]]; then
sed -i '' "s/NodeServerSDK\/v[0-9]*\.[0-9]*\.[0-9]*/NodeServerSDK\/v$NEW_VERSION/g" ${SERVER_META_INFO_PATH}
sed -i '' "s/NodeServerSDK\/v[0-9]*\.[0-9]*\.[0-9]*/NodeServerSDK\/v$NEW_VERSION/g" ${SERVER_META_INFO_TEST_PATH}
sed -i '' "s/\"pcp-server-nodejs-sdk\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"pcp-server-nodejs-sdk\": \"$NEW_VERSION\"/g" ${EXAMPLE_APP_PACKAGE_JSON_PATH}
sed -i '' "s/\"pcp-server-nodejs-sdk\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"pcp-server-nodejs-sdk\": \"$NEW_VERSION\"/g" ${EXAMPLE_APP_PACKAGE_JSON_LOCK_PATH}
git add $SERVER_META_INFO_PATH
git add $SERVER_META_INFO_TEST_PATH
git add $EXAMPLE_APP_PACKAGE_JSON_PATH
git add $EXAMPLE_APP_PACKAGE_JSON_LOCK_PATH
echo "Updated $SERVER_META_INFO_PATH with version $NEW_VERSION"
echo "Updated $SERVER_META_INFO_TEST_PATH with version $NEW_VERSION"
echo "Updated $EXAMPLE_APP_PACKAGE_JSON_PATH with version $NEW_VERSION"
echo "Updated $EXAMPLE_APP_PACKAGE_JSON_LOCK_PATH with version $NEW_VERSION"
else
echo "Could not find some files to update"
exit 1
fi
npm run changelog
git add CHANGELOG.md
echo "Updated CHANGELOG.md"
else
echo "Script can only be run as npm version hook"
fi