jellyfin/bump_version

146 lines
5.0 KiB
Plaintext
Raw Normal View History

2019-01-19 23:11:01 +00:00
#!/usr/bin/env bash
# bump_version - increase the shared version and generate changelogs
set -o errexit
set -o pipefail
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-19 23:11:01 +00:00
echo -e ""
echo -e "The web_branch defaults to the same branch name as the current main branch."
echo -e "This helps facilitate releases where both branches would be called release-X.Y.Z"
echo -e "and would already be created before running this script."
}
if [[ -z $1 ]]; then
usage
exit 1
fi
shared_version_file="./SharedVersion.cs"
build_file="./build.yaml"
2019-01-19 23:11:01 +00:00
if [[ -z $2 ]]; then
web_branch="$( git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' )"
else
web_branch="$2"
fi
2019-01-19 23:11:01 +00:00
# Initialize submodules
git submodule update --init --recursive
# configure branch
pushd MediaBrowser.WebDashboard/jellyfin-web
if ! git diff-index --quiet HEAD --; then
popd
echo
echo "ERROR: Your 'jellyfin-web' submodule working directory is not clean!"
echo "This script will overwrite your unstaged and unpushed changes."
echo "Please do development on 'jellyfin-web' outside of the submodule."
exit 1
fi
2019-01-19 23:11:01 +00:00
git fetch --all
git checkout origin/${web_branch}
2019-01-19 23:11:01 +00:00
popd
git add MediaBrowser.WebDashboard/jellyfin-web
2019-01-19 23:11:01 +00: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-19 23:11:01 +00:00
)"
2019-04-10 04:23:39 +00:00
echo $old_version
2019-01-19 23:11:01 +00: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-19 23:11:01 +00:00
old_version="$(
grep "version:" ${build_file} \
2019-04-10 04:23:39 +00:00
| sed -E 's/version: "([0-9\.]+[-a-z0-9]*)"/\1/'
)"
2019-04-10 04:23:39 +00:00
echo $old_version
2019-04-10 04:23:39 +00:00
# Set the build.yaml version to the specified new_version
old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
sed -i "s/${old_version_sed}/${new_version}/g" ${build_file}
if [[ ${new_version} == *"-"* ]]; then
new_version_deb="$( sed 's/-/~/g' <<<"${new_version}" )"
else
new_version_deb="${new_version}-1"
fi
2019-01-19 23:11:01 +00:00
2019-04-10 04:23:39 +00:00
# Set the Dockerfile web version to the specified new_version
old_version="$(
grep "JELLYFIN_WEB_VERSION=" Dockerfile \
| sed -E 's/ARG JELLYFIN_WEB_VERSION=v([0-9\.]+[-a-z0-9]*)/\1/'
2019-04-10 04:23:39 +00:00
)"
echo $old_version
old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
sed -i "s/${old_version_sed}/${new_version}/g" Dockerfile*
2019-01-19 23:11:01 +00:00
# Write out a temporary Debian changelog with our new stuff appended and some templated formatting
debian_changelog_file="deployment/debian-package-x64/pkg-src/changelog"
debian_changelog_temp="$( mktemp )"
# Create new temp file with our changelog
echo -e "### DEBIAN PACKAGE CHANGELOG: Verify this file looks correct or edit accordingly, then delete this line, write, and exit.
jellyfin (${new_version_deb}) unstable; urgency=medium
* New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v${new_version}
2019-01-19 23:11:01 +00:00
2019-01-21 05:00:16 +00:00
-- Jellyfin Packaging Team <packaging@jellyfin.org> $( date --rfc-2822 )
2019-01-19 23:11:01 +00:00
" >> ${debian_changelog_temp}
cat ${debian_changelog_file} >> ${debian_changelog_temp}
# Edit the file to verify
$EDITOR ${debian_changelog_temp}
# Move into place
mv ${debian_changelog_temp} ${debian_changelog_file}
# Clean up
rm -f ${debian_changelog_temp}
# Write out a temporary Yum changelog with our new stuff prepended and some templated formatting
fedora_spec_file="deployment/fedora-package-x64/pkg-src/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 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_sed}/g" xx00
2019-01-19 23:11:01 +00:00
# Remove the header from xx01
sed -i '/^%changelog/d' xx01
# Create new temp file with our changelog
echo -e "### YUM SPEC CHANGELOG: Verify this file looks correct or edit accordingly, then delete this line, write, and exit.
%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-19 23:11:01 +00:00
cat xx01 >> ${fedora_changelog_temp}
# Edit the file to verify
$EDITOR ${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
rm -rf ${fedora_changelog_temp} ${fedora_spec_temp_dir}
# Stage the changed files for commit
2019-04-10 04:23:39 +00:00
git add ${shared_version_file} ${build_file} ${debian_changelog_file} ${fedora_spec_file} Dockerfile*
2019-01-19 23:11:01 +00:00
git status