forked from AlexW00/obsidian-3d-graph
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hananoshika Yomaru
committed
Oct 28, 2023
1 parent
cbb08c4
commit 2c721b4
Showing
3 changed files
with
53 additions
and
14 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
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 |
---|---|---|
@@ -1,31 +1,70 @@ | ||
# get the version number in manifest.json | ||
MANINEST_VERSION=$(jq -r '.version' manifest.json) | ||
#!/bin/bash | ||
|
||
# get the package json version | ||
VERSION=$(node -p -e "require('./package.json').version") | ||
# Parse command-line arguments | ||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
case $key in | ||
-m | --minor) | ||
UPDATE_TYPE="minor" | ||
shift | ||
;; | ||
-p | --patch) | ||
UPDATE_TYPE="patch" | ||
shift | ||
;; | ||
-M | --major) | ||
UPDATE_TYPE="major" | ||
shift | ||
;; | ||
*) | ||
echo "Unknown option: $key" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# if version != manifest.json version then exit | ||
if [ "$VERSION" != "$MANINEST_VERSION" ]; then | ||
# Get the version number from manifest.json | ||
MANIFEST_VERSION=$(jq -r '.version' manifest.json) | ||
|
||
# Get the version number from package.json | ||
PACKAGE_VERSION=$(node -p -e "require('./package.json').version") | ||
|
||
# Ensure the version from package.json matches the version in manifest.json | ||
if [ "$PACKAGE_VERSION" != "$MANIFEST_VERSION" ]; then | ||
echo "Version mismatch between package.json and manifest.json" | ||
exit 1 | ||
fi | ||
|
||
# increate the version by 1 minor | ||
NEW_VERSION=$(bun semver $VERSION -i patch) | ||
echo "Current version: $VERSION" | ||
# Increment the version based on the specified update type | ||
if [ "$UPDATE_TYPE" = "minor" ]; then | ||
NEW_VERSION=$(semver $PACKAGE_VERSION -i minor) | ||
elif [ "$UPDATE_TYPE" = "patch" ]; then | ||
NEW_VERSION=$(semver $PACKAGE_VERSION -i patch) | ||
elif [ "$UPDATE_TYPE" = "major" ]; then | ||
NEW_VERSION=$(semver $PACKAGE_VERSION -i major) | ||
else | ||
echo "No update type specified." | ||
exit 1 | ||
fi | ||
|
||
echo "Current version: $PACKAGE_VERSION" | ||
echo "New version: $NEW_VERSION" | ||
|
||
# change the package.json version using linux command without using sed | ||
# Update the version in package.json | ||
jq --arg version "$NEW_VERSION" '.version = $version' package.json >tmp.json && mv tmp.json package.json | ||
echo "Changed package.json version to $NEW_VERSION" | ||
|
||
# Print the updated version of manifest.json using 'bun' | ||
bun run version | ||
echo "Updated version of manifest using bun, the current version of manifest.json is $(jq -r '.version' manifest.json)" | ||
echo "Updated version of manifest using bun. The current version of manifest.json is $(jq -r '.version' manifest.json)" | ||
|
||
# Create a git commit and tag | ||
git add . && git commit -m "release: $NEW_VERSION" | ||
git tag -a "$NEW_VERSION" -m "release: $NEW_VERSION" | ||
echo "Created tag $NEW_VERSION" | ||
|
||
# Push the commit and tag to the remote repository | ||
git push origin "$NEW_VERSION" | ||
echo "Pushed tag $NEW_VERSION to origin branch $NEW_VERSION" | ||
echo "Pushed tag $NEW_VERSION to the origin branch $NEW_VERSION" | ||
git push | ||
echo "Pushed to origin master branch" |