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.

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