Skip to content

Commit 128e1e5

Browse files
committed
chore(sdk): publish script
1 parent 078b233 commit 128e1e5

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

kleros-sdk/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
"test": "vitest",
3131
"test:ui": "vitest --ui",
3232
"test:run": "vitest run",
33-
"publish": "yarn npm publish"
33+
"release:patch": "scripts/publish.sh patch",
34+
"release:minor": "scripts/publish.sh minor",
35+
"release:major": "scripts/publish.sh major"
3436
},
3537
"devDependencies": {
3638
"@types/mustache": "^4.2.5",

kleros-sdk/scripts/publish.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4+
5+
#--------------------------------------
6+
# Error handling
7+
#--------------------------------------
8+
9+
set -Ee
10+
function _catch {
11+
# Don't propagate to outer shell
12+
exit 0
13+
}
14+
function _finally {
15+
# TODO: rollback version bump
16+
rm -rf $SCRIPT_DIR/../dist
17+
}
18+
trap _catch ERR
19+
trap _finally EXIT
20+
21+
#--------------------------------------
22+
23+
# Check if any tracked files are currently changed, ignoring untracked files
24+
if [ -n "$(git status --porcelain -uno)" ]; then
25+
echo "Error: There are uncommitted changes in tracked files. Please commit or stash them before publishing."
26+
exit 1
27+
fi
28+
29+
yarn version $1
30+
31+
version=$(cat package.json | jq -r .version)
32+
echo "Publishing version $version"
33+
34+
git add package.json
35+
git commit -m "chore(sdk): release @kleros/kleros-sdk@$version"
36+
git tag "@kleros/kleros-sdk@$version" -m "@kleros/kleros-sdk@$version"
37+
git push
38+
git push --tags
39+
40+
yarn clean
41+
yarn build
42+
yarn npm publish

0 commit comments

Comments
 (0)