bump_version 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. web_branch="$( git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' )"
  22. # Initialize submodules
  23. git submodule update --init --recursive
  24. # configure branch
  25. pushd MediaBrowser.WebDashboard/jellyfin-web
  26. if ! git diff-index --quiet HEAD --; then
  27. popd
  28. echo
  29. echo "ERROR: Your 'jellyfin-web' submodule working directory is not clean!"
  30. echo "This script will overwrite your unstaged and unpushed changes."
  31. echo "Please do development on 'jellyfin-web' outside of the submodule."
  32. exit 1
  33. fi
  34. git fetch --all
  35. git checkout origin/${web_branch}
  36. popd
  37. git add MediaBrowser.WebDashboard/jellyfin-web
  38. new_version="$1"
  39. # Parse the version from the AssemblyVersion
  40. old_version="$(
  41. grep "AssemblyVersion" ${shared_version_file} \
  42. | sed -E 's/\[assembly: ?AssemblyVersion\("([0-9\.]+)"\)\]/\1/'
  43. )"
  44. echo $old_version
  45. # Set the shared version to the specified new_version
  46. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  47. new_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"
  48. sed -i "s/${old_version_sed}/${new_version_sed}/g" ${shared_version_file}
  49. old_version="$(
  50. grep "version:" ${build_file} \
  51. | sed -E 's/version: "([0-9\.]+[-a-z0-9]*)"/\1/'
  52. )"
  53. echo $old_version
  54. # Set the build.yaml version to the specified new_version
  55. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  56. sed -i "s/${old_version_sed}/${new_version}/g" ${build_file}
  57. if [[ ${new_version} == *"-"* ]]; then
  58. new_version_deb="$( sed 's/-/~/g' <<<"${new_version}" )"
  59. else
  60. new_version_deb="${new_version}-1"
  61. fi
  62. # Set the Dockerfile web version to the specified new_version
  63. old_version="$(
  64. grep "JELLYFIN_WEB_VERSION=" Dockerfile \
  65. | sed -E 's/ARG JELLYFIN_WEB_VERSION=([0-9\.]+[-a-z0-9]*)/\1/'
  66. )"
  67. echo $old_version
  68. old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
  69. sed -i "s/${old_version_sed}/${new_version}/g" Dockerfile*
  70. # Write out a temporary Debian changelog with our new stuff appended and some templated formatting
  71. debian_changelog_file="deployment/debian-package-x64/pkg-src/changelog"
  72. debian_changelog_temp="$( mktemp )"
  73. # Create new temp file with our changelog
  74. echo -e "### DEBIAN PACKAGE CHANGELOG: Verify this file looks correct or edit accordingly, then delete this line, write, and exit.
  75. jellyfin (${new_version_deb}) 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. # Edit the file to verify
  81. $EDITOR ${debian_changelog_temp}
  82. # Move into place
  83. mv ${debian_changelog_temp} ${debian_changelog_file}
  84. # Clean up
  85. rm -f ${debian_changelog_temp}
  86. # Write out a temporary Yum changelog with our new stuff prepended and some templated formatting
  87. fedora_spec_file="deployment/fedora-package-x64/pkg-src/jellyfin.spec"
  88. fedora_changelog_temp="$( mktemp )"
  89. fedora_spec_temp_dir="$( mktemp -d )"
  90. fedora_spec_temp="${fedora_spec_temp_dir}/jellyfin.spec.tmp"
  91. # Make a copy of our spec file for hacking
  92. cp ${fedora_spec_file} ${fedora_spec_temp_dir}/
  93. pushd ${fedora_spec_temp_dir}
  94. # Split out the stuff before and after changelog
  95. csplit jellyfin.spec "/^%changelog/" # produces xx00 xx01
  96. # Update the version in xx00
  97. sed -i "s/${old_version_sed}/${new_version_sed}/g" xx00
  98. # Remove the header from xx01
  99. sed -i '/^%changelog/d' xx01
  100. # Create new temp file with our changelog
  101. echo -e "### YUM SPEC CHANGELOG: Verify this file looks correct or edit accordingly, then delete this line, write, and exit.
  102. %changelog
  103. * $( LANG=C date '+%a %b %d %Y' ) Jellyfin Packaging Team <packaging@jellyfin.org>
  104. - New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}" >> ${fedora_changelog_temp}
  105. cat xx01 >> ${fedora_changelog_temp}
  106. # Edit the file to verify
  107. $EDITOR ${fedora_changelog_temp}
  108. # Reassembble
  109. cat xx00 ${fedora_changelog_temp} > ${fedora_spec_temp}
  110. popd
  111. # Move into place
  112. mv ${fedora_spec_temp} ${fedora_spec_file}
  113. # Clean up
  114. rm -rf ${fedora_changelog_temp} ${fedora_spec_temp_dir}
  115. # Stage the changed files for commit
  116. git add ${shared_version_file} ${build_file} ${debian_changelog_file} ${fedora_spec_file} Dockerfile*
  117. git status