upload.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash
  2. TARGET=$1
  3. # 获取最新版本号
  4. VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)
  5. if [[ "${VERSION}" = "" ]]
  6. then
  7. VERSION=0.0.1-SNAPSHOT
  8. fi
  9. if [[ -z ${TARGET} ]]
  10. then
  11. # 默认平台
  12. TARGET=admin
  13. fi
  14. rm -rf ${PROJECT_PATH}/dist
  15. if [[ $TARGET = "admin" ]]
  16. then
  17. cd front;
  18. if [[ $ENV = "test" ]]
  19. then
  20. npm run deploy:test ${TARGET}
  21. elif [[ $ENV = "dev" ]]
  22. then
  23. npm run deploy ${TARGET}
  24. else
  25. npm run deploy:prod ${TARGET}
  26. fi
  27. cd ../;
  28. # mv admin/dist ./;
  29. export UPLOAD=front/dist
  30. export UPLOADED=static-${TARGET}
  31. elif [[ $TARGET = "www" ]]
  32. then
  33. cd front;
  34. if [[ $ENV = "test" ]]
  35. then
  36. npm run deploy:test ${TARGET}
  37. elif [[ $ENV = "dev" ]]
  38. then
  39. npm run deploy ${TARGET}
  40. else
  41. npm run deploy:prod ${TARGET}
  42. fi
  43. cd ../;
  44. # mv web/dist ./;
  45. export UPLOAD=front/dist
  46. export UPLOADED=static-${TARGET}
  47. elif [[ $TARGET = "h5" ]]
  48. then
  49. cd front;
  50. if [[ $ENV = "test" ]]
  51. then
  52. npm run deploy:test ${TARGET}
  53. elif [[ $ENV = "dev" ]]
  54. then
  55. npm run deploy ${TARGET}
  56. else
  57. npm run deploy:prod ${TARGET}
  58. fi
  59. cd ../;
  60. # mv web/dist ./;
  61. export UPLOAD=front/dist
  62. export UPLOADED=static-${TARGET}
  63. elif [[ $TARGET = "gateway" ]]
  64. then
  65. rm -rf dist
  66. mkdir dist
  67. export ENV=$ENV
  68. cd server;
  69. ./gradlew :gateway-api:bootJar
  70. cd ../
  71. mv server/gateway-api/build/libs/gateway-api-*-boot.jar dist/gateway-api-boot.jar
  72. cat server/pm2-gateway-api.json > dist/pm2.json
  73. chmod +x dist/*
  74. echo ${VERSION} > dist/LAST_VERSION
  75. export FORCE_UPLOAD=false
  76. export UPLOAD=dist
  77. export UPLOADED="gateway"
  78. elif [[ $TARGET = "gateway-all" ]]
  79. then
  80. rm -rf dist
  81. mkdir dist
  82. export ENV=$ENV
  83. cd server;
  84. ./gradlew :gateway-api:bootJar
  85. cd ../
  86. mv server/gateway-api/build/libs/* dist/
  87. mv dist/gateway-api-*-boot.jar dist/gateway-api-boot.jar
  88. cat server/pm2-gateway-api.json > dist/pm2.json
  89. chmod +x dist/*
  90. echo ${VERSION} > dist/LAST_VERSION
  91. export FORCE_UPLOAD=true
  92. export UPLOAD=dist
  93. export UPLOADED="gateway"
  94. fi