bump_version 5.0 KB

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