build.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. set -e
  3. export WORKSPACE=$PWD
  4. export PACKAGE_NAME="mint-$1"
  5. function build_dashboard_v4() {
  6. local react_node_modules="dashboard-$1.tar.xz"
  7. if [ ! -f $WORKSPACE/downloads/$react_node_modules ]; then
  8. echo "couldn't find $react_node_modules_tar"
  9. exit 1
  10. fi
  11. cd $WORKSPACE/$PACKAGE_NAME/dashboard-v4/dashboard/
  12. echo "uncompress node_modules for dashboard-v4"
  13. tar xf $WORKSPACE/downloads/$react_node_modules
  14. yarn build
  15. cp -r build $WORKSPACE/$PACKAGE_NAME-dist/dashboard
  16. }
  17. # -----------------------------------------------------------------------------
  18. if [ "$#" -ne 2 ]; then
  19. echo "USAGE: $0 FULL_GIT_COMMIT_ID ENV_ID"
  20. exit 1
  21. fi
  22. if [ ! -f $WORKSPACE/downloads/$1.zip ]; then
  23. echo "download $1.zip from github"
  24. mkdir -p $WORKSPACE/downloads
  25. wget -q -P $WORKSPACE/downloads https://github.com/iapt-platform/mint/archive/$1.zip
  26. fi
  27. if [ ! -f $WORKSPACE/$2.env ]; then
  28. echo "couldn't find config file $2.env"
  29. exit 1
  30. fi
  31. source $WORKSPACE/$2.env
  32. # -----------------------------------------------------------------------------
  33. if [ -d $WORKSPACE/$PACKAGE_NAME ]; then
  34. echo "remove $PACKAGE_NAME folder"
  35. rm -r $WORKSPACE/$PACKAGE_NAME
  36. fi
  37. echo "uncompress $1.zip"
  38. unzip -d $WORKSPACE -q $WORKSPACE/downloads/$1.zip
  39. # -----------------------------------------------------------------------------
  40. if [ -d $WORKSPACE/$PACKAGE_NAME-dist ]; then
  41. rm -r $WORKSPACE/$PACKAGE_NAME-dist
  42. fi
  43. mkdir -p $WORKSPACE/$PACKAGE_NAME-dist
  44. build_dashboard_v4 "20241106153131"
  45. cd $WORKSPACE
  46. cp -r $PACKAGE_NAME/api-v8 $PACKAGE_NAME-dist/htdocs
  47. if [ -f $PACKAGE_NAME.tar.xz ]; then
  48. rm $PACKAGE_NAME.tar.xz
  49. fi
  50. XZ_OPT=-e9 tar -C $PACKAGE_NAME-dist -jcf $PACKAGE_NAME.tar.xz dashboard htdocs
  51. md5sum $PACKAGE_NAME.tar.xz >$PACKAGE_NAME.md5
  52. # -----------------------------------------------------------------------------
  53. echo "done($PACKAGE_NAME.tar.xz)."
  54. exit 0