mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 09:25:06 +01:00
Upgrade bump_version script to handle release and post-release commit
- Updates version in khoj.el and Obsidian manifest, package, versions json files under interface and project root - Create and tag release commit with updated files - Creates commit with post-release version upgrade in files - Use flags to specify whether to create a release or post-release commit
This commit is contained in:
parent
8bb8824d0c
commit
bcc0bed9db
1 changed files with 75 additions and 19 deletions
|
@ -1,26 +1,82 @@
|
||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
|
||||||
# Copy current version to project root
|
project_root=$PWD
|
||||||
echo $PWD
|
|
||||||
cp src/interface/obsidian/versions.json .
|
|
||||||
cp src/interface/obsidian/manifest.json .
|
|
||||||
|
|
||||||
# Induce hatch to compute next version number
|
while getopts 'nc:' opt;
|
||||||
# remove .dev[commits-since-tag] version suffix from hatch computed version number
|
do
|
||||||
next_version=$(touch bump.txt && git add bump.txt && hatch version | sed 's/\.dev.*//g')
|
case "${opt}" in
|
||||||
git rm --cached -- bump.txt && rm bump.txt
|
c)
|
||||||
|
# Get current project version
|
||||||
|
current_version=$OPTARG
|
||||||
|
|
||||||
# Bump Obsidian plugins to next version
|
# Bump Obsidian plugin to current version
|
||||||
cd src/interface/obsidian
|
cd $project_root/src/interface/obsidian
|
||||||
sed -E -i.bak "s/version\": \"(.*)\",/version\": \"$next_version\",/" package.json
|
sed -E -i.bak "s/version\": \"(.*)\",/version\": \"$current_version\",/" package.json
|
||||||
sed -E -i.bak "s/version\": \"(.*)\"/version\": \"$next_version\"/" manifest.json
|
sed -E -i.bak "s/version\": \"(.*)\"/version\": \"$current_version\"/" manifest.json
|
||||||
npm run version # updates versions.json
|
cp $project_root/versions.json .
|
||||||
rm *.bak
|
npm run version # append current version
|
||||||
|
rm *.bak
|
||||||
|
|
||||||
# Bump Emacs package to next version
|
# Bump Emacs package to current version
|
||||||
cd ../emacs
|
cd ../emacs
|
||||||
sed -E -i.bak "s/^;; Version: (.*)/;; Version: $next_version/" khoj.el
|
sed -E -i.bak "s/^;; Version: (.*)/;; Version: $current_version/" khoj.el
|
||||||
rm *.bak
|
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 \
|
||||||
|
$project_root/src/interface/obsidian/package.json \
|
||||||
|
$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
|
||||||
|
|
||||||
|
# Bump Obsidian plugins to next version
|
||||||
|
cd $project_root/src/interface/obsidian
|
||||||
|
sed -E -i.bak "s/version\": \"(.*)\",/version\": \"$next_version\",/" package.json
|
||||||
|
sed -E -i.bak "s/version\": \"(.*)\"/version\": \"$next_version\"/" manifest.json
|
||||||
|
npm run version # updates versions.json
|
||||||
|
rm *.bak
|
||||||
|
|
||||||
|
# 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 \
|
||||||
|
$project_root/src/interface/obsidian/package.json \
|
||||||
|
$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"
|
||||||
|
;;
|
||||||
|
?)
|
||||||
|
echo -e "Invalid command option.\nUsage: $(basename $0) [-c] [-n]"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# Restore State
|
# Restore State
|
||||||
cd ../../../
|
cd $project_root
|
||||||
|
|
Loading…
Reference in a new issue