-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·34 lines (29 loc) · 989 Bytes
/
publish.sh
File metadata and controls
executable file
·34 lines (29 loc) · 989 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
if ! command -v pnpm >/dev/null 2>&1; then
echo "pnpm is required" >&2
exit 1
fi
package_name=$(node -p "require('./package.json').name")
current_version=$(node -p "require('./package.json').version")
published_version=$(pnpm view "$package_name" dist-tags.latest 2>/dev/null || true)
next_version=$(node -e "
const parse = (v) => v.split('.').map((n) => Number(n));
const gt = (a, b) => {
for (let i = 0; i < 3; i += 1) {
if (a[i] > b[i]) return true;
if (a[i] < b[i]) return false;
}
return false;
};
const current = parse(process.argv[1]);
const published = process.argv[2] ? parse(process.argv[2]) : [0, 0, 0];
const base = gt(current, published) ? current : published;
base[2] += 1;
console.log(base.join('.'));
" "$current_version" "$published_version")
if [[ "$next_version" != "$current_version" ]]; then
pnpm version "$next_version" --no-git-tag-version
fi
pnpm run build
pnpm publish --access public --no-git-checks