2023-02-18 03:31:51 +01:00
|
|
|
#!/bin/zsh
|
|
|
|
|
2023-03-10 22:15:08 +01:00
|
|
|
project_root=$PWD
|
|
|
|
|
2024-06-22 14:45:37 +02:00
|
|
|
while getopts 'nc:t:' opt;
|
2023-03-10 22:15:08 +01:00
|
|
|
do
|
|
|
|
case "${opt}" in
|
2024-06-22 14:45:37 +02:00
|
|
|
t)
|
|
|
|
# Get version type to bump. Options: major, minor, patch
|
|
|
|
version_type=$OPTARG
|
|
|
|
|
2024-08-05 12:50:47 +02:00
|
|
|
# Bump Web app to current version
|
|
|
|
cd $project_root/src/interface/web
|
|
|
|
yarn version --$version_type --no-git-tag-version
|
|
|
|
|
2024-06-22 14:45:37 +02:00
|
|
|
# Bump Desktop app to current version
|
|
|
|
cd $project_root/src/interface/desktop
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn version --$version_type --no-git-tag-version
|
2024-06-22 14:45:37 +02:00
|
|
|
|
|
|
|
# Get bumped project version
|
|
|
|
current_version=$(grep '"version":' package.json | awk -F '"' '{print $4}')
|
|
|
|
|
|
|
|
# Bump Obsidian plugin to current version
|
|
|
|
cd $project_root/src/interface/obsidian
|
2024-07-07 14:48:00 +02:00
|
|
|
yarn build # verify build before bumping version
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn version --$version_type --no-git-tag-version
|
2024-06-23 04:46:42 +02:00
|
|
|
# append current version, min Obsidian app version from manifest to versions json
|
|
|
|
cp $project_root/versions.json .
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn run version # run Obsidian version script
|
2024-06-22 14:45:37 +02:00
|
|
|
|
|
|
|
# Bump Emacs package to current version
|
|
|
|
cd ../emacs
|
|
|
|
sed -E -i.bak "s/^;; Version: (.*)/;; Version: $current_version/" khoj.el
|
|
|
|
git add khoj.el
|
|
|
|
rm *.bak
|
|
|
|
|
|
|
|
# Copy current obsidian versioned files to project root
|
|
|
|
cd $project_root
|
|
|
|
cp src/interface/obsidian/versions.json .
|
|
|
|
cp src/interface/obsidian/manifest.json .
|
|
|
|
|
|
|
|
# Run pre-commit validation to fix jsons
|
|
|
|
pre-commit run --hook-stage manual --all
|
|
|
|
|
|
|
|
# Commit changes and tag commit for release
|
|
|
|
git add \
|
2024-08-05 12:50:47 +02:00
|
|
|
$project_root/src/interface/web/package.json \
|
2024-06-22 14:45:37 +02:00
|
|
|
$project_root/src/interface/desktop/package.json \
|
|
|
|
$project_root/src/interface/obsidian/package.json \
|
2024-06-26 06:57:20 +02:00
|
|
|
$project_root/src/interface/obsidian/yarn.lock \
|
2024-06-22 14:45:37 +02:00
|
|
|
$project_root/src/interface/obsidian/manifest.json \
|
|
|
|
$project_root/src/interface/obsidian/versions.json \
|
|
|
|
$project_root/src/interface/emacs/khoj.el \
|
|
|
|
$project_root/manifest.json \
|
|
|
|
$project_root/versions.json
|
|
|
|
git commit -m "Release Khoj version $current_version"
|
|
|
|
git tag $current_version master
|
|
|
|
;;
|
2023-03-10 22:15:08 +01:00
|
|
|
c)
|
|
|
|
# Get current project version
|
|
|
|
current_version=$OPTARG
|
|
|
|
|
2024-08-05 12:50:47 +02:00
|
|
|
# Bump Web app to current version
|
|
|
|
cd $project_root/src/interface/web
|
|
|
|
yarn version --new-version $current_version --no-git-tag-version
|
|
|
|
|
2023-10-14 05:22:33 +02:00
|
|
|
# Bump Desktop app to current version
|
|
|
|
cd $project_root/src/interface/desktop
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn version --new-version $current_version --no-git-tag-version
|
2023-10-14 05:22:33 +02:00
|
|
|
|
2023-03-10 22:15:08 +01:00
|
|
|
# Bump Obsidian plugin to current version
|
|
|
|
cd $project_root/src/interface/obsidian
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn version --new-version $current_version --no-git-tag-version
|
2024-06-23 04:46:42 +02:00
|
|
|
# append current version, min Obsidian app version from manifest.json to versions.json
|
|
|
|
cp $project_root/versions.json .
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn run version # run Obsidian version script
|
2023-03-10 22:15:08 +01:00
|
|
|
|
|
|
|
# Bump Emacs package to current version
|
|
|
|
cd ../emacs
|
|
|
|
sed -E -i.bak "s/^;; Version: (.*)/;; Version: $current_version/" khoj.el
|
|
|
|
git add khoj.el
|
|
|
|
rm *.bak
|
|
|
|
|
|
|
|
# Copy current obsidian versioned files to project root
|
|
|
|
cd $project_root
|
|
|
|
cp src/interface/obsidian/versions.json .
|
|
|
|
cp src/interface/obsidian/manifest.json .
|
|
|
|
|
|
|
|
# Run pre-commit validation to fix jsons
|
|
|
|
pre-commit run --hook-stage manual --all
|
|
|
|
|
|
|
|
# Commit changes and tag commit for release
|
|
|
|
git add \
|
2024-08-05 12:50:47 +02:00
|
|
|
$project_root/src/interface/web/package.json \
|
2023-12-22 17:12:03 +01:00
|
|
|
$project_root/src/interface/desktop/package.json \
|
2023-03-10 22:15:08 +01:00
|
|
|
$project_root/src/interface/obsidian/package.json \
|
2024-06-26 06:57:20 +02:00
|
|
|
$project_root/src/interface/obsidian/yarn.lock \
|
2023-03-10 22:15:08 +01:00
|
|
|
$project_root/src/interface/obsidian/manifest.json \
|
|
|
|
$project_root/src/interface/obsidian/versions.json \
|
|
|
|
$project_root/src/interface/emacs/khoj.el \
|
|
|
|
$project_root/manifest.json \
|
|
|
|
$project_root/versions.json
|
|
|
|
git commit -m "Release Khoj version $current_version"
|
|
|
|
git tag $current_version master
|
|
|
|
;;
|
|
|
|
n)
|
|
|
|
# Induce hatch to compute next version number
|
|
|
|
# remove .dev[commits-since-tag] version suffix from hatch computed version number
|
|
|
|
next_version=$(touch bump.txt && git add bump.txt && hatch version | sed 's/\.dev.*//g')
|
|
|
|
git rm --cached -- bump.txt && rm bump.txt
|
|
|
|
|
2024-08-05 12:50:47 +02:00
|
|
|
# Bump Web app to next version
|
|
|
|
cd $project_root/src/interface/web
|
|
|
|
yarn version --new-version $next_version --no-git-tag-version
|
|
|
|
|
2023-12-22 17:12:03 +01:00
|
|
|
# Bump Desktop app to next version
|
|
|
|
cd $project_root/src/interface/desktop
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn version --new-version $next_version --no-git-tag-version
|
2023-12-22 17:12:03 +01:00
|
|
|
|
2023-03-10 22:15:08 +01:00
|
|
|
# Bump Obsidian plugins to next version
|
|
|
|
cd $project_root/src/interface/obsidian
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn version --new-version $next_version --no-git-tag-version
|
2024-06-23 04:46:42 +02:00
|
|
|
# append next version, min Obsidian app version from manifest to versions json
|
|
|
|
git rm --cached -- versions.json
|
2024-06-26 06:57:20 +02:00
|
|
|
yarn run version # run Obsidian version script
|
2023-03-10 22:15:08 +01:00
|
|
|
|
|
|
|
# Bump Emacs package to next version
|
|
|
|
cd $project_root/src/interface/emacs
|
|
|
|
sed -E -i.bak "s/^;; Version: (.*)/;; Version: $next_version/" khoj.el
|
|
|
|
rm *.bak
|
|
|
|
|
|
|
|
# Run pre-commit validations to fix jsons
|
|
|
|
pre-commit run --hook-stage manual --all
|
|
|
|
|
|
|
|
# Commit changes
|
|
|
|
git add \
|
2024-08-05 12:50:47 +02:00
|
|
|
$project_root/src/interface/web/package.json \
|
2023-12-22 17:12:03 +01:00
|
|
|
$project_root/src/interface/desktop/package.json \
|
2023-03-10 22:15:08 +01:00
|
|
|
$project_root/src/interface/obsidian/package.json \
|
2024-06-26 06:57:20 +02:00
|
|
|
$project_root/src/interface/obsidian/yarn.lock \
|
2023-03-10 22:15:08 +01:00
|
|
|
$project_root/src/interface/obsidian/manifest.json \
|
|
|
|
$project_root/src/interface/obsidian/versions.json \
|
|
|
|
$project_root/src/interface/emacs/khoj.el
|
|
|
|
git commit -m "Bump Khoj to pre-release version $next_version"
|
|
|
|
;;
|
|
|
|
?)
|
2024-06-22 14:45:37 +02:00
|
|
|
echo -e "Invalid command option.\nUsage: $(basename $0) [-t] [-c] [-n]"
|
2023-03-10 22:15:08 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2023-02-18 03:31:51 +01:00
|
|
|
|
|
|
|
# Restore State
|
2023-03-10 22:15:08 +01:00
|
|
|
cd $project_root
|