package.sh 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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,files}
  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 src/partials/*.html $DIR/partials/
  34. cp -R src/partials/messenger.receiver/*.html $DIR/partials/messenger.receiver/
  35. cp -R src/directives/*.html $DIR/directives/
  36. echo "+ Copy dependencies..."
  37. targets=(
  38. angular/angular.js
  39. angular/angular-csp.css
  40. angular-aria/angular-aria.min.js
  41. angular-animate/angular-animate.min.js
  42. angular-sanitize/angular-sanitize.min.js
  43. angular-route/angular-route.min.js
  44. babel-es6-polyfill/browser-polyfill.min.js
  45. msgpack-lite/dist/msgpack.min.js
  46. tweetnacl/nacl-fast.min.js
  47. file-saver/FileSaver.min.js
  48. js-sha256/build/sha256.min.js
  49. chunked-dc/dist/chunked-dc.es5.js
  50. saltyrtc-client/dist/saltyrtc-client.es5.js
  51. saltyrtc-task-webrtc/dist/saltyrtc-task-webrtc.es5.js
  52. webrtc-adapter/out/adapter_no_edge.js
  53. qrcode-generator/js/qrcode.js
  54. angular-qrcode/angular-qrcode.js
  55. angularjs-scroll-glue/src/scrollglue.js
  56. angular-material/angular-material.min.js
  57. angular-material/angular-material.min.css
  58. croppie/croppie.min.js
  59. croppie/croppie.css
  60. autolinker/dist/Autolinker.min.js
  61. angular-ui-router/release/angular-ui-router.min.js
  62. messageformat/messageformat.min.js
  63. angular-translate/dist/angular-translate.min.js
  64. angular-translate/dist/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js
  65. angular-translate/dist/angular-translate-interpolation-messageformat/angular-translate-interpolation-messageformat.min.js
  66. angular-inview/angular-inview.js
  67. angular-messages/angular-messages.min.js
  68. )
  69. for target in "${targets[@]}"; do
  70. install -D "node_modules/$target" "$DIR/node_modules/$target"
  71. done
  72. echo "+ Update version number..."
  73. sed -i "s/\[\[VERSION\]\]/${VERSION}/g" $DIR/index.html $DIR/dist/app.js
  74. echo "+ Update permissions..."
  75. find $DIR/ -type f -exec chmod 644 {} \;
  76. find $DIR/ -type d -exec chmod 755 {} \;
  77. echo "+ Put everything in an archive..."
  78. cd release
  79. tar cfz "../dist/threema-web-$VERSION.tar.gz" $(basename "$DIR")
  80. cd ..
  81. echo -e "\nDone."