bump_version 4.4 KB

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