-
Notifications
You must be signed in to change notification settings - Fork 112
/
publish.sh
executable file
·45 lines (37 loc) · 1.04 KB
/
publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$SCRIPT_DIR"
if [[ -n $(git status --porcelain) ]]; then
echo -e "${RED}Your git state is not empty. Aborting the script...${NC}"
exit 1
fi
# Check if a version bumping flag is provided
if [ $# -ne 1 ]; then
echo "Error: Version bumping flag (patch, minor, or major) is required."
exit 1
fi
# Validate the version bumping flag
case $1 in
patch|minor|major)
;;
*)
echo "Error: Invalid version bumping flag. Use patch, minor, or major."
exit 1
;;
esac
# Change to the priompt directory, increment the version, and publish the package
cd $SCRIPT_DIR/priompt
npm version $1
cd $SCRIPT_DIR/priompt-preview
npm version $1
cd $SCRIPT_DIR/tiktoken-node
npm version $1
git commit -am "update version"
git push
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
DEPLOY_BRANCH=publish
git branch -D $DEPLOY_BRANCH || true
git checkout -b $DEPLOY_BRANCH
git push origin $DEPLOY_BRANCH -f
git checkout $CURRENT_BRANCH