package.sh 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. echo -e " _____ _ _ _ _ _ "
  4. echo -e "|_ _| |_ ___ ___ ___ _____ ___| | | |___| |_ "
  5. echo -e " | | | | _| -_| -_| | .'| | | | -_| . | \e[32m_\e[0m "
  6. echo -e " |_| |_|_|_| |___|___|_|_|_|__,|_____|___|___|\e[32m|_|\e[0m\n"
  7. echo -e "Creating release distribution for Threema Web\n"
  8. # Test whether we're in the root dir
  9. if [ ! -f "package.json" ]; then
  10. echo "Error: package.json not found."
  11. echo "Please run this script from the root directory of this repository."
  12. exit 1
  13. fi
  14. # Clean up release directory
  15. if [ -e "release" ]; then
  16. while true; do
  17. read -r -p "Release directory exists. Delete it? (y/n) " input
  18. case $input in
  19. y|Y ) echo -e "\n+ Delete release directory..."; rm -r release; break;;
  20. n|N ) echo "Aborting."; exit 1;;
  21. * ) echo "Invalid input.";;
  22. esac
  23. done
  24. fi
  25. VERSION=$(grep "\"version\"" package.json | sed 's/\s*\"version\": \"\([^\"]*\).*/\1/')
  26. DIR="release/threema-web-$VERSION"
  27. echo "+ Create release directory..."
  28. mkdir -p $DIR/{dist,partials,directives,node_modules,partials/messenger.receiver,troubleshoot}
  29. echo "+ Copy code..."
  30. cp -R index.html $DIR/
  31. cp -R dist/app.js $DIR/dist/
  32. cp -R public/* $DIR/
  33. cp -R troubleshoot/* $DIR/troubleshoot/
  34. cp -R src/partials/*.html $DIR/partials/
  35. cp -R src/partials/messenger.receiver/*.html $DIR/partials/messenger.receiver/
  36. cp -R src/directives/*.html $DIR/directives/
  37. echo "+ Copy dependencies..."
  38. targets=(
  39. angular/angular.js
  40. angular/angular-csp.css
  41. angular-aria/angular-aria.min.js
  42. angular-animate/angular-animate.min.js
  43. angular-sanitize/angular-sanitize.min.js
  44. angular-route/angular-route.min.js
  45. babel-es6-polyfill/browser-polyfill.min.js
  46. msgpack-lite/dist/msgpack.min.js
  47. tweetnacl/nacl-fast.min.js
  48. file-saver/FileSaver.min.js
  49. js-sha256/build/sha256.min.js
  50. chunked-dc/dist/chunked-dc.es5.js
  51. saltyrtc-client/dist/saltyrtc-client.es5.js
  52. saltyrtc-task-webrtc/dist/saltyrtc-task-webrtc.es5.js
  53. webrtc-adapter/out/adapter_no_edge.js
  54. webrtc-adapter/out/adapter.js
  55. qrcode-generator/js/qrcode.js
  56. angular-qrcode/angular-qrcode.js
  57. angularjs-scroll-glue/src/scrollglue.js
  58. angular-material/angular-material.min.js
  59. angular-material/angular-material.min.css
  60. croppie/croppie.min.js
  61. croppie/croppie.css
  62. autolinker/dist/Autolinker.min.js
  63. angular-ui-router/release/angular-ui-router.min.js
  64. messageformat/messageformat.min.js
  65. angular-translate/dist/angular-translate.min.js
  66. angular-translate/dist/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js
  67. angular-translate/dist/angular-translate-interpolation-messageformat/angular-translate-interpolation-messageformat.min.js
  68. angular-messages/angular-messages.min.js
  69. sdp/sdp.js
  70. )
  71. for target in "${targets[@]}"; do
  72. install -D "node_modules/$target" "$DIR/node_modules/$target"
  73. done
  74. echo "+ Update version number..."
  75. sed -i "s/\[\[VERSION\]\]/${VERSION}/g" $DIR/index.html $DIR/troubleshoot/index.html $DIR/dist/app.js $DIR/version.txt
  76. echo "+ Update permissions..."
  77. find $DIR/ -type f -exec chmod 644 {} \;
  78. find $DIR/ -type d -exec chmod 755 {} \;
  79. echo "+ Put everything in an archive..."
  80. cd release
  81. tar cfz "../dist/threema-web-$VERSION.tar.gz" $(basename "$DIR")
  82. cd ..
  83. echo -e "\nDone."