Skip to content

Commit

Permalink
ci: fix publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
sripwoud committed Jul 10, 2024
1 parent 101e809 commit 19bf5a2
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,40 @@ 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 {} +
clean() {
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")
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 "$pkg"

git checkout -b "$package"
git commit -am "$version"
git push origin "$package"
clean "$pkg"
mv "packages/$pkg/{src,README.md}" .
rm -fr "packages/$pkg"
git commit -am "$version"
git push origin "$pkg"

git checkout main

}

publish_forge_pkgs() {
# http://mywiki.wooledge.org/BashFAQ/001
# https://github.com/koalaman/shellcheck/wiki/SC2012
find packages -maxdepth 1 -mindepth 1 -printf '%P\n' | while read -r pkg; do
publish_forge_pkg "$pkg"
done
}

main() {
pkg="$1"
clean_root "$pkg"
publish_forge
# TODO: uncomment
# publish_npm
publish_forge_pkgs
# TODO: uncomment
# publish_npm
}

main "$@"
main

0 comments on commit 19bf5a2

Please sign in to comment.