2022-08-06 20:32:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Properties: actions
|
|
|
|
# username, token, registry=https://registry.npmjs.org, scope, folder=.
|
2022-08-09 09:06:10 +00:00
|
|
|
# profile=release, target=bundler, make, browser
|
2022-08-06 20:32:27 +00:00
|
|
|
|
|
|
|
# publish: username, token
|
2022-08-09 09:06:10 +00:00
|
|
|
# test:
|
2022-08-06 20:32:27 +00:00
|
|
|
# build:
|
|
|
|
|
2022-08-07 00:51:10 +00:00
|
|
|
echo wasm-pack plugin
|
|
|
|
pwd
|
|
|
|
echo actions: ${PLUGIN_ACTIONS}
|
|
|
|
echo username: ${PLUGIN_USERNAME}
|
|
|
|
echo registry: ${PLUGIN_REGISTRY:-https://registry.npmjs.org/}
|
|
|
|
echo scope: ${PLUGIN_SCOPE}
|
|
|
|
echo folder: ${PLUGIN_FOLDER:-.}
|
2022-08-07 16:53:21 +00:00
|
|
|
echo profile: ${PLUGIN_PROFILE:-release}
|
|
|
|
echo target: ${PLUGIN_TARGET:-bundler}
|
2022-08-07 00:51:10 +00:00
|
|
|
echo make: ${PLUGIN_MAKE}
|
|
|
|
|
2022-08-06 20:32:27 +00:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
cd ${PLUGIN_FOLDER:-.}
|
|
|
|
|
|
|
|
if [[ "${PLUGIN_ACTIONS}" =~ '(^|,)build(,|$)' ]]; then
|
|
|
|
if [ "${PLUGIN_SCOPE:-}" = "" ]; then
|
2022-08-07 16:53:21 +00:00
|
|
|
wasm-pack build --${PLUGIN_PROFILE:-release} --target ${PLUGIN_TARGET:-bundler}
|
2022-08-06 20:32:27 +00:00
|
|
|
else
|
2022-08-07 16:53:21 +00:00
|
|
|
wasm-pack build --${PLUGIN_PROFILE:-release} --target ${PLUGIN_TARGET:-bundler} --scope ${PLUGIN_SCOPE}
|
2022-08-06 20:32:27 +00:00
|
|
|
fi
|
|
|
|
|
2022-08-07 01:59:08 +00:00
|
|
|
if [ "${PLUGIN_MAKE:-}" != "" ]; then
|
2022-08-06 20:32:27 +00:00
|
|
|
make ${PLUGIN_MAKE}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-08-09 09:41:51 +00:00
|
|
|
if [[ "${PLUGIN_ACTIONS}" =~ '(^|,)test(,|$)' ]]; then
|
2022-08-09 09:06:10 +00:00
|
|
|
wasm-pack test --node
|
|
|
|
fi
|
|
|
|
|
2022-08-06 20:32:27 +00:00
|
|
|
if [[ "${PLUGIN_ACTIONS}" =~ '(^|,)publish(,|$)' ]]; then
|
2022-08-07 01:59:08 +00:00
|
|
|
cd pkg
|
2022-08-07 16:53:21 +00:00
|
|
|
npm pkg set type=module
|
2022-08-07 01:42:36 +00:00
|
|
|
REGISTRY=${PLUGIN_REGISTRY:-https://registry.npmjs.org/}
|
2022-08-06 20:32:27 +00:00
|
|
|
|
|
|
|
if [ "${PLUGIN_SCOPE:-}" = "" ]; then
|
|
|
|
npm config set registry ${REGISTRY}
|
|
|
|
else
|
2022-08-06 20:36:36 +00:00
|
|
|
npm config set @${PLUGIN_SCOPE}:registry ${REGISTRY}
|
2022-08-06 20:32:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
npm config set -- $(echo ${REGISTRY} | sed -Ee "s/^https?://"):_authToken "${PLUGIN_TOKEN}"
|
|
|
|
npm publish
|
2022-08-07 16:53:21 +00:00
|
|
|
fi
|