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.

58 lines
1.2 KiB

  1. #!/bin/bash
  2. # Author: Sotiris Papadopoulos <ytubedlg@gmail.com>
  3. # Last-Revision: 2017-04-17
  4. # Script to bump the version and automatically update related files
  5. #
  6. # Usage: ./bump_version.sh <new-version>
  7. PACKAGE="youtube_dl_gui"
  8. FILES=`cat <<EOF
  9. $PACKAGE/version.py
  10. .github/ISSUE_TEMPLATE.md
  11. README.md
  12. EOF`
  13. # Update version string on given file
  14. # $1 = current version
  15. # $2 = new version
  16. # $3 = file
  17. function update_version {
  18. echo "Updating file: $3"
  19. sed -i "s/$1/$2/g" $3
  20. }
  21. # Returns 'true' if given version is less or equal to the current version
  22. # $1 = version to check
  23. # $2 = current version
  24. function version_le {
  25. smallest_version=`echo -e "$1\n$2" | sort -V | head -n1`
  26. [ "$1" = "$smallest_version" ]
  27. }
  28. if [ $# -ne 1 ]; then
  29. echo "Usage ./bump_version.sh <new-version>"
  30. exit 1
  31. fi
  32. cd ..
  33. new_version=$1
  34. cur_version=`grep version "$PACKAGE/version.py" | cut -d"'" -f2`
  35. echo "Current version = $cur_version"
  36. echo "New version = $new_version"
  37. echo
  38. if version_le $new_version $cur_version; then
  39. echo "New version must be greater than the current version, exiting..."
  40. exit 1
  41. fi
  42. for file in $FILES; do
  43. update_version $cur_version $new_version $file
  44. done
  45. echo "Done"