bump_version 3.4 KB

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