#!/bin/bash set -euo pipefail # Resolve inputs from this checkout, independently of the caller's cwd. cd "$(dirname "$0")/.." # Generate version ./scripts/gen-version.sh # Prepare staging for SDK extra files echo "Preparing dist-staging..." mkdir -p dist-staging/devtools/debugger-protocol mkdir -p dist-staging/devtools/headless-protocol dist-staging/docs/runtime cp devtools/debugger-protocol/protocol.json dist-staging/devtools/debugger-protocol/ cp VERSION.txt dist-staging/devtools/debugger-protocol/VERSION.txt cp devtools/headless-protocol/*.json dist-staging/devtools/headless-protocol/ cp VERSION.txt dist-staging/devtools/headless-protocol/VERSION.txt cp docs/specs/runtime/11a-headless-automation-protocol.md dist-staging/docs/runtime/ # Clean and prepare the version-specific directory echo "Preparing dist-staging/stable (existing archives are retained)..." mkdir -p "dist-staging/stable" # Build stable using cargo build dist build "$@" echo "Copying target/distrib content to dist-staging/stable..." if [ -d "target/distrib" ] && [ "$(ls -A target/distrib)" ]; then cp -r target/distrib/* "dist-staging/stable/" else echo "Error: target/distrib directory not found or empty." >&2 exit 1 fi