| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 | #!/usr/bin/env bash# bump_version - increase the shared version and generate changelogsset -o errexitset -o pipefailset -o xtraceusage() {    echo -e "bump_version - increase the shared version and generate changelogs"    echo -e ""    echo -e "Usage:"    echo -e " $ bump_version <new_version>"}if [[ -z $1 ]]; then    usage    exit 1fishared_version_file="./SharedVersion.cs"build_file="./build.yaml"# csproj files for nuget packagesjellyfin_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 )new_version="$1"# Parse the version from the AssemblyVersionold_version="$(    grep "AssemblyVersion" ${shared_version_file} \        | sed -E 's/\[assembly: ?AssemblyVersion\("([0-9\.]+)"\)\]/\1/')"echo $old_version# Set the shared version to the specified new_versionold_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' charsnew_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"sed -i "s/${old_version_sed}/${new_version_sed}/g" ${shared_version_file}old_version="$(    grep "version:" ${build_file} \        | sed -E 's/version: "([0-9\.]+[-a-z0-9]*)"/\1/')"echo $old_version# Set the build.yaml version to the specified new_versionold_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' charssed -i "s/${old_version_sed}/${new_version}/g" ${build_file}# update nuget package versionfor subproject in ${jellyfin_subprojects[@]}; do    echo ${subproject}    # Parse the version from the *.csproj file    old_version="$(        grep "VersionPrefix" ${subproject} \            | awk '{$1=$1};1' \            | sed -E 's/<VersionPrefix>([0-9\.]+[-a-z0-9]*)<\/VersionPrefix>/\1/'    )"    echo old nuget version: $old_version    # Set the nuget version to the specified new_version    sed -i "s|${old_version}|${new_version}|g" ${subproject}doneif [[ ${new_version} == *"-"* ]]; then    new_version_deb="$( sed 's/-/~/g' <<<"${new_version}" )"else    new_version_deb="${new_version}-1"fi# Update the metapackage equivs filedebian_equivs_file="debian/metapackage/jellyfin"sed -i "s/${old_version_sed}/${new_version}/g" ${debian_equivs_file}# Write out a temporary Debian changelog with our new stuff appended and some templated formattingdebian_changelog_file="debian/changelog"debian_changelog_temp="$( mktemp )"# Create new temp file with our changelogecho -e "jellyfin-server (${new_version_deb}) unstable; urgency=medium  * New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version} -- Jellyfin Packaging Team <packaging@jellyfin.org>  $( date --rfc-2822 )" >> ${debian_changelog_temp}cat ${debian_changelog_file} >> ${debian_changelog_temp}# Move into placemv ${debian_changelog_temp} ${debian_changelog_file}# Write out a temporary Yum changelog with our new stuff prepended and some templated formattingfedora_spec_file="fedora/jellyfin.spec"fedora_changelog_temp="$( mktemp )"fedora_spec_temp_dir="$( mktemp -d )"fedora_spec_temp="${fedora_spec_temp_dir}/jellyfin.spec.tmp"# Make a copy of our spec file for hackingcp ${fedora_spec_file} ${fedora_spec_temp_dir}/pushd ${fedora_spec_temp_dir}# Split out the stuff before and after changelogcsplit jellyfin.spec  "/^%changelog/" # produces xx00 xx01# Update the version in xx00sed -i "s/${old_version_sed}/${new_version_sed}/g" xx00# Remove the header from xx01sed -i '/^%changelog/d' xx01# Create new temp file with our changelogecho -e "%changelog* $( LANG=C date '+%a %b %d %Y' ) Jellyfin Packaging Team <packaging@jellyfin.org>- New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}" >> ${fedora_changelog_temp}cat xx01 >> ${fedora_changelog_temp}# Reassembblecat xx00 ${fedora_changelog_temp} > ${fedora_spec_temp}popd# Move into placemv ${fedora_spec_temp} ${fedora_spec_file}# Clean uprm -rf ${fedora_spec_temp_dir}# Stage the changed files for commitgit add ${shared_version_file} ${build_file} ${debian_equivs_file} ${debian_changelog_file} ${fedora_spec_file}git status
 |