bump_version 4.4 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. 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. echo -e ""
  11. echo -e "The web_branch defaults to the same branch name as the current main branch."
  12. echo -e "This helps facilitate releases where both branches would be called release-X.Y.Z"
  13. echo -e "and would already be created before running this script."
  14. }
  15. if [[ -z $1 ]]; then
  16. usage
  17. exit 1
  18. fi
  19. shared_version_file="./SharedVersion.cs"
  20. build_file="./build.yaml"
  21. new_version="$1"
  22. # Parse the version from the AssemblyVersion
  23. old_version="$(
  24. grep "AssemblyVersion" ${shared_version_file} \
  25. | sed -E 's/\[assembly: ?AssemblyVersion\("([0-9\.]+)"\)\]/\1/'
  26. )"
  27. echo $old_version
  28. # Set the shared version to the specified new_version
  29. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  30. new_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"
  31. sed -i "s/${old_version_sed}/${new_version_sed}/g" ${shared_version_file}
  32. old_version="$(
  33. grep "version:" ${build_file} \
  34. | sed -E 's/version: "([0-9\.]+[-a-z0-9]*)"/\1/'
  35. )"
  36. echo $old_version
  37. # Set the build.yaml version to the specified new_version
  38. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  39. sed -i "s/${old_version_sed}/${new_version}/g" ${build_file}
  40. if [[ ${new_version} == *"-"* ]]; then
  41. new_version_deb="$( sed 's/-/~/g' <<<"${new_version}" )"
  42. else
  43. new_version_deb="${new_version}-1"
  44. fi
  45. # Set the Dockerfile web version to the specified new_version
  46. old_version="$(
  47. grep "JELLYFIN_WEB_VERSION=" Dockerfile \
  48. | sed -E 's/ARG JELLYFIN_WEB_VERSION=v([0-9\.]+[-a-z0-9]*)/\1/'
  49. )"
  50. echo $old_version
  51. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  52. sed -i "s/${old_version_sed}/${new_version}/g" Dockerfile*
  53. # Write out a temporary Debian changelog with our new stuff appended and some templated formatting
  54. debian_changelog_file="deployment/debian-package-x64/pkg-src/changelog"
  55. debian_changelog_temp="$( mktemp )"
  56. # Create new temp file with our changelog
  57. echo -e "### DEBIAN PACKAGE CHANGELOG: Verify this file looks correct or edit accordingly, then delete this line, write, and exit.
  58. jellyfin (${new_version_deb}) unstable; urgency=medium
  59. * New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}
  60. -- Jellyfin Packaging Team <packaging@jellyfin.org> $( date --rfc-2822 )
  61. " >> ${debian_changelog_temp}
  62. cat ${debian_changelog_file} >> ${debian_changelog_temp}
  63. # Edit the file to verify
  64. $EDITOR ${debian_changelog_temp}
  65. # Move into place
  66. mv ${debian_changelog_temp} ${debian_changelog_file}
  67. # Clean up
  68. rm -f ${debian_changelog_temp}
  69. # Write out a temporary Yum changelog with our new stuff prepended and some templated formatting
  70. fedora_spec_file="deployment/fedora-package-x64/pkg-src/jellyfin.spec"
  71. fedora_changelog_temp="$( mktemp )"
  72. fedora_spec_temp_dir="$( mktemp -d )"
  73. fedora_spec_temp="${fedora_spec_temp_dir}/jellyfin.spec.tmp"
  74. # Make a copy of our spec file for hacking
  75. cp ${fedora_spec_file} ${fedora_spec_temp_dir}/
  76. pushd ${fedora_spec_temp_dir}
  77. # Split out the stuff before and after changelog
  78. csplit jellyfin.spec "/^%changelog/" # produces xx00 xx01
  79. # Update the version in xx00
  80. sed -i "s/${old_version_sed}/${new_version_sed}/g" xx00
  81. # Remove the header from xx01
  82. sed -i '/^%changelog/d' xx01
  83. # Create new temp file with our changelog
  84. echo -e "### YUM SPEC CHANGELOG: Verify this file looks correct or edit accordingly, then delete this line, write, and exit.
  85. %changelog
  86. * $( LANG=C date '+%a %b %d %Y' ) Jellyfin Packaging Team <packaging@jellyfin.org>
  87. - New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}" >> ${fedora_changelog_temp}
  88. cat xx01 >> ${fedora_changelog_temp}
  89. # Edit the file to verify
  90. $EDITOR ${fedora_changelog_temp}
  91. # Reassembble
  92. cat xx00 ${fedora_changelog_temp} > ${fedora_spec_temp}
  93. popd
  94. # Move into place
  95. mv ${fedora_spec_temp} ${fedora_spec_file}
  96. # Clean up
  97. rm -rf ${fedora_changelog_temp} ${fedora_spec_temp_dir}
  98. # Stage the changed files for commit
  99. git add ${shared_version_file} ${build_file} ${debian_changelog_file} ${fedora_spec_file} Dockerfile*
  100. git status