master
AdityaAngajala
v0.12.8
160fd3c
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
#!/usr/bin/env bash
# Publishes this checkout as a release of the wiki page adom/adom-3d-viewer:
# 1. the package, from a staging dir with a wiki-clean manifest
# 2. the source files, pushed to the page repo (the page's Files tab)
# 3. the built bundle, as a pinnable release asset
# and leaves the bundle tarball in dist-release/ for the GitHub release.
#
# GitHub is the source of record. The release workflow runs this on a
# vX.Y.Z tag; it runs the same way by hand from a clean checkout of that tag.
#
# scripts/release.sh build, then publish
# SKIP_BUILD=1 scripts/release.sh publish the dist-standalone/ already built
# DRY_RUN=1 scripts/release.sh build and stage; print the publish commands
# instead of running them
# SKIP_PKG=1 / SKIP_PUSH=1 / SKIP_ASSET=1
# leave out a step, to finish a release whose
# earlier steps already went through
#
# Needs: dependencies installed (npm ci), python3, and adom-wiki on PATH,
# signed in or given ADOM_WIKI_TOKEN. When RELEASE_TAG is set (CI sets it to
# the pushed tag) it must be v<VERSION>.
set -euo pipefail
cd "$(dirname "$0")/.."
PAGE=adom/adom-3d-viewer
V=$(tr -d '[:space:]' < VERSION)
PKG_V=$(node -p "require('./package.json').version")
[ "$V" = "$PKG_V" ] || { echo "VERSION ($V) and package.json ($PKG_V) disagree" >&2; exit 1; }
if [ -n "${RELEASE_TAG:-}" ] && [ "$RELEASE_TAG" != "v$V" ]; then
echo "tag $RELEASE_TAG does not match VERSION $V (want v$V)" >&2; exit 1
fi
run() {
if [ "${DRY_RUN:-}" = "1" ]; then printf 'would run:'; printf ' %q' "$@"; printf '\n'; else "$@"; fi
}
# 0. the standalone browser bundle
if [ "${SKIP_BUILD:-}" != "1" ]; then
npx vite build --config vite.standalone.config.mts
fi
[ -f dist-standalone/adom-3d-viewer-babylon9.esm.js ] || { echo "dist-standalone/ is not built" >&2; exit 1; }
printf '%s\n' "$V" > dist-standalone/VERSION
# 1. the package. The checkout's package.json carries npm dev/peer deps,
# which the wiki's owner-qualified dependency validation rejects, so the
# publish goes out of a staging dir with a wiki-clean manifest.
STAGE=$(mktemp -d)
trap 'rm -rf "$STAGE"' EXIT
cp README.md SKILL.md VERSION "$STAGE/"
cp wiki/install.sh wiki/uninstall.sh "$STAGE/"
python3 - "$STAGE" << 'PY'
import json, sys
d = json.load(open("package.json"))
for k in ["devDependencies", "peerDependencies", "scripts", "main", "module", "exports", "files", "types"]:
d.pop(k, None)
d["scripts"] = {"install": "./install.sh", "uninstall": "./uninstall.sh"}
json.dump(d, open(sys.argv[1] + "/package.json", "w"), indent=2)
PY
echo "staged $PAGE $V in $STAGE: $(ls "$STAGE" | tr '\n' ' ')"
if [ "${SKIP_PKG:-}" != "1" ]; then
(cd "$STAGE" && run adom-wiki pkg publish --org adom)
fi
# 2. the source, to the page repo (explicit files; never node_modules or dist)
if [ "${SKIP_PUSH:-}" != "1" ]; then
run adom-wiki repo push "$PAGE" \
--files src static docs test scripts README.md README-FORK.md SKILL.md publish-skills \
package.json package-lock.json VERSION standalone.ts \
svelte.config.mjs tsconfig.json vite.config.mts vite.standalone.config.mts .gitignore \
-m "v$V"
fi
# 3. the built bundle, as the pinnable release asset
mkdir -p dist-release
TARBALL="dist-release/adom-3d-viewer-babylon9-$V.tar.gz"
tar -czf "$TARBALL" -C dist-standalone .
echo "bundle: $TARBALL ($(du -h "$TARBALL" | cut -f1))"
if [ "${SKIP_ASSET:-}" != "1" ]; then
run adom-wiki release upload "$PAGE" "$V" "$TARBALL" --platform any
fi
if [ "${DRY_RUN:-}" = "1" ]; then echo "dry run: nothing was published."; else echo "released $PAGE $V."; fi
echo "The wiki's own 3D tab still serves its vendored copy: to ship this build there,"
echo "vendor dist-standalone/ into git-wiki static/vendor/adom-3d-viewer-babylon9 and bump VIEWER_BUNDLE_VER."