jellyfin/bump_version

130 lines
4.4 KiB
Plaintext
Raw Normal View History

2019-01-20 00:11:01 +01:00
#!/usr/bin/env bash
# bump_version - increase the shared version and generate changelogs
set -o errexit
set -o pipefail
2020-07-28 01:01:33 +02:00
set -o xtrace
2019-01-20 00:11:01 +01:00
usage() {
echo -e "bump_version - increase the shared version and generate changelogs"
echo -e ""
echo -e "Usage:"
echo -e " $ bump_version <new_version>"
2019-01-20 00:11:01 +01:00
}
if [[ -z $1 ]]; then
usage
exit 1
fi
shared_version_file="./SharedVersion.cs"
build_file="./build.yaml"
2020-08-13 15:22:12 +02:00
# csproj files for nuget packages
jellyfin_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
src/Jellyfin.Extensions/Jellyfin.Extensions.csproj
)
2019-01-20 00:11:01 +01:00
new_version="$1"
# Parse the version from the AssemblyVersion
old_version="$(
grep "AssemblyVersion" ${shared_version_file} \
| sed -E 's/\[assembly: ?AssemblyVersion\("([0-9\.]+)"\)\]/\1/'
2019-01-20 00:11:01 +01:00
)"
2019-04-10 06:23:39 +02:00
echo $old_version
2019-01-20 00:11:01 +01:00
# Set the shared version to the specified new_version
old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
new_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"
sed -i "s/${old_version_sed}/${new_version_sed}/g" ${shared_version_file}
2019-01-20 00:11:01 +01:00
old_version="$(
grep "version:" ${build_file} \
2019-04-10 06:23:39 +02:00
| sed -E 's/version: "([0-9\.]+[-a-z0-9]*)"/\1/'
)"
2019-04-10 06:23:39 +02:00
echo $old_version
2019-04-10 06:23:39 +02:00
# Set the build.yaml version to the specified new_version
old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
new_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"
sed -i "s/${old_version_sed}/${new_version_sed}/g" ${build_file}
2020-08-13 15:22:12 +02:00
# update nuget package version
2020-08-25 10:08:05 +02:00
for subproject in ${jellyfin_subprojects[@]}; do
echo ${subproject}
2020-08-13 15:22:12 +02:00
# Parse the version from the *.csproj file
old_version="$(
2020-08-25 10:08:05 +02:00
grep "VersionPrefix" ${subproject} \
2020-08-13 15:22:12 +02:00
| awk '{$1=$1};1' \
2020-08-13 19:03:24 +02:00
| sed -E 's/<VersionPrefix>([0-9\.]+[-a-z0-9]*)<\/VersionPrefix>/\1/'
2020-08-13 15:22:12 +02:00
)"
echo old nuget version: $old_version
new_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"
2020-08-13 15:22:12 +02:00
# Set the nuget version to the specified new_version
sed -i "s|${old_version}|${new_version_sed}|g" ${subproject}
2020-08-13 15:22:12 +02:00
done
if [[ ${new_version} == *"-"* ]]; then
new_version_pkg="$( sed 's/-/~/g' <<<"${new_version}" )"
new_version_deb_sup=""
else
new_version_pkg="${new_version}"
new_version_deb_sup="-1"
fi
2019-01-20 00:11:01 +01:00
# Update the metapackage equivs file
debian_equivs_file="debian/metapackage/jellyfin"
sed -i "s/${old_version_sed}/${new_version_pkg}/g" ${debian_equivs_file}
2019-04-10 06:23:39 +02:00
2019-01-20 00:11:01 +01:00
# Write out a temporary Debian changelog with our new stuff appended and some templated formatting
debian_changelog_file="debian/changelog"
2019-01-20 00:11:01 +01:00
debian_changelog_temp="$( mktemp )"
# Create new temp file with our changelog
echo -e "jellyfin-server (${new_version_pkg}${new_version_deb_sup}) unstable; urgency=medium
* New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}
2019-01-20 00:11:01 +01:00
2019-01-21 06:00:16 +01:00
-- Jellyfin Packaging Team <packaging@jellyfin.org> $( date --rfc-2822 )
2019-01-20 00:11:01 +01:00
" >> ${debian_changelog_temp}
cat ${debian_changelog_file} >> ${debian_changelog_temp}
# Move into place
mv ${debian_changelog_temp} ${debian_changelog_file}
# Write out a temporary Yum changelog with our new stuff prepended and some templated formatting
fedora_spec_file="fedora/jellyfin.spec"
2019-01-20 00:11:01 +01:00
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 hacking
cp ${fedora_spec_file} ${fedora_spec_temp_dir}/
pushd ${fedora_spec_temp_dir}
# Split out the stuff before and after changelog
csplit jellyfin.spec "/^%changelog/" # produces xx00 xx01
# Update the version in xx00
sed -i "s/${old_version_sed}/${new_version_pkg}/g" xx00
2019-01-20 00:11:01 +01:00
# Remove the header from xx01
sed -i '/^%changelog/d' xx01
# Create new temp file with our changelog
echo -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}
2019-01-20 00:11:01 +01:00
cat xx01 >> ${fedora_changelog_temp}
# Reassembble
cat xx00 ${fedora_changelog_temp} > ${fedora_spec_temp}
popd
# Move into place
mv ${fedora_spec_temp} ${fedora_spec_file}
# Clean up
2020-04-09 17:37:00 +02:00
rm -rf ${fedora_spec_temp_dir}
2019-01-20 00:11:01 +01:00
# Stage the changed files for commit
git add .
2021-12-11 21:03:07 +01:00
git status -v