21 lines
832 B
Bash
Executable File
21 lines
832 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
: "${OTEL_URL:?set OTEL_URL, for example https://otel.example.com}"
|
|
OTEL_SOURCEMAP_KEY="${OTEL_SOURCEMAP_KEY:-6901e62e4468631f27f1dc85fd4231f35b5e591c61f5bcfa}"
|
|
: "${RELEASE:?set RELEASE to the exact VITE_APP_RELEASE used at build time}"
|
|
|
|
bundle="${1:?usage: RELEASE=... OTEL_URL=... $0 dist/assets/index-HASH.js}"
|
|
map="${bundle}.map"
|
|
test -f "$bundle" || { echo "bundle not found: $bundle" >&2; exit 1; }
|
|
test -f "$map" || { echo "source map not found: $map" >&2; exit 1; }
|
|
|
|
source_path="/${bundle#*/dist/}"
|
|
curl --fail-with-body --silent --show-error \
|
|
-H "X-Sourcemap-Key: ${OTEL_SOURCEMAP_KEY}" \
|
|
-X POST "${OTEL_URL%/}/api/sourcemaps" \
|
|
-F "release=${RELEASE}" \
|
|
-F "source=${source_path}" \
|
|
-F "file=@${map};type=application/json"
|
|
echo "uploaded ${source_path} for ${RELEASE}"
|