pre-compile.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. [ "${DEBUG:-0}" -eq 1 ] && set -x
  4. # NOTE: PROFILE_STR may not be exactly PROFILE (emqx or emqx-enterprise)
  5. # it might be with suffix such as -pkg etc.
  6. PROFILE_STR="${1}"
  7. case "$PROFILE_STR" in
  8. *enterprise*)
  9. dashboard_version="$EMQX_EE_DASHBOARD_VERSION"
  10. ;;
  11. *)
  12. dashboard_version="$EMQX_DASHBOARD_VERSION"
  13. ;;
  14. esac
  15. # ensure dir
  16. cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
  17. ./scripts/get-dashboard.sh "$dashboard_version"
  18. # generate merged config files and English translation of the desc (desc.en.hocon)
  19. ./scripts/merge-config.escript
  20. I18N_REPO_BRANCH="v$(./pkg-vsn.sh "${PROFILE_STR}" | tr -d '.' | cut -c 1-2)"
  21. DOWNLOAD_I18N_TRANSLATIONS=${DOWNLOAD_I18N_TRANSLATIONS:-true}
  22. # download desc (i18n) translations
  23. beginfmt='\033[1m'
  24. endfmt='\033[0m'
  25. if [ "$DOWNLOAD_I18N_TRANSLATIONS" = "true" ]; then
  26. echo "Downloading i18n translation from emqx/emqx-i18n..."
  27. start=$(date +%s%N)
  28. curl -L --fail --silent --show-error \
  29. --output "apps/emqx_dashboard/priv/desc.zh.hocon" \
  30. "https://raw.githubusercontent.com/emqx/emqx-i18n/${I18N_REPO_BRANCH}/desc.zh.hocon"
  31. end=$(date +%s%N)
  32. duration=$(echo "$end $start" | awk '{printf "%.f\n", (($1 - $2)/ 1000000)}')
  33. if [ "$duration" -gt 1000 ]; then beginfmt='\033[1;33m'; fi
  34. echo -e "Downloaded i18n translation in $duration milliseconds.\nSet ${beginfmt}DOWNLOAD_I18N_TRANSLATIONS=false${endfmt} to skip"
  35. else
  36. echo -e "Skipping to download i18n translation from emqx/emqx-i18n.\nSet ${beginfmt}DOWNLOAD_I18N_TRANSLATIONS=true${endfmt} to update"
  37. fi
  38. # TODO
  39. # make sbom a build artifact
  40. # ./scripts/update-bom.sh "$PROFILE_STR" ./rel