apps-version-check.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. latest_release=$(git describe --abbrev=0 --tags)
  4. bad_app_count=0
  5. while read -r app; do
  6. if [ "$app" != "emqx" ]; then
  7. app_path="$app"
  8. else
  9. app_path="."
  10. fi
  11. src_file="$app_path/src/$(basename "$app").app.src"
  12. old_app_version="$(git show "$latest_release":"$src_file" | grep vsn | grep -oE '"[0-9]+.[0-9]+.[0-9]+"' | tr -d '"')"
  13. now_app_version=$(grep -E 'vsn' "$src_file" | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"')
  14. if [ "$old_app_version" = "$now_app_version" ]; then
  15. changed="$(git diff --name-only "$latest_release"...HEAD \
  16. -- "$app_path/src" \
  17. -- "$app_path/priv" \
  18. -- "$app_path/c_src" | { grep -v -E 'appup\.src' || true; } | wc -l)"
  19. if [ "$changed" -gt 0 ]; then
  20. echo "$src_file needs a vsn bump"
  21. bad_app_count=$(( bad_app_count + 1))
  22. elif [[ ${app_path} = *emqx_dashboard* ]]; then
  23. ## emqx_dashboard is ensured to be upgraded after all other plugins
  24. ## at the end of its appup instructions, there is the final instruction
  25. ## {apply, {emqx_plugins, load, []}
  26. ## since we don't know which plugins are stopped during the upgrade
  27. ## for safty, we just force a dashboard version bump for each and every release
  28. ## even if there is nothing changed in the app
  29. echo "$src_file needs a vsn bump to ensure plugins loaded after upgrade"
  30. bad_app_count=$(( bad_app_count + 1))
  31. fi
  32. fi
  33. done < <(./scripts/find-apps.sh)
  34. if [ $bad_app_count -gt 0 ]; then
  35. exit 1
  36. else
  37. echo "apps version check successfully"
  38. fi