您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

118 行
3.1 KiB

  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. bump_type="${1:-}"
  48. check_bump_type_is_defined ${bump_type}
  49. check_branch_is_master
  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 build {
  78. pushd packages/lesspass-web-extension/
  79. yarn install
  80. rm -rf ./extension/dist
  81. mkdir ./extension/dist
  82. popd
  83. cp -r packages/lesspass-pure/dist/. packages/lesspass-web-extension/extension/dist/
  84. }
  85. function commit_and_push {
  86. git add .
  87. git commit --message="Auto build for lesspass-web-extension"
  88. git push
  89. }
  90. current_version=$( grep -Po '(?<="version": ")[^"]*' packages/lesspass-web-extension/package.json )
  91. echo "Current lesspass-web-extension version is ${current_version}"
  92. new_version=$( increment_version ${current_version} ${bump_type} )
  93. echo "New lesspass-web-extension version is ${new_version}"
  94. latest_lesspass_pure_version=$( yarn info -s lesspass-pure version )
  95. echo "Latest lesspass-pure version is ${latest_lesspass_pure_version}"
  96. sed -i -E "s/\"lesspass-pure\": \"([0-9]+)\.([0-9]+)\.([0-9]+)\"/\"lesspass-pure\": \"${latest_lesspass_pure_version}\"/g" packages/lesspass-web-extension/package.json
  97. sed -i -E "s/\"version\": \"([0-9]+)\.([0-9]+)\.([0-9]+)\"/\"version\": \"${new_version}\"/g" packages/lesspass-web-extension/package.json
  98. sed -i -E "s/\"version\": \"([0-9]+)\.([0-9]+)\.([0-9]+)\"/\"version\": \"${new_version}\"/g" packages/lesspass-web-extension/extension/manifest.json
  99. build
  100. commit_and_push