Skip to content

Commit

Permalink
release: 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Hananoshika Yomaru committed Oct 28, 2023
1 parent cbb08c4 commit 2c721b4
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 14 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "3d-graph-new",
"name": "3D Graph New",
"version": "1.0.16",
"version": "1.1.0",
"description": "A 3D Graph for Obsidian",
"author": "Hananoshika Yomaru",
"authorUrl": "https://github.com/HananoshikaYomaru",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3d-graph-new",
"version": "1.0.16",
"version": "1.1.0",
"description": "A 3D graph for Obsidian",
"main": "main.js",
"scripts": {
Expand Down
63 changes: 51 additions & 12 deletions release.sh
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"

0 comments on commit 2c721b4

Please sign in to comment.