wasm-pack-plugin
This commit is contained in:
12
tools/wasm-pack-plugin/Dockerfile
Normal file
12
tools/wasm-pack-plugin/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM rust:alpine
|
||||
|
||||
RUN apk add --no-cache \
|
||||
npm \
|
||||
musl-dev \
|
||||
make \
|
||||
&& cargo install wasm-pack \
|
||||
&& rustup target add wasm32-unknown-unknown
|
||||
|
||||
COPY plugin.sh /plugin.sh
|
||||
|
||||
ENTRYPOINT ["/plugin.sh"]
|
20
tools/wasm-pack-plugin/README.md
Normal file
20
tools/wasm-pack-plugin/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# wasm-pack plugin
|
||||
|
||||
This is a drone/woodpecker plugin for building and publishing wasm-pack packages.
|
||||
|
||||
## Settings
|
||||
|
||||
- `actions` (required): Actions (see below) to run
|
||||
- `folder`: Project folder
|
||||
- `scope`: NPM package scope
|
||||
|
||||
### Build
|
||||
|
||||
- `build_profile` (default=`release`): Build profile to use for `wasm-pack build`
|
||||
- `make`: Optionally run a make target building
|
||||
|
||||
### Publish
|
||||
|
||||
- `username` (required): NPM registry username
|
||||
- `token` (required): NPM registry auth token (secret recommended)
|
||||
- `registry` (default=`https://registry.npmjs.org`): NPM registry to publish to
|
37
tools/wasm-pack-plugin/plugin.sh
Executable file
37
tools/wasm-pack-plugin/plugin.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Properties: actions
|
||||
# username, token, registry=https://registry.npmjs.org, scope, folder=.
|
||||
# build_profile=release, make
|
||||
|
||||
# publish: username, token
|
||||
# build:
|
||||
|
||||
set -eu
|
||||
|
||||
cd ${PLUGIN_FOLDER:-.}
|
||||
|
||||
if [[ "${PLUGIN_ACTIONS}" =~ '(^|,)build(,|$)' ]]; then
|
||||
if [ "${PLUGIN_SCOPE:-}" = "" ]; then
|
||||
wasm-pack build --${PLUGIN_BUILD_PROFILE:-release}
|
||||
else
|
||||
wasm-pack build --${PLUGIN_BUILD_PROFILE:-release} --scope ${PLUGIN_SCOPE}
|
||||
fi
|
||||
|
||||
if [ "${PLUGIN_MAKE:-}" != ""]; then
|
||||
make ${PLUGIN_MAKE}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${PLUGIN_ACTIONS}" =~ '(^|,)publish(,|$)' ]]; then
|
||||
REGISTY=${PLUGIN_REGISTRY:-https://registry.npmjs.org/}
|
||||
|
||||
if [ "${PLUGIN_SCOPE:-}" = "" ]; then
|
||||
npm config set registry ${REGISTRY}
|
||||
else
|
||||
npm config set ${PLUGIN_SCOPE}:registry ${REGISTRY}
|
||||
fi
|
||||
|
||||
npm config set -- $(echo ${REGISTRY} | sed -Ee "s/^https?://"):_authToken "${PLUGIN_TOKEN}"
|
||||
npm publish
|
||||
fi
|
Reference in New Issue
Block a user