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.

59 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. youtube-dl-gui.1
  13. EOF`
  14. # Update version string on given file
  15. # $1 = current version
  16. # $2 = new version
  17. # $3 = file
  18. function update_version {
  19. echo "Updating file: $3"
  20. sed -i "s/$1/$2/g" $3
  21. }
  22. # Returns 'true' if given version is less or equal to the current version
  23. # $1 = version to check
  24. # $2 = current version
  25. function version_le {
  26. smallest_version=`echo -e "$1\n$2" | sort -V | head -n1`
  27. [ "$1" = "$smallest_version" ]
  28. }
  29. if [ $# -ne 1 ]; then
  30. echo "Usage ./bump_version.sh <new-version>"
  31. exit 1
  32. fi
  33. cd ..
  34. new_version=$1
  35. cur_version=`grep version "$PACKAGE/version.py" | cut -d"'" -f2`
  36. echo "Current version = $cur_version"
  37. echo "New version = $new_version"
  38. echo
  39. if version_le $new_version $cur_version; then
  40. echo "New version must be greater than the current version, exiting..."
  41. exit 1
  42. fi
  43. for file in $FILES; do
  44. update_version $cur_version $new_version $file
  45. done
  46. echo "Done"