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.

tag 3.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env bash
  2. set +o errexit
  3. git diff-index --quiet HEAD
  4. if [ $? == 1 ]
  5. then
  6. echo >&2 "Git repository not clean. Aborting."
  7. exit 1
  8. fi
  9. set -o errexit
  10. set -o pipefail
  11. set -o nounset
  12. function increment_version {
  13. IFS='.' read -a versions <<< "${1}"
  14. major=${versions[0]}
  15. minor=${versions[1]}
  16. patch=${versions[2]}
  17. case "${2}" in
  18. "major")
  19. major=$((major + 1))
  20. minor=0
  21. patch=0
  22. ;;
  23. "minor")
  24. minor=$((minor + 1))
  25. patch=0
  26. ;;
  27. "patch")
  28. patch=$((patch + 1))
  29. ;;
  30. esac
  31. new_version="$major.$minor.$patch"
  32. echo ${new_version}
  33. }
  34. function replace_versions_in_files {
  35. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" package.json
  36. sed -i "s/__version__ = \"${1}\"/__version__ = \"${2}\"/g" cli/lesspass/version.py
  37. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" mobile/package.json
  38. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass/package.json
  39. sed -i "s/\"lesspass-entropy\": \"${1}\"/\"lesspass-entropy\": \"${2}\"/g" packages/lesspass/package.json
  40. sed -i "s/\"lesspass-fingerprint\": \"${1}\"/\"lesspass-fingerprint\": \"${2}\"/g" packages/lesspass/package.json
  41. sed -i "s/\"lesspass-render-password\": \"${1}\"/\"lesspass-render-password\": \"${2}\"/g" packages/lesspass/package.json
  42. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-crypto/package.json
  43. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-entropy/package.json
  44. sed -i "s/\"lesspass-crypto\": \"${1}\"/\"lesspass-crypto\": \"${2}\"/g" packages/lesspass-entropy/package.json
  45. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-fingerprint/package.json
  46. sed -i "s/\"lesspass-crypto\": \"${1}\"/\"lesspass-crypto\": \"${2}\"/g" packages/lesspass-fingerprint/package.json
  47. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-pure/package.json
  48. sed -i "s/\"lesspass\": \"${1}\"/\"lesspass\": \"${2}\"/g" packages/lesspass-pure/package.json
  49. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-render-password/package.json
  50. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-web-extension/package.json
  51. sed -i "s/\"lesspass-pure\": \"${1}\"/\"lesspass-pure\": \"${2}\"/g" packages/lesspass-web-extension/package.json
  52. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-web-extension/extension/manifest.json
  53. sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" containers/frontend/package.json
  54. sed -i "s/VERSION=\"${1}\"/VERSION=\"${2}\"/g" containers/deploy
  55. }
  56. function tag {
  57. git add .
  58. git commit --message="LessPass version ${1}"
  59. git tag "${1}"
  60. }
  61. __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  62. __root="$(cd "$(dirname "${__dir}")" && pwd)"
  63. pushd ${__root}
  64. bump_type="${1:-}"
  65. if [ "${bump_type}" == "major" ] || [ "${bump_type}" == "minor" ] || [ "${bump_type}" == "patch" ]
  66. then
  67. current_version=$(grep -Po '(?<="version": ")[^"]*' package.json)
  68. new_version=$( increment_version ${current_version} ${bump_type} )
  69. replace_versions_in_files ${current_version} ${new_version}
  70. tag ${new_version}
  71. else
  72. echo >&2 "Error: No bump type specified (major, minor, patch). Aborting."
  73. exit 1
  74. fi