Skip to content

Commit

Permalink
chore: define publish.sh
Browse files Browse the repository at this point in the history
Publish pkg to npm and to a branch for use by `forge install`

re #11, #30
  • Loading branch information
sripwoud committed Jul 10, 2024
1 parent 81d050b commit 4ab5bf8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"test": "forge test",
"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}",
"version:publish": "yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public",
"version:publish": "scripts/publish.sh",
"version:release": "changelogithub",
"format": "prettier -c . && forge fmt --check",
"format:write": "prettier -w . && forge fmt",
Expand Down
35 changes: 35 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env sh

set -eu

publish_npm() {
yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public
}

clean_root() {
pkg="$1"
exclude_regex="\./\.git\|\./packages\|\./\|\./packages/$pkg\|\./LICENSE"
find . -maxdepth 1 -not -regex "$exclude_regex" -exec rm -rf {} +
}

publish_forge_pkg() {
pkg="$1"
version=$(jq -r '.version' "packages/$pkg/package.json")

clean_root "$pkg"
mv "packages/$pkg/{src,README.md}" .
rm -fr "packages/$pkg"

git checkout -b "$package"
git commit -am "$version"
git push origin "$package"
}

main() {
pkg="$1"
clean_root "$pkg"
publish_forge
publish_npm
}

main "$@"

0 comments on commit 4ab5bf8

Please sign in to comment.