From 63e95f35280e13fe866eeb7f364d71c32b38281d Mon Sep 17 00:00:00 2001 From: Zetok Zalbavar Date: Sat, 11 Feb 2017 05:52:06 +0000 Subject: [PATCH] chore(build): adjust version updating script to not rely on git Relying on git doesn't work in awful lot of cases, e.g. when there's a shallow `git clone`. Instead have "hardcoded" version in files, and update it before release. Closes #4165. --- MAINTAINING.md | 3 +++ osx/info.plist | 4 ++-- osx/update-plist-version.sh | 48 +++++++++++++++++++++++++------------ tools/lib/git.source | 28 ---------------------- tools/update-versions.sh | 35 +++++++++++++++++++-------- windows/qtox-nsi-version.sh | 42 ++++++++++++++++++-------------- windows/qtox.nsi | 1 + windows/qtox64.nsi | 1 + 8 files changed, 89 insertions(+), 73 deletions(-) delete mode 100644 tools/lib/git.source diff --git a/MAINTAINING.md b/MAINTAINING.md index d2b21750d..973a3655a 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -162,6 +162,8 @@ process, so that no translation effort would be lost when resetting Weblate.** - `PATCH` – bump when there have been only fixes added. If changes include something more than just bugfixes, bump `MAJOR` or `MINOR` version accordingly. +- update version for windows/osx packages using [`./tools/update-versions.sh`] + script - before creating a `MAJOR`/`MINOR` release generate changelog with `clog`. - in a `MAJOR`/`MINOR` release tag should include information that changelog is located in the `CHANGELOG.md` file, e.g. `For details see CHANGELOG.md` @@ -196,3 +198,4 @@ helping for a while, ask to be added to the `qTox` organization on GitHub. [`test-pr.sh`]: /test-pr.sh [`./tools/deweblate-translation-file.sh`]: /tools/deweblate-translation-file.sh [`./tools/create-tarball.sh`]: /tools/create-tarball.sh +[`./tools/update-versions.sh`]: /tools/update-versions.sh diff --git a/osx/info.plist b/osx/info.plist index 123c794ce..f28cffc91 100644 --- a/osx/info.plist +++ b/osx/info.plist @@ -65,7 +65,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.7.0 + 1.8.1 CFBundleSignature toxq CFBundleURLTypes @@ -84,7 +84,7 @@ CFBundleVersion - 1.7.0 + 1.8.1 NSPrincipalClass NSApplication UTImportedTypeDeclarations diff --git a/osx/update-plist-version.sh b/osx/update-plist-version.sh index ef7b8bf68..ef41e1e51 100755 --- a/osx/update-plist-version.sh +++ b/osx/update-plist-version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright © 2016 The qTox Project Contributors +# Copyright © 2016-2017 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 @@ -16,30 +16,48 @@ # along with this program. If not, see . -# script to append correct qTox version to `.plist` file from -# `git describe` +# script to change qTox version in `info.plist` file to the supplied one # # NOTE: it checkouts the files before appending a version to them! # # requires: -# * correctly formatted `*.plist file(s) in working dir -# * git – tags in format `v0.0.0` +# * correctly formatted `info.plist file in working dir # * GNU sed # usage: # -# ./$script +# ./$script $version +# +# $version has to be composed of at least one number/dot set -eu -o pipefail -# uses `get_version()` -source "../tools/lib/git.source" - -# append version to .plist file(s) after the right line +# update version in `info.plist` file to supplied one after the right lines update_version() { - local ver=$(get_version) - defaults write "$(pwd)/info.plist" CFBundleVersion $ver - defaults write "$(pwd)/info.plist" CFBundleShortVersionString $ver - plutil -convert xml1 info.plist + local vars=( + ' CFBundleShortVersionString' + ' CFBundleVersion' + ) + + for v in "${vars[@]}" + do + sed -i -r "\\R$v\$R,+1 s,()[0-9\\.]+()$,\\1$@\\2," \ + "./info.plist" + done } -update_version + +# exit if supplied arg is not a version +is_version() { + if [[ ! $@ =~ [0-9\\.]+ ]] + then + echo "Not a version: $@" + exit 1 + fi +} + +main() { + is_version "$@" + + update_version "$@" +} +main "$@" diff --git a/tools/lib/git.source b/tools/lib/git.source deleted file mode 100644 index d722160f3..000000000 --- a/tools/lib/git.source +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -# Copyright © 2016 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 . - - -# source for scripts using git-based functionality - -set -e -o pipefail - -# Get numerical version from git tag, parts of version separated by dots -# from e.g. `v123.456.789` get `123.456.789` part -get_version() { - git describe --abbrev=0 \ - | sed -e 's/^v//' -} diff --git a/tools/update-versions.sh b/tools/update-versions.sh index 85b4b98d4..87f0998d3 100755 --- a/tools/update-versions.sh +++ b/tools/update-versions.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright © 2016 The qTox Project Contributors +# Copyright © 2016-2017 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 @@ -16,19 +16,20 @@ # along with this program. If not, see . -# script to add versions to the files for osx and windows "packages" +# script to change versions in the files for osx and windows "packages" # -# it should be run by the `qTox-Mac-Deployer-ULTIMATE.sh` +# it should be run before releasing a new version # # NOTE: it checkouts the files before appending a version to them! # # requires: -# * git – tags in format `v0.0.0` # * GNU sed # usage: # -# ./$script +# ./$script $version +# +# $version has to be composed of at least one number/dot set -eu -o pipefail @@ -36,20 +37,34 @@ set -eu -o pipefail update_windows() { ( cd windows - ./qtox-nsi-version.sh ) + ./qtox-nsi-version.sh "$@" ) } update_osx() { ( cd osx - ./update-plist-version.sh ) + ./update-plist-version.sh "$@" ) +} + +# exit if supplied arg is not a version +is_version() { + if [[ ! $@ =~ [0-9\\.]+ ]] + then + echo "Not a version: $@" + exit 1 + fi } main() { - update_osx + is_version "$@" + # osx cannot into proper sed if [[ ! "$OSTYPE" == "darwin"* ]] then - update_windows + update_osx "$@" + update_windows "$@" + else + # TODO: actually check whether there is a GNU sed on osx + echo "OSX's sed not supported. Get a proper one." fi } -main +main "$@" diff --git a/windows/qtox-nsi-version.sh b/windows/qtox-nsi-version.sh index b51d74488..2c6a8ca2c 100755 --- a/windows/qtox-nsi-version.sh +++ b/windows/qtox-nsi-version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright © 2016 Zetok Zalbavar +# Copyright © 2016-2017 Zetok Zalbavar # # 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 @@ -15,36 +15,42 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# script to append correct qTox version to `.nsi` files from -# `git describe` -# -# NOTE: it checkouts the files before appending a version to them! + +# script to change qTox version in `.nsi` files to supplied one # # requires: # * files `qtox.nsi` and `qtox64.nsi` in working dir -# * git – tags in format `v0.0.0` # * GNU sed # usage: # -# ./$script +# ./$script $version +# +# $version has to be composed of at least one number/dot set -eu -o pipefail -# uses `get_version()` -source "../tools/lib/git.source" - - -# append version to .nsi files after a certain line -append_version() { - local after_line=' ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "qTox"' - local append=' ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion"' +# change version in .nsi files in the right line +change_version() { for nsi in *.nsi do - git checkout "$nsi" - sed -i "/$after_line/a\\$append \"$(get_version)\"" "$nsi" + sed -i -r "/DisplayVersion/ s/\"[0-9\\.]+\"$/\"$@\"/" "$nsi" done } -append_version +# exit if supplied arg is not a version +is_version() { + if [[ ! $@ =~ [0-9\\.]+ ]] + then + echo "Not a version: $@" + exit 1 + fi +} + +main() { + is_version "$@" + + change_version "$@" +} +main "$@" diff --git a/windows/qtox.nsi b/windows/qtox.nsi index 473d85ed4..40119472d 100644 --- a/windows/qtox.nsi +++ b/windows/qtox.nsi @@ -281,6 +281,7 @@ Section "Install" ${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}" ${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "Path" "$INSTDIR\bin\" ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "qTox" + ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "1.8.1" ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "The qTox Project" ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe" ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "https://qtox.github.io" diff --git a/windows/qtox64.nsi b/windows/qtox64.nsi index 4ef47e277..61bec912b 100644 --- a/windows/qtox64.nsi +++ b/windows/qtox64.nsi @@ -281,6 +281,7 @@ Section "Install" ${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}" ${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "Path" "$INSTDIR\bin\" ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "qTox" + ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "1.8.1" ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "The qTox Project" ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe" ${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "https://qtox.github.io"