Skip to content

Commit 19bf5a2

Browse files
committed
ci: fix publish script
1 parent 101e809 commit 19bf5a2

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

scripts/publish.sh

+27-18
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,40 @@ publish_npm() {
66
yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public
77
}
88

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 {} +
9+
clean() {
10+
pkg="$1"
11+
exclude_regex="\./\.git\|\./packages\|\./\|\./packages/$pkg\|\./LICENSE"
12+
find . -maxdepth 1 -not -regex "$exclude_regex" -exec rm -rf {} +
1313
}
1414

1515
publish_forge_pkg() {
16-
pkg="$1"
17-
version=$(jq -r '.version' "packages/$pkg/package.json")
16+
pkg="$1"
17+
version=$(jq -r '.version' "packages/$pkg/package.json")
1818

19-
clean_root "$pkg"
20-
mv "packages/$pkg/{src,README.md}" .
21-
rm -fr "packages/$pkg"
19+
git checkout -b "$pkg"
2220

23-
git checkout -b "$package"
24-
git commit -am "$version"
25-
git push origin "$package"
21+
clean "$pkg"
22+
mv "packages/$pkg/{src,README.md}" .
23+
rm -fr "packages/$pkg"
24+
git commit -am "$version"
25+
git push origin "$pkg"
26+
27+
git checkout main
28+
29+
}
30+
31+
publish_forge_pkgs() {
32+
# http://mywiki.wooledge.org/BashFAQ/001
33+
# https://github.com/koalaman/shellcheck/wiki/SC2012
34+
find packages -maxdepth 1 -mindepth 1 -printf '%P\n' | while read -r pkg; do
35+
publish_forge_pkg "$pkg"
36+
done
2637
}
2738

2839
main() {
29-
pkg="$1"
30-
clean_root "$pkg"
31-
publish_forge
32-
# TODO: uncomment
33-
# publish_npm
40+
publish_forge_pkgs
41+
# TODO: uncomment
42+
# publish_npm
3443
}
3544

36-
main "$@"
45+
main

0 commit comments

Comments
 (0)