chore(build): add script to update toxcore version

reviewable/pr5492/r2
Anthony Bilinski 2018-08-29 00:47:23 -07:00
parent fd7097222d
commit 266757ae5e
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
1 changed files with 92 additions and 0 deletions

92
tools/update-toxcore-version.sh Executable file
View File

@ -0,0 +1,92 @@
#!/bin/bash
#
# Copyright © 2016-2018 The qTox Project Contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# script to change targeted toxcore version
#
# it should be run before releasing a new version
# usage:
#
# ./$script $version
#
# $version has to be composed of at least one number/dot
set -eu -o pipefail
readonly SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly BASE_DIR="$SCRIPT_DIR/../"
readonly VERSION_PATTERN="[0-9]+\.[0-9]+\.[0-9]+"
update_install() {
perl -i -0pe "s|(git clone https://github.com/toktok/c-toxcore.*?)$VERSION_PATTERN|\${1}$@|gms" INSTALL.md
perl -i -0pe "s|(git clone https://github.com/toktok/c-toxcore.*?)$VERSION_PATTERN|\${1}$@|gms" INSTALL.fa.md
}
update_bootstrap() {
perl -i -0pe "s|(TOXCORE_VERSION=\"v)$VERSION_PATTERN|\${1}$@|gms" bootstrap.sh
}
update_osx() {
cd osx
perl -i -0pe "s|$VERSION_PATTERN( --depth=1 https://github.com/toktok/c-toxcore)|$@\${1}|gms" qTox-Mac-Deployer-ULTIMATE.sh
cd ..
}
update_flatpak() {
cd flatpak
latest_tag_ref=$(git ls-remote --tags https://github.com/toktok/c-toxcore | tail -n1)
ref_array=($latest_tag_ref)
commit_hash=${ref_array[0]}
perl -i -0pe "s|(https://github.com/toktok/c-toxcore.*?)$VERSION_PATTERN(.*?)[a-f0-9]{40}|\${1}$@\${2}$commit_hash|gms" io.github.qtox.qTox.json
cd ..
}
update_travis() {
cd .travis
perl -i -0pe "s|$VERSION_PATTERN( --depth=1 https://github.com/toktok/c-toxcore)|$@\${1}|gms" build-ubuntu-14-04.sh
cd ..
}
update_docker() {
cd docker
perl -i -0pe "s|(https://github.com/toktok/c-toxcore.*?)$VERSION_PATTERN|\${1}$@|gms" Dockerfile.debian
perl -i -0pe "s|(https://github.com/toktok/c-toxcore.*?)$VERSION_PATTERN|\${1}$@|gms" Dockerfile.ubuntu
cd ..
}
# exit if supplied arg is not a version
is_version() {
if [[ ! $@ =~ $VERSION_PATTERN ]]
then
echo "Not a version: $@"
echo "Must match: $VERSION_PATTERN"
exit 1
fi
}
main() {
is_version "$@"
update_install "$@"
update_bootstrap "$@"
update_osx "$@"
update_flatpak "$@"
update_travis "$@"
update_docker "$@"
}
main "$@"