Files
compiler-explorer/etc/scripts/build-dist.sh
T
Matt Godbolt 7828576a5b Reverts the reversion of the "make" being more prod-like, and fixes it. (#3591)
* Use webpack to autogenerate the files.

That way, we always generate them consistently, be it through
`make` or building for prod. This fixes the `make` issue, and also
means we've further unified the way we build and run with `make`
vs prod.

Unfortunately this doesn't work for `make dev`; which sees the
handlebars content only. That's probably ok though, I think.
2022-04-28 12:59:25 -05:00

59 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(
cd -- "$(dirname "$0")/../.." >/dev/null 2>&1
pwd -P
)"
cd "$ROOT"
RELEASE_FILE_NAME=${GITHUB_RUN_NUMBER}
RELEASE_NAME=gh-${RELEASE_FILE_NAME}
HASH=$(git rev-parse HEAD)
# Clear the output
rm -rf out
mkdir -p out/dist
cd out/dist
echo "${HASH}" >git_hash
echo "${RELEASE_NAME}" >release_build
cp -R "${ROOT}"/etc \
"${ROOT}"/examples \
"${ROOT}"/views \
"${ROOT}"/types \
"${ROOT}"/package*.json \
.
rm -rf "${ROOT}"/lib/storage/data
# Set up and build and webpack everything
cd "${ROOT}"
npm install --no-audit
npm run webpack
npm run ts-compile
# Now install only the production dependencies in our output directory
cd out/dist
npm install --no-audit --ignore-scripts --production
rm -rf node_modules/.cache/ node_modules/monaco-editor/
find node_modules -name \*.ts -delete
# Output some magic for GH to set the branch name and release name
echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
echo "::set-output name=release_name::${RELEASE_NAME}"
# Run to make sure we haven't just made something that won't work
node -r esm ./app.js --version --dist
rm -rf "${ROOT}/out/dist-bin"
mkdir -p "${ROOT}/out/dist-bin"
export XZ_OPT="-1 -T 0"
tar -Jcf "${ROOT}/out/dist-bin/${RELEASE_FILE_NAME}.tar.xz" .
pushd "${ROOT}/out/webpack"
tar -Jcf "${ROOT}/out/dist-bin/${RELEASE_FILE_NAME}.static.tar.xz" --transform="s,^static/,," static/*
popd
echo "${HASH}" >"${ROOT}/out/dist-bin/${RELEASE_FILE_NAME}.txt"
du -ch ./*