#!/usr/bin/env bash set -euo pipefail # Hold ownership across both preparation and publication. A leftover backup # from a previous interrupted run belongs to manual --restore. lock=.changeset/.publish-prep-lock mkdir "$lock" trap 'rmdir "$lock"' EXIT if [[ -e .changeset/.publish-prep-backup.json ]]; then echo "Publish backup already exists. Run --restore before publishing." >&2 exit 1 fi pnpm install nx run-many --target=build:dist,build:types --skip-nx-cache # The public CLI compiles against the library declarations. pnpm --filter @tevm/cli build publisher= cleanup() { local status=$? trap - EXIT trap '' INT TERM if [[ -n "$publisher" ]]; then kill -TERM -- "-$publisher" 2>/dev/null || true wait "$publisher" 2>/dev/null || true fi node scripts/prepare-changeset-publish.mjs --restore || status=$? rmdir "$lock" || status=$? exit "$status" } trap cleanup EXIT trap 'exit 130' INT trap 'exit 143' TERM checks=(--check-dist --check-registry) if [[ "${NODE_ENV:-}" == test && "${TEVM_SKIP_REGISTRY_CHECK:-}" == 1 ]]; then checks=(--check-dist --skip-registry) fi node scripts/prepare-changeset-publish.mjs --apply "${checks[@]}" if [[ ${checks[1]} == --check-registry ]]; then node scripts/verify-published-zevm.mjs fi export TEVM_REAL_PNPM="$(command -v pnpm)" export PATH="$PWD/scripts/pnpm-publish-wrapper:$PATH" # A separate process group lets a signal to this shell stop publish and its children. set -m changeset publish "$@" & publisher=$! status=0 wait "$publisher" || status=$? publisher= exit "$status"