|
- #!/bin/bash
- #
- # Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
- #
- #
- # Build Bubble distribution ZIP file
- #
- # Usage:
- #
- # build_dist [no-build]
- #
- # no-build : if present, do not rebuild the bubble jar file
- #
- # Environment variables
- #
- # BUBBLE_ENV : env file to load. Default is ~/.bubble.env or /home/bubble/api/bubble.env (whichever is found first)
- #
- SCRIPT="${0}"
- SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd)
- . ${SCRIPT_DIR}/bubble_common
-
- NO_BUILD="${1}"
-
- BASE=$(cd $(dirname $0)/.. && pwd)
- cd ${BASE}
-
- if [[ -z "${NO_BUILD}" || "${NO_BUILD}" != "no-build" ]] ; then
- echo "Building bubble jar..."
- ${BASE}/bin/git_update_bubble.sh || die "Error building bubble jar file"
- else
- echo "Not building bubble jar: no-build was set"
- fi
-
- DIST_BASE="${BASE}/dist"
- rm -rf "${DIST_BASE}" || die "Error removing "${DIST_BASE}" directory"
- mkdir -p "${DIST_BASE}" || die "Error creating "${DIST_BASE}" directory"
-
- JAR_DIR="${BASE}/bubble-server/target"
- JAR="$(find "${JAR_DIR}" -type f -name "bubble-server-*.jar" | head -1)"
- if [[ -z "${JAR}" ]] ; then
- die "No bubble jar found in ${JAR_DIR}"
- fi
-
- VERSION_FILE="${BASE}/bubble-server/src/main/resources/META-INF/bubble/bubble.properties"
- VERSION=$(cat "${VERSION_FILE}" | grep bubble.version | awk -F '=' '{print $2}' | tr ' ' '_')
- if [[ -z "${VERSION}" ]] ; then
- die "No version found in ${VERSION_FILE}"
- fi
-
- DIST="${DIST_BASE}/bubble-${VERSION}"
- ZIP="${DIST_BASE}/bubble-${VERSION}.zip"
- mkdir -p "${DIST}" || die "Error creating distribution directory: ${DIST}"
- cp "${JAR}" "${DIST}/bubble.jar" || die "Error copying ${JAR} to ${DIST}/bubble.jar"
- cp "${BASE}/README.md" "${DIST}/README.md" || die "Error copying README.md to ${DIST}/README.md"
- cp "${BASE}/LICENSE.md" "${DIST}/LICENSE.md" || die "Error copying LICENSE.md to ${DIST}/LICENSE.md"
- cp -R "${BASE}/docs" "${DIST}" || die "Error copying docs directory to ${DIST}"
- cp -R "${BASE}/bin" "${DIST}" || die "Error copying bin directory to ${DIST}"
- cp -R "${BASE}/config" "${DIST}" || die "Error copying config directory to ${DIST}"
- cd "${DIST}/.." && zip -r "${ZIP}" "$(basename ${DIST})"
- echo "Distribution created: "
- ls -lh "${ZIP}"
-
- if [[ ! -z "${BUBBLE_DIST_HOME}" ]] ; then
- IS_DEV=0
- if [[ -z ${BUILD_NUMBER} ]] ; then
- BUILD_NUMBER="dev"
- IS_DEV=1
- fi
- BUBBLE_VERSION="${VERSION}.${BUILD_NUMBER}"
-
- BUBBLE_DIST_TOP=${BUBBLE_DIST_HOME}/releases/bubble
- BUBBLE_DIST=${BUBBLE_DIST_TOP}/${BUBBLE_VERSION}/$(basename ${ZIP})
- BUBBLE_DIST_DIR="$(dirname ${BUBBLE_DIST})"
- if [[ ! -d "${BUBBLE_DIST_DIR}" ]] ; then
- mkdir -p ${BUBBLE_DIST_DIR}
- fi
- cp "${ZIP}" "${BUBBLE_DIST}" && cat "${ZIP}" | sha256sum | cut -f1 -d' ' | tr -d '\n' > "${BUBBLE_DIST}.sha256"
- if [[ ${IS_DEV} -eq 0 ]] ; then
- cd ${BUBBLE_DIST_TOP} && rm -f latest && ln -sf ${BUBBLE_VERSION} latest
- echo "${BUBBLE_VERSION}" > latest.txt
- cd ${BUBBLE_DIST_DIR} && ln -s "$(basename ${BUBBLE_DIST})" bubble.zip && ln -s "$(basename ${BUBBLE_DIST}).sha" bubble.zip.sha256
- fi
- echo "Published release: ${BUBBLE_DIST}"
- fi
|