The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

104 line
4.4 KiB

  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
  4. #
  5. # Build Bubble distribution ZIP file
  6. #
  7. # Usage:
  8. #
  9. # build_dist [no-build]
  10. #
  11. # no-build : if present, do not rebuild the bubble jar file
  12. #
  13. # Environment variables
  14. #
  15. # BUBBLE_ENV : env file to load. Default is ~/.bubble.env or /home/bubble/api/bubble.env (whichever is found first)
  16. #
  17. SCRIPT="${0}"
  18. SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd)
  19. . ${SCRIPT_DIR}/bubble_common
  20. NO_BUILD="${1}"
  21. BASE=$(cd $(dirname $0)/.. && pwd)
  22. cd ${BASE}
  23. if [[ -z "${NO_BUILD}" || "${NO_BUILD}" != "no-build" ]] ; then
  24. echo "Building bubble jar..."
  25. ${BASE}/bin/git_update_bubble.sh || die "Error building bubble jar file"
  26. else
  27. echo "Not building bubble jar: no-build was set"
  28. fi
  29. DIST_BASE="${BASE}/dist"
  30. rm -rf "${DIST_BASE}" || die "Error removing "${DIST_BASE}" directory"
  31. mkdir -p "${DIST_BASE}" || die "Error creating "${DIST_BASE}" directory"
  32. JAR_DIR="${BASE}/bubble-server/target"
  33. FULL_JAR="$(find "${JAR_DIR}" -type f -name "bubble-server-*-full.jar" | head -1)"
  34. if [[ -z "${FULL_JAR}" ]] ; then
  35. die "No full bubble jar found in ${JAR_DIR}"
  36. fi
  37. JAR="$(find "${JAR_DIR}" -type f -name "bubble-server-*-prod.jar" | head -1)"
  38. if [[ -z "${JAR}" ]] ; then
  39. die "No regular bubble jar found in ${JAR_DIR}"
  40. fi
  41. VERSION_FILE="${BASE}/bubble-server/src/main/resources/META-INF/bubble/bubble.properties"
  42. VERSION=$(cat "${VERSION_FILE}" | grep bubble.version | awk -F '=' '{print $2}' | tr ' ' '_')
  43. if [[ -z "${VERSION}" ]] ; then
  44. die "No version found in ${VERSION_FILE}"
  45. fi
  46. DIST="${DIST_BASE}/bubble-${VERSION}"
  47. ZIP="${DIST_BASE}/bubble-${VERSION}.zip"
  48. mkdir -p "${DIST}" || die "Error creating distribution directory: ${DIST}"
  49. cp "${JAR}" "${DIST}/bubble.jar" || die "Error copying ${JAR} to ${DIST}/bubble.jar"
  50. cp "${FULL_JAR}" "${DIST}/bubble-full.jar" || die "Error copying ${FULL_JAR} to ${DIST}/bubble-full.jar"
  51. cp "${BASE}/README.md" "${DIST}/README.md" || die "Error copying README.md to ${DIST}/README.md"
  52. cp "${BASE}/LICENSE.md" "${DIST}/LICENSE.md" || die "Error copying LICENSE.md to ${DIST}/LICENSE.md"
  53. cp -R "${BASE}/docs" "${DIST}" || die "Error copying docs directory to ${DIST}"
  54. cp -R "${BASE}/bin" "${DIST}" || die "Error copying bin directory to ${DIST}"
  55. cp -R "${BASE}/config" "${DIST}" || die "Error copying config directory to ${DIST}"
  56. cd "${DIST}/.." && zip -r "${ZIP}" "$(basename ${DIST})"
  57. echo "Distribution created: "
  58. ls -lh "${ZIP}"
  59. if [[ -n "${BUBBLE_DIST_HOME}" ]] ; then
  60. IS_DEV=0
  61. if [[ -z ${BUILD_NUMBER} ]] ; then
  62. BUILD_NUMBER="dev"
  63. IS_DEV=1
  64. fi
  65. BUBBLE_VERSION="${VERSION}.${BUILD_NUMBER}"
  66. BUBBLE_DIST_TOP=${BUBBLE_DIST_HOME}/releases/bubble
  67. BUBBLE_DIST=${BUBBLE_DIST_TOP}/${BUBBLE_VERSION}/$(basename ${ZIP})
  68. BUBBLE_JAR_DIST=${BUBBLE_DIST_TOP}/${BUBBLE_VERSION}/bubble.jar
  69. BUBBLE_FULL_JAR_DIST=${BUBBLE_DIST_TOP}/${BUBBLE_VERSION}/bubble-full.jar
  70. BUBBLE_DIST_DIR="$(dirname ${BUBBLE_DIST})"
  71. if [[ ! -d "${BUBBLE_DIST_DIR}" ]] ; then
  72. mkdir -p ${BUBBLE_DIST_DIR}
  73. fi
  74. cp "${ZIP}" "${BUBBLE_DIST}" && cat "${ZIP}" | sha256sum | cut -f1 -d' ' | tr -d '\n' > "${BUBBLE_DIST}.sha256" || die "Error copying bubble zip distribution ${ZIP} to dist or creating shasum"
  75. cp "${JAR}" "${BUBBLE_JAR_DIST}" && cat "${JAR}" | sha256sum | cut -f1 -d' ' | tr -d '\n' > "${BUBBLE_JAR_DIST}.sha256" || die "Error copying bubble jar ${JAR} to dist or creating shasum"
  76. cp "${FULL_JAR}" "${BUBBLE_FULL_JAR_DIST}" && cat "${FULL_JAR}" | sha256sum | cut -f1 -d' ' | tr -d '\n' > "${BUBBLE_FULL_JAR_DIST}.sha256" || die "Error copying full bubble jar ${FULL_JAR} to dist or creating shasum"
  77. if [[ ${IS_DEV} -eq 0 ]] ; then
  78. cd ${BUBBLE_DIST_TOP} && rm -f latest && ln -sf ${BUBBLE_VERSION} latest
  79. echo "${BUBBLE_VERSION}" > latest.txt
  80. cd ${BUBBLE_DIST_DIR} && rm -f bubble.zip* && \
  81. ln -s "$(basename ${BUBBLE_DIST})" bubble.zip && \
  82. ln -s "$(basename ${BUBBLE_DIST}).sha256" bubble.zip.sha256
  83. cd ${BUBBLE_DIST_DIR} && rm -f bubble.jar* && \
  84. ln -s "$(basename ${BUBBLE_JAR_DIST})" bubble.jar && \
  85. ln -s "$(basename ${BUBBLE_JAR_DIST}).sha256" bubble.jar.sha256
  86. cd ${BUBBLE_DIST_DIR} && rm -f bubble-full.jar* && \
  87. ln -s "$(basename ${BUBBLE_FULL_JAR_DIST})" bubble-full.jar && \
  88. ln -s "$(basename ${BUBBLE_FULL_JAR_DIST}).sha256" bubble-full.jar.sha256
  89. fi
  90. echo "Published release: ${BUBBLE_DIST}"
  91. fi