Skip to content

Commit 4ab5bf8

Browse files
committed
chore: define publish.sh
Publish pkg to npm and to a branch for use by `forge install` re #11, #30
1 parent 81d050b commit 4ab5bf8

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scripts": {
1010
"test": "forge test",
1111
"version:bump": "yarn workspace @zk-kit/${0}.sol version ${1} && yarn remove:stable-version-field ${0} && NO_HOOK=1 git commit -am \"chore(${0}): v${1}\" && git tag ${0}.sol-v${1}",
12-
"version:publish": "yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public",
12+
"version:publish": "scripts/publish.sh",
1313
"version:release": "changelogithub",
1414
"format": "prettier -c . && forge fmt --check",
1515
"format:write": "prettier -w . && forge fmt",

scripts/publish.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
publish_npm() {
6+
yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public
7+
}
8+
9+
clean_root() {
10+
pkg="$1"
11+
exclude_regex="\./\.git\|\./packages\|\./\|\./packages/$pkg\|\./LICENSE"
12+
find . -maxdepth 1 -not -regex "$exclude_regex" -exec rm -rf {} +
13+
}
14+
15+
publish_forge_pkg() {
16+
pkg="$1"
17+
version=$(jq -r '.version' "packages/$pkg/package.json")
18+
19+
clean_root "$pkg"
20+
mv "packages/$pkg/{src,README.md}" .
21+
rm -fr "packages/$pkg"
22+
23+
git checkout -b "$package"
24+
git commit -am "$version"
25+
git push origin "$package"
26+
}
27+
28+
main() {
29+
pkg="$1"
30+
clean_root "$pkg"
31+
publish_forge
32+
publish_npm
33+
}
34+
35+
main "$@"

0 commit comments

Comments
 (0)