2016-12-07 23:51:26 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2018-04-13 04:02:28 +08:00
|
|
|
# Copyright © 2016-2018 The qTox Project Contributors
|
2016-12-07 23:51:26 +08:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
|
|
|
|
2017-02-11 13:52:06 +08:00
|
|
|
# script to change versions in the files for osx and windows "packages"
|
2018-09-30 16:06:53 +08:00
|
|
|
#
|
2017-02-11 13:52:06 +08:00
|
|
|
# it should be run before releasing a new version
|
2016-12-07 23:51:26 +08:00
|
|
|
#
|
|
|
|
# NOTE: it checkouts the files before appending a version to them!
|
|
|
|
#
|
|
|
|
# requires:
|
|
|
|
# * GNU sed
|
|
|
|
|
|
|
|
# usage:
|
|
|
|
#
|
2017-02-11 13:52:06 +08:00
|
|
|
# ./$script $version
|
|
|
|
#
|
|
|
|
# $version has to be composed of at least one number/dot
|
2016-12-07 23:51:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
2017-02-23 16:47:46 +08:00
|
|
|
readonly SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
readonly BASE_DIR="$SCRIPT_DIR/../"
|
2018-04-23 04:51:46 +08:00
|
|
|
readonly VERSION_PATTERN="[0-9]+\.[0-9]+\.[0-9]+"
|
2016-12-07 23:51:26 +08:00
|
|
|
|
|
|
|
update_windows() {
|
2017-02-23 16:47:46 +08:00
|
|
|
( cd "$BASE_DIR/windows"
|
2017-02-11 13:52:06 +08:00
|
|
|
./qtox-nsi-version.sh "$@" )
|
2016-12-07 23:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
update_osx() {
|
2017-02-23 16:47:46 +08:00
|
|
|
( cd "$BASE_DIR/osx"
|
2017-02-11 13:52:06 +08:00
|
|
|
./update-plist-version.sh "$@" )
|
|
|
|
}
|
|
|
|
|
2018-04-23 04:51:46 +08:00
|
|
|
update_readme() {
|
|
|
|
cd "$BASE_DIR"
|
|
|
|
sed -ri "s|(github.com/qTox/qTox/releases/download/v)$VERSION_PATTERN|\1$@|g" README.md
|
2018-07-27 03:09:10 +08:00
|
|
|
# for flatpak and AppImage
|
|
|
|
sed -ri "s|(github.com/qTox/qTox/releases/download/v$VERSION_PATTERN/qTox-v)$VERSION_PATTERN|\1$@|g" README.md
|
2018-04-23 04:51:46 +08:00
|
|
|
}
|
|
|
|
|
2018-09-30 16:06:53 +08:00
|
|
|
update_appdata() {
|
|
|
|
cd "$BASE_DIR"/res/
|
|
|
|
local isodate="$(date --iso-8601)"
|
|
|
|
sed -ri "s|(<release version=\")$VERSION_PATTERN|\1$@|g" io.github.qtox.qTox.appdata.xml
|
|
|
|
sed -ri "s|(<release version=\"$VERSION_PATTERN\" date=\").{10}|\1"$isodate"|g" io.github.qtox.qTox.appdata.xml
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-11 13:52:06 +08:00
|
|
|
# exit if supplied arg is not a version
|
|
|
|
is_version() {
|
2018-04-23 04:51:46 +08:00
|
|
|
if [[ ! $@ =~ $VERSION_PATTERN ]]
|
2017-02-11 13:52:06 +08:00
|
|
|
then
|
|
|
|
echo "Not a version: $@"
|
2018-04-23 04:51:46 +08:00
|
|
|
echo "Must match: $VERSION_PATTERN"
|
2017-02-11 13:52:06 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-12-07 23:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2017-02-11 13:52:06 +08:00
|
|
|
is_version "$@"
|
|
|
|
|
2016-12-07 23:51:26 +08:00
|
|
|
# osx cannot into proper sed
|
|
|
|
if [[ ! "$OSTYPE" == "darwin"* ]]
|
|
|
|
then
|
2017-02-11 13:52:06 +08:00
|
|
|
update_osx "$@"
|
|
|
|
update_windows "$@"
|
2018-04-23 04:51:46 +08:00
|
|
|
update_readme "$@"
|
2018-09-30 16:06:53 +08:00
|
|
|
update_appdata "$@"
|
2017-02-11 13:52:06 +08:00
|
|
|
else
|
|
|
|
# TODO: actually check whether there is a GNU sed on osx
|
|
|
|
echo "OSX's sed not supported. Get a proper one."
|
2016-12-07 23:51:26 +08:00
|
|
|
fi
|
|
|
|
}
|
2017-02-11 13:52:06 +08:00
|
|
|
main "$@"
|