bump_version 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/env bash
  2. # bump_version - increase the shared version and generate changelogs
  3. set -o errexit
  4. set -o pipefail
  5. usage() {
  6. echo -e "bump_version - increase the shared version and generate changelogs"
  7. echo -e ""
  8. echo -e "Usage:"
  9. echo -e " $ bump_version <new_version>"
  10. }
  11. if [[ -z $1 ]]; then
  12. usage
  13. exit 1
  14. fi
  15. shared_version_file="./SharedVersion.cs"
  16. build_file="./build.yaml"
  17. new_version="$1"
  18. # Parse the version from the AssemblyVersion
  19. old_version="$(
  20. grep "AssemblyVersion" ${shared_version_file} \
  21. | sed -E 's/\[assembly: ?AssemblyVersion\("([0-9\.]+)"\)\]/\1/'
  22. )"
  23. echo $old_version
  24. # Set the shared version to the specified new_version
  25. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  26. new_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"
  27. sed -i "s/${old_version_sed}/${new_version_sed}/g" ${shared_version_file}
  28. old_version="$(
  29. grep "version:" ${build_file} \
  30. | sed -E 's/version: "([0-9\.]+[-a-z0-9]*)"/\1/'
  31. )"
  32. echo $old_version
  33. # Set the build.yaml version to the specified new_version
  34. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  35. sed -i "s/${old_version_sed}/${new_version}/g" ${build_file}
  36. if [[ ${new_version} == *"-"* ]]; then
  37. new_version_deb="$( sed 's/-/~/g' <<<"${new_version}" )"
  38. else
  39. new_version_deb="${new_version}-1"
  40. fi
  41. # Update the metapackage equivs file
  42. debian_equivs_file="debian/metapackage/jellyfin"
  43. sed -i "s/${old_version_sed}/${new_version}/g" ${debian_equivs_file}
  44. # Write out a temporary Debian changelog with our new stuff appended and some templated formatting
  45. debian_changelog_file="debian/changelog"
  46. debian_changelog_temp="$( mktemp )"
  47. # Create new temp file with our changelog
  48. echo -e "jellyfin (${new_version_deb}) unstable; urgency=medium
  49. * New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}
  50. -- Jellyfin Packaging Team <packaging@jellyfin.org> $( date --rfc-2822 )
  51. " >> ${debian_changelog_temp}
  52. cat ${debian_changelog_file} >> ${debian_changelog_temp}
  53. # Move into place
  54. mv ${debian_changelog_temp} ${debian_changelog_file}
  55. # Write out a temporary Yum changelog with our new stuff prepended and some templated formatting
  56. fedora_spec_file="fedora/jellyfin.spec"
  57. fedora_changelog_temp="$( mktemp )"
  58. fedora_spec_temp_dir="$( mktemp -d )"
  59. fedora_spec_temp="${fedora_spec_temp_dir}/jellyfin.spec.tmp"
  60. # Make a copy of our spec file for hacking
  61. cp ${fedora_spec_file} ${fedora_spec_temp_dir}/
  62. pushd ${fedora_spec_temp_dir}
  63. # Split out the stuff before and after changelog
  64. csplit jellyfin.spec "/^%changelog/" # produces xx00 xx01
  65. # Update the version in xx00
  66. sed -i "s/${old_version_sed}/${new_version_sed}/g" xx00
  67. # Remove the header from xx01
  68. sed -i '/^%changelog/d' xx01
  69. # Create new temp file with our changelog
  70. echo -e "%changelog
  71. * $( LANG=C date '+%a %b %d %Y' ) Jellyfin Packaging Team <packaging@jellyfin.org>
  72. - New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}" >> ${fedora_changelog_temp}
  73. cat xx01 >> ${fedora_changelog_temp}
  74. # Reassembble
  75. cat xx00 ${fedora_changelog_temp} > ${fedora_spec_temp}
  76. popd
  77. # Move into place
  78. mv ${fedora_spec_temp} ${fedora_spec_file}
  79. # Clean up
  80. rm -rf ${fedora_spec_temp_dir}
  81. # Stage the changed files for commit
  82. git add ${shared_version_file} ${build_file} ${debian_equivs_file} ${debian_changelog_file} ${fedora_spec_file}
  83. git status