-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): bump version script (#28)
1 parent
947549a
commit eb79a16
Showing
2 changed files
with
50 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ -z "$BUMP_TYPE" ]]; then | ||
echo "Error: BUMP_TYPE is not set" | ||
exit 1 | ||
fi | ||
|
||
npm add --global semver | ||
SEMVER_BIN=$(which semver || echo "$(npm root --global)/.bin/semver") | ||
echo "semver bin: $SEMVER_BIN" | ||
|
||
# Define the package paths | ||
# assumes this is run with cwd as the root of the repo | ||
PACKAGES=( | ||
"./packages/record" | ||
"./packages/plugins/rrweb-plugin-console-record" | ||
"./packages/types" | ||
"./packages/rrweb" | ||
) | ||
|
||
# Loop through each package and update the package.json | ||
for PACKAGE in "${PACKAGES[@]}"; do | ||
PACKAGE_JSON="$PACKAGE/package.json" | ||
|
||
echo "Updating version in $PACKAGE_JSON" | ||
OLD_VERSION=$(jq ".version" "$PACKAGE_JSON" -r) | ||
echo "Old Version: $OLD_VERSION" | ||
|
||
NEW_VERSION=$($SEMVER_BIN "$OLD_VERSION" -i ""$BUMP_TYPE"") | ||
echo "New Version: $NEW_VERSION" | ||
|
||
if [ -f "$PACKAGE_JSON" ]; then | ||
echo "Updating version in $PACKAGE_JSON" | ||
mv "$PACKAGE_JSON" "$PACKAGE_JSON.old" || { echo "Failed to rename $PACKAGE_JSON"; exit 1; } | ||
jq --indent 4 '.version = "'$NEW_VERSION'"' "$PACKAGE_JSON.old" > "$PACKAGE_JSON" || { echo "Failed to update version in $PACKAGE_JSON"; exit 1; } | ||
rm "$PACKAGE_JSON.old" || { echo "Failed to remove backup file $PACKAGE_JSON.old"; exit 1; } | ||
else | ||
echo "Error: $PACKAGE_JSON does not exist" | ||
exit 1 | ||
fi | ||
done |