mirror of https://github.com/openclaw/openclaw.git
46 lines
1.3 KiB
Bash
46 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
mode="${1:-}"
|
|
package_dir="${2:-}"
|
|
|
|
if [[ "${mode}" != "--dry-run" && "${mode}" != "--publish" ]]; then
|
|
echo "usage: bash scripts/plugin-npm-publish.sh [--dry-run|--publish] <package-dir>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if [[ -z "${package_dir}" ]]; then
|
|
echo "missing package dir" >&2
|
|
exit 2
|
|
fi
|
|
|
|
package_name="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.name)' "${package_dir}")"
|
|
package_version="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.version)' "${package_dir}")"
|
|
publish_cmd=(npm publish --access public --provenance)
|
|
release_channel="stable"
|
|
|
|
if [[ "${package_version}" == *-beta.* ]]; then
|
|
publish_cmd=(npm publish --access public --tag beta --provenance)
|
|
release_channel="beta"
|
|
fi
|
|
|
|
echo "Resolved package dir: ${package_dir}"
|
|
echo "Resolved package name: ${package_name}"
|
|
echo "Resolved package version: ${package_version}"
|
|
echo "Resolved release channel: ${release_channel}"
|
|
echo "Publish auth: GitHub OIDC trusted publishing"
|
|
|
|
printf 'Publish command:'
|
|
printf ' %q' "${publish_cmd[@]}"
|
|
printf '\n'
|
|
|
|
if [[ "${mode}" == "--dry-run" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
(
|
|
cd "${package_dir}"
|
|
"${publish_cmd[@]}"
|
|
)
|