bump_version 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. # csproj files for nuget packages
  19. jellyfin_subprojects=( MediaBrowser.Common/MediaBrowser.Common.csproj Jellyfin.Data/Jellyfin.Data.csproj MediaBrowser.Controller/MediaBrowser.Controller.csproj MediaBrowser.Model/MediaBrowser.Model.csproj Emby.Naming/Emby.Naming.csproj )
  20. new_version="$1"
  21. # Parse the version from the AssemblyVersion
  22. old_version="$(
  23. grep "AssemblyVersion" ${shared_version_file} \
  24. | sed -E 's/\[assembly: ?AssemblyVersion\("([0-9\.]+)"\)\]/\1/'
  25. )"
  26. echo $old_version
  27. # Set the shared version to the specified new_version
  28. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  29. new_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"
  30. sed -i "s/${old_version_sed}/${new_version_sed}/g" ${shared_version_file}
  31. old_version="$(
  32. grep "version:" ${build_file} \
  33. | sed -E 's/version: "([0-9\.]+[-a-z0-9]*)"/\1/'
  34. )"
  35. echo $old_version
  36. # Set the build.yaml version to the specified new_version
  37. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  38. sed -i "s/${old_version_sed}/${new_version}/g" ${build_file}
  39. # update nuget package version
  40. for subproject in ${jellyfin_subprojects[@]}; do
  41. echo ${subproject}
  42. # Parse the version from the *.csproj file
  43. old_version="$(
  44. grep "VersionPrefix" ${subproject} \
  45. | awk '{$1=$1};1' \
  46. | sed -E 's/<VersionPrefix>([0-9\.]+[-a-z0-9]*)<\/VersionPrefix>/\1/'
  47. )"
  48. echo old nuget version: $old_version
  49. # Set the nuget version to the specified new_version
  50. sed -i "s|${old_version}|${new_version}|g" ${subproject}
  51. done
  52. if [[ ${new_version} == *"-"* ]]; then
  53. new_version_deb="$( sed 's/-/~/g' <<<"${new_version}" )"
  54. else
  55. new_version_deb="${new_version}-1"
  56. fi
  57. # Update the metapackage equivs file
  58. debian_equivs_file="debian/metapackage/jellyfin"
  59. sed -i "s/${old_version_sed}/${new_version}/g" ${debian_equivs_file}
  60. # Write out a temporary Debian changelog with our new stuff appended and some templated formatting
  61. debian_changelog_file="debian/changelog"
  62. debian_changelog_temp="$( mktemp )"
  63. # Create new temp file with our changelog
  64. echo -e "jellyfin-server (${new_version_deb}) unstable; urgency=medium
  65. * New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}
  66. -- Jellyfin Packaging Team <packaging@jellyfin.org> $( date --rfc-2822 )
  67. " >> ${debian_changelog_temp}
  68. cat ${debian_changelog_file} >> ${debian_changelog_temp}
  69. # Move into place
  70. mv ${debian_changelog_temp} ${debian_changelog_file}
  71. # Write out a temporary Yum changelog with our new stuff prepended and some templated formatting
  72. fedora_spec_file="fedora/jellyfin.spec"
  73. fedora_changelog_temp="$( mktemp )"
  74. fedora_spec_temp_dir="$( mktemp -d )"
  75. fedora_spec_temp="${fedora_spec_temp_dir}/jellyfin.spec.tmp"
  76. # Make a copy of our spec file for hacking
  77. cp ${fedora_spec_file} ${fedora_spec_temp_dir}/
  78. pushd ${fedora_spec_temp_dir}
  79. # Split out the stuff before and after changelog
  80. csplit jellyfin.spec "/^%changelog/" # produces xx00 xx01
  81. # Update the version in xx00
  82. sed -i "s/${old_version_sed}/${new_version_sed}/g" xx00
  83. # Remove the header from xx01
  84. sed -i '/^%changelog/d' xx01
  85. # Create new temp file with our changelog
  86. echo -e "%changelog
  87. * $( LANG=C date '+%a %b %d %Y' ) Jellyfin Packaging Team <packaging@jellyfin.org>
  88. - New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}" >> ${fedora_changelog_temp}
  89. cat xx01 >> ${fedora_changelog_temp}
  90. # Reassembble
  91. cat xx00 ${fedora_changelog_temp} > ${fedora_spec_temp}
  92. popd
  93. # Move into place
  94. mv ${fedora_spec_temp} ${fedora_spec_file}
  95. # Clean up
  96. rm -rf ${fedora_spec_temp_dir}
  97. # Stage the changed files for commit
  98. git add ${shared_version_file} ${build_file} ${debian_equivs_file} ${debian_changelog_file} ${fedora_spec_file}
  99. git status