#!/bin/bash # Release script for html5rw npm package # Run from npm branch after building on main set -e # Path to dune install directory (relative to repo root) INSTALL_DIR="_build/install/default/share/html5rw-js" # Check we're on the npm branch BRANCH=$(git rev-parse --abbrev-ref HEAD) if [ "$BRANCH" != "npm" ]; then echo "Error: Must be on npm branch (currently on $BRANCH)" exit 1 fi # Check the install directory exists if [ ! -d "$INSTALL_DIR" ]; then echo "Error: Install directory not found at $INSTALL_DIR" echo "Run 'opam exec -- dune build @install' on main branch first" exit 1 fi # Copy JavaScript files echo "Copying JavaScript files..." cp "$INSTALL_DIR/htmlrw.js" . cp "$INSTALL_DIR/htmlrw-worker.js" . cp "$INSTALL_DIR/htmlrw-tests.js" . # Copy WASM loader scripts echo "Copying WASM loader scripts..." cp "$INSTALL_DIR/htmlrw.wasm.js" . cp "$INSTALL_DIR/htmlrw-worker.wasm.js" . cp "$INSTALL_DIR/htmlrw-tests.wasm.js" . # Copy WASM assets directories echo "Copying WASM assets..." rm -rf htmlrw_js_main.bc.wasm.assets htmlrw_js_worker.bc.wasm.assets htmlrw_js_tests_main.bc.wasm.assets cp -r "$INSTALL_DIR/htmlrw_js_main.bc.wasm.assets" . cp -r "$INSTALL_DIR/htmlrw_js_worker.bc.wasm.assets" . cp -r "$INSTALL_DIR/htmlrw_js_tests_main.bc.wasm.assets" . # Fix permissions echo "Fixing permissions..." chmod 644 *.js find htmlrw_js_main.bc.wasm.assets -type f -exec chmod 644 {} \; find htmlrw_js_worker.bc.wasm.assets -type f -exec chmod 644 {} \; find htmlrw_js_tests_main.bc.wasm.assets -type f -exec chmod 644 {} \; echo "Done! Ready to commit and publish." echo "Run: git add -A && git commit -m 'Release X.Y.Z' && npm publish"