Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

117 linhas
3.0 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. yarn upgrade --latest
  81. yarn build
  82. popd
  83. }
  84. function commit_and_push {
  85. git add .
  86. git commit --message="Auto build for lesspass-web-extension"
  87. git push
  88. }
  89. current_version=$( grep -Po '(?<="version": ")[^"]*' packages/lesspass-web-extension/package.json )
  90. echo "Current lesspass-web-extension version is ${current_version}"
  91. new_version=$( increment_version ${current_version} ${bump_type} )
  92. echo "New lesspass-web-extension version is ${new_version}"
  93. latest_lesspass_pure_version=$( yarn info -s lesspass-pure version )
  94. echo "Latest lesspass-pure version is ${latest_lesspass_pure_version}"
  95. 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
  96. sed -i -E "s/\"version\": \"([0-9]+)\.([0-9]+)\.([0-9]+)\"/\"version\": \"${new_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/extension/manifest.json
  98. build
  99. commit_and_push