This is required because we have to patch the VERSION file inside the tarball for 'rerelease'. Which then requires release tarballs to have a unique name. The version is at the end because there is code in release script which relies on the box sha at the front
84 lines
2.9 KiB
Bash
Executable File
84 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
# Only GNU getopt supports long options. OS X comes bundled with the BSD getopt
|
|
# brew install gnu-getopt to get the GNU getopt on OS X
|
|
[[ $(uname -s) == "Darwin" ]] && GNU_GETOPT="/usr/local/opt/gnu-getopt/bin/getopt" || GNU_GETOPT="getopt"
|
|
readonly GNU_GETOPT
|
|
|
|
args=$(${GNU_GETOPT} -o "" -l "output:,version:" -n "$0" -- "$@")
|
|
eval set -- "${args}"
|
|
|
|
readonly SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
bundle_file=""
|
|
version=""
|
|
|
|
while true; do
|
|
case "$1" in
|
|
--version) version="$2"; shift 2;;
|
|
--) break;;
|
|
*) echo "Unknown option $1"; exit 1;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z "${version}" ]]; then
|
|
echo "--version is required"
|
|
exit 1
|
|
fi
|
|
|
|
readonly TMPDIR=${TMPDIR:-/tmp} # why is this not set on mint?
|
|
|
|
if ! $(cd "${SOURCE_DIR}" && git diff --exit-code >/dev/null); then
|
|
echo "You have local changes in box, stash or commit them to proceed"
|
|
exit 1
|
|
fi
|
|
|
|
if ! $(cd "${SOURCE_DIR}/../dashboard" && git diff --exit-code >/dev/null); then
|
|
echo "You have local changes in dashboard, stash or commit them to proceed"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$(node --version)" != "v8.11.2" ]]; then
|
|
echo "This script requires node 8.11.2"
|
|
exit 1
|
|
fi
|
|
|
|
box_version=$(cd "${SOURCE_DIR}" && git rev-parse "HEAD")
|
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
|
dashboard_version=$(cd "${SOURCE_DIR}/../dashboard" && git fetch && git rev-parse "${branch}")
|
|
bundle_dir=$(mktemp -d -t box 2>/dev/null || mktemp -d box-XXXXXXXXXX --tmpdir=$TMPDIR)
|
|
bundle_file="${TMPDIR}/box-${box_version:0:10}-${dashboard_version:0:10}-${version}.tar.gz"
|
|
|
|
chmod "o+rx,g+rx" "${bundle_dir}" # otherwise extracted tarball director won't be readable by others/group
|
|
echo "==> Checking out code box version [${box_version}] and dashboard version [${dashboard_version}] into ${bundle_dir}"
|
|
(cd "${SOURCE_DIR}" && git archive --format=tar ${box_version} | (cd "${bundle_dir}" && tar xf -))
|
|
(cd "${SOURCE_DIR}/../dashboard" && git archive --format=tar ${dashboard_version} | (mkdir -p "${bundle_dir}/dashboard.build" && cd "${bundle_dir}/dashboard.build" && tar xf -))
|
|
(cp "${SOURCE_DIR}/../dashboard/LICENSE" "${bundle_dir}")
|
|
echo "${version}" > "${bundle_dir}/VERSION"
|
|
|
|
echo "==> Installing modules for dashboard asset generation"
|
|
(cd "${bundle_dir}/dashboard.build" && npm install --production)
|
|
|
|
echo "==> Building dashboard assets"
|
|
(cd "${bundle_dir}/dashboard.build" && ./node_modules/.bin/gulp --revision ${dashboard_version})
|
|
|
|
echo "==> Move built dashboard assets into destination"
|
|
mkdir -p "${bundle_dir}/dashboard"
|
|
mv "${bundle_dir}/dashboard.build/dist" "${bundle_dir}/dashboard/"
|
|
|
|
echo "==> Cleanup dashboard build artifacts"
|
|
rm -rf "${bundle_dir}/dashboard.build"
|
|
|
|
echo "==> Installing toplevel node modules"
|
|
(cd "${bundle_dir}" && npm install --production --no-optional)
|
|
|
|
echo "==> Create final tarball"
|
|
(cd "${bundle_dir}" && tar czf "${bundle_file}" .)
|
|
|
|
echo "==> Cleaning up ${bundle_dir}"
|
|
rm -rf "${bundle_dir}"
|
|
|
|
echo "==> Tarball saved at ${bundle_file}"
|