2022-12-12 21:40:11 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Usage: build-npm-package.sh <registry-url> <publish-with-this-version>
|
2023-01-05 03:43:13 +00:00
|
|
|
# Note: supply the registry auth token in CERC_NPM_AUTH_TOKEN
|
2022-12-14 16:23:12 +00:00
|
|
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
2022-12-12 21:40:11 +00:00
|
|
|
set -x
|
|
|
|
fi
|
2023-01-05 04:23:17 +00:00
|
|
|
if ! [[ $# -eq 1 || $# -eq 2 ]]; then
|
2022-12-12 21:40:11 +00:00
|
|
|
echo "Illegal number of parameters" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-01-05 03:43:13 +00:00
|
|
|
if [[ -z "${CERC_NPM_AUTH_TOKEN}" ]]; then
|
|
|
|
echo "CERC_NPM_AUTH_TOKEN is not set" >&2
|
2022-12-12 21:40:11 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2023-01-05 04:23:17 +00:00
|
|
|
if [[ $# -eq 2 ]]; then
|
|
|
|
package_publish_version=$2
|
|
|
|
else
|
|
|
|
package_publish_version=$( cat package.json | jq -r .version )
|
|
|
|
fi
|
2022-12-12 21:40:11 +00:00
|
|
|
local_npm_registry_url=$1
|
2023-01-04 14:39:01 +00:00
|
|
|
npm config set @lirewine:registry ${local_npm_registry_url}
|
2022-12-12 21:40:11 +00:00
|
|
|
npm config set @cerc-io:registry ${local_npm_registry_url}
|
2023-01-05 03:43:13 +00:00
|
|
|
npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN}
|
2022-12-12 21:40:11 +00:00
|
|
|
echo "Build and publish version ${package_publish_version}"
|
|
|
|
yarn install
|
|
|
|
yarn build
|
|
|
|
yarn publish --non-interactive --new-version ${package_publish_version} --no-git-tag-version
|