2020-03-30 12:31:14 -07:00
#!/usr/bin/env bash
# bump_version - increase the shared version and generate changelogs
set -o errexit
set -o pipefail
2021-12-12 18:28:28 -07:00
set -o xtrace
2020-03-30 12:31:14 -07:00
usage() {
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 1
fi
build_file="./build.yaml"
2021-09-06 13:26:25 -07:00
package_file="./package*.json"
2020-03-30 12:31:14 -07:00
new_version="$1"
2021-12-12 18:28:28 -07:00
old_version="$(
grep "version:" ${build_file} \
| sed -E 's/version: "([0-9\.]+[-a-z0-9]*)"/\1/'
)"
2021-09-06 13:26:25 -07:00
echo "Old version: ${old_version}"
# Bump the NPM version
2021-10-05 20:30:27 -07:00
new_version_sed="$( cut -f1 -d'-' <<<"${new_version}" )"
npm --no-git-tag-version --allow-same-version version v${new_version_sed}
2020-03-30 12:31:14 -07:00
# Set the build.yaml version to the specified new_version
old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
2021-12-12 18:28:28 -07:00
sed -i "s/${old_version_sed}/${new_version_sed}/g" ${build_file}
2020-03-30 12:31:14 -07:00
if [[ ${new_version} == *"-"* ]]; then
2021-12-12 18:28:28 -07:00
new_version_pkg="$( sed 's/-/~/g' <<<"${new_version}" )"
new_version_deb_sup=""
2020-03-30 12:31:14 -07:00
else
2021-12-12 18:28:28 -07:00
new_version_pkg="${new_version}"
new_version_deb_sup="-1"
2020-03-30 12:31:14 -07:00
fi
# Write out a temporary Debian changelog with our new stuff appended and some templated formatting
debian_changelog_file="debian/changelog"
debian_changelog_temp="$( mktemp )"
# Create new temp file with our changelog
2021-12-12 18:28:28 -07:00
echo -e "jellyfin-web (${new_version_pkg}${new_version_deb_sup}) unstable; urgency=medium
2020-03-30 12:31:14 -07:00
* New upstream version ${new_version}; release changelog at https://github.com/jellyfin/jellyfin-web/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 place
mv ${debian_changelog_temp} ${debian_changelog_file}
# Write out a temporary Yum changelog with our new stuff prepended and some templated formatting
2020-07-27 15:40:42 -07:00
fedora_spec_file="fedora/jellyfin-web.spec"
2020-03-30 12:31:14 -07:00
fedora_changelog_temp="$( mktemp )"
fedora_spec_temp_dir="$( mktemp -d )"
2020-07-27 15:40:42 -07:00
fedora_spec_temp="${fedora_spec_temp_dir}/jellyfin-web.spec.tmp"
2020-03-30 12:31:14 -07:00
# 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
2020-07-27 15:40:42 -07:00
csplit jellyfin-web.spec "/^%changelog/" # produces xx00 xx01
2020-03-30 12:31:14 -07:00
# Update the version in xx00
2021-12-12 18:28:28 -07:00
sed -i "s/${old_version_sed}/${new_version_pkg}/g" xx00
2020-03-30 12:31:14 -07: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-web/releases/tag/v${new_version}" >> ${fedora_changelog_temp}
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
2021-12-12 18:28:28 -07:00
rm -rf ${fedora_spec_temp_dir}
2020-03-30 12:31:14 -07:00
# Stage the changed files for commit
2021-12-12 18:28:28 -07:00
git add .
git status -v