.drone.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # 仅 tag 触发:顺序打包 backend / web / mobile-h5
  2. # 产物:/root/hzdyjs-releases/<tag>/{backend,web,mobile-h5}-<tag>.*
  3. # Maven 缓存:宿主机 /root/maven-repo → 容器 /maven-repo(由 runner DRONE_RUNNER_VOLUMES 注入)
  4. # 发版目录:/root/hzdyjs-releases → /hzdyjs-releases(同上,勿在本文件重复挂载)
  5. kind: pipeline
  6. type: docker
  7. name: package-prod
  8. concurrency:
  9. limit: 1
  10. trigger:
  11. event:
  12. - tag
  13. clone:
  14. depth: 1
  15. steps:
  16. - name: package-backend
  17. image: maven:3.9-eclipse-temurin-17
  18. commands:
  19. - set -eu
  20. - echo "==> backend tag=${DRONE_TAG} commit=${DRONE_COMMIT}"
  21. - test -n "${DRONE_TAG}"
  22. - mkdir -p "/hzdyjs-releases/${DRONE_TAG}"
  23. - cd backend
  24. - |
  25. mvn clean package -Pprod \
  26. -Dmaven.test.skip=true \
  27. -Dmaven.compiler.parameters=true \
  28. -Dmaven.repo.local=/maven-repo
  29. - test -f ruoyi-admin/target/ruoyi-admin.jar
  30. - cp -v ruoyi-admin/target/ruoyi-admin.jar "/hzdyjs-releases/${DRONE_TAG}/backend-${DRONE_TAG}.jar"
  31. - ls -lh "/hzdyjs-releases/${DRONE_TAG}/backend-${DRONE_TAG}.jar"
  32. - name: package-web
  33. image: node:20-bookworm
  34. environment:
  35. NPM_CONFIG_REGISTRY: https://registry.npmmirror.com
  36. commands:
  37. - set -eu
  38. - echo "==> web tag=${DRONE_TAG}"
  39. - mkdir -p "/hzdyjs-releases/${DRONE_TAG}"
  40. - cd web
  41. # package-lock.json 被 gitignore,仓库内无 lock,改用 npm install
  42. - npm install
  43. - npm run build:prod
  44. - test -f dist/index.html
  45. - tar -C dist -czf "/hzdyjs-releases/${DRONE_TAG}/web-${DRONE_TAG}.tar.gz" .
  46. - ls -lh "/hzdyjs-releases/${DRONE_TAG}/web-${DRONE_TAG}.tar.gz"
  47. - name: package-mobile-h5
  48. image: node:20-bookworm
  49. environment:
  50. NPM_CONFIG_REGISTRY: https://registry.npmmirror.com
  51. commands:
  52. - set -eu
  53. - echo "==> mobile-h5 tag=${DRONE_TAG}"
  54. - mkdir -p "/hzdyjs-releases/${DRONE_TAG}"
  55. - corepack enable
  56. - corepack prepare pnpm@9 --activate
  57. - cd mobile
  58. - pnpm config set registry https://registry.npmmirror.com
  59. - pnpm install --frozen-lockfile
  60. - pnpm run build
  61. - test -d dist/build/h5
  62. - tar -C dist/build/h5 -czf "/hzdyjs-releases/${DRONE_TAG}/mobile-h5-${DRONE_TAG}.tar.gz" .
  63. - ls -lh "/hzdyjs-releases/${DRONE_TAG}/"
  64. - ls -lh "/hzdyjs-releases/${DRONE_TAG}/mobile-h5-${DRONE_TAG}.tar.gz"