You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/usr/bin/env bash
  2. RED='\033[0;31m'
  3. NOCOLOR='\033[0m'
  4. function print_error {
  5. echo -e "${RED}$1${NOCOLOR}"
  6. }
  7. function check_current_directory_is_root {
  8. if [ ! -f README.md ]; then
  9. print_error "You seems to be in the wrong directory"
  10. print_error "Execute this script from the root of lesspass with ./bin/${0##*/}"
  11. exit 1
  12. fi
  13. }
  14. function check_repository_is_clean {
  15. git remote update
  16. git add .
  17. git status
  18. git diff-index --quiet HEAD
  19. if [ $? == 1 ]
  20. then
  21. print_error "Git repository not clean. Aborting."
  22. exit 1
  23. fi
  24. if [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]
  25. then
  26. print_error "Git branch diverged. Aborting."
  27. exit 1
  28. fi
  29. }
  30. function check_branch_is_master {
  31. BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2)
  32. if [ $BRANCH_NAME != "master" ]
  33. then
  34. print_error "Current branch is not master. Aborting."
  35. exit 1
  36. fi
  37. }
  38. function check_bump_type_is_defined {
  39. bump_type="${1}"
  40. if [ "${bump_type}" != "major" ] && [ "${bump_type}" != "minor" ] && [ "${bump_type}" != "patch" ]
  41. then
  42. print_error "Error: No bump type specified (major, minor, patch). Aborting."
  43. exit 1
  44. fi
  45. }
  46. set +o errexit
  47. check_branch_is_master
  48. bump_type="${1:-}"
  49. check_bump_type_is_defined ${bump_type}
  50. check_current_directory_is_root
  51. check_repository_is_clean
  52. set -o errexit
  53. set -o pipefail
  54. set -o nounset
  55. function increment_version {
  56. IFS='.' read -a versions <<< "${1}"
  57. major=${versions[0]}
  58. minor=${versions[1]}
  59. patch=${versions[2]}
  60. case "${2}" in
  61. "major")
  62. major=$((major + 1))
  63. minor=0
  64. patch=0
  65. ;;
  66. "minor")
  67. minor=$((minor + 1))
  68. patch=0
  69. ;;
  70. "patch")
  71. patch=$((patch + 1))
  72. ;;
  73. esac
  74. new_version="$major.$minor.$patch"
  75. echo ${new_version}
  76. }
  77. function replace_versions_in_files {
  78. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" package.json
  79. sed -i "s/__version__ = \"${1}\"/__version__ = \"${2}\"/g" cli/lesspass/version.py
  80. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" mobile/package.json
  81. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" mobile/src/version.json
  82. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass/package.json
  83. sed -i "s/\"lesspass-entropy\": \"${1}\"/\"lesspass-entropy\": \"${2}\"/g" packages/lesspass/package.json
  84. sed -i "s/\"lesspass-fingerprint\": \"${1}\"/\"lesspass-fingerprint\": \"${2}\"/g" packages/lesspass/package.json
  85. sed -i "s/\"lesspass-render-password\": \"${1}\"/\"lesspass-render-password\": \"${2}\"/g" packages/lesspass/package.json
  86. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-crypto/package.json
  87. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-entropy/package.json
  88. sed -i "s/\"lesspass-crypto\": \"${1}\"/\"lesspass-crypto\": \"${2}\"/g" packages/lesspass-entropy/package.json
  89. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-fingerprint/package.json
  90. sed -i "s/\"lesspass-crypto\": \"${1}\"/\"lesspass-crypto\": \"${2}\"/g" packages/lesspass-fingerprint/package.json
  91. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-pure/package.json
  92. sed -i "s/\"lesspass\": \"${1}\"/\"lesspass\": \"${2}\"/g" packages/lesspass-pure/package.json
  93. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-render-password/package.json
  94. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-site/package.json
  95. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-web-extension/package.json
  96. sed -i "s/\"lesspass-pure\": \"${1}\"/\"lesspass-pure\": \"${2}\"/g" packages/lesspass-web-extension/package.json
  97. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-web-extension/extension/manifest.json
  98. }
  99. function build_web_extensions {
  100. yarn install
  101. yarn workspace lesspass-pure run build
  102. rm -rf packages/lesspass-web-extension/extension/dist
  103. mkdir packages/lesspass-web-extension/extension/dist
  104. cp -r packages/lesspass-pure/dist/. packages/lesspass-web-extension/extension/dist/
  105. }
  106. function build_mobile_app {
  107. pushd mobile/android/
  108. ./gradlew bundleRelease
  109. popd
  110. }
  111. function tag {
  112. git add .
  113. git commit --message="LessPass version ${1}"
  114. git tag "${1}"
  115. }
  116. current_version=$( grep -Po '(?<="version": ")[^"]*' package.json )
  117. new_version=$( increment_version ${current_version} ${bump_type} )
  118. replace_versions_in_files ${current_version} ${new_version}
  119. build_web_extensions
  120. build_mobile_app
  121. tag ${new_version}