From 07e8b36efb23b55fb8c3ba9f65bdc4ced39ba96e Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 3 Sep 2018 14:18:56 +0200 Subject: [PATCH] Do not overwrite release build archives. We new release of a project is made, projects dependending of it are rebuild and republish to keep the binaries up-to-date. To avoid overwrite the already build archives and silent the fact that new archives are available, we need to have a extra build version. `release_versions[project]` has to be set each time a dependency of `project` is bump but the project version has not changed. If the `project` version changes, the `release_versions[project]` has to be cleared. If we don't want to release this version again, remove project from `release_versions`. See kiwix/kiwix-tools#222 --- kiwixbuild/versions.py | 18 ++++++++++++++++++ travis/compile_all.py | 21 +++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/kiwixbuild/versions.py b/kiwixbuild/versions.py index f5647c8..ccbc153 100644 --- a/kiwixbuild/versions.py +++ b/kiwixbuild/versions.py @@ -1,3 +1,4 @@ +# This file reference all the versions of the depedencies we use in kiwix-build. main_project_versions = { 'kiwix-lib': '2.0.2', @@ -8,6 +9,23 @@ main_project_versions = { 'kiwix-desktop': '2.0-alpha2' } +# This dictionnary specify what we need to build at each release process. +# - Values are integer or None +# - If a project is not in the dict (or None), the project is not released. +# - If release_versions[project] == 0, this is the first time the project is +# build for this release, so publish src and build archives. +# - If release_versions[project] > 0, release only the build archive with a +# build postfix. +# To change this dictionnary, use the following algorithm: +# - If project version change, set release_versions[project] = 0 +# - Else +# - If project depedencies have not change, remove project from release_versions +# - Else, increment the value. If no value was present, see in +# http://download.kiwikorg/releases what to set. + +release_versions = { +} + # This is the "version" of the whole base_deps_versions dict. # Change this when you change base_deps_versions. diff --git a/travis/compile_all.py b/travis/compile_all.py index f43e97c..463b949 100755 --- a/travis/compile_all.py +++ b/travis/compile_all.py @@ -13,6 +13,7 @@ from urllib.error import URLError from kiwixbuild.versions import ( main_project_versions, + release_versions, base_deps_versions, base_deps_meta_version) @@ -98,6 +99,12 @@ def run_kiwix_build(target, platform, def create_app_image(): if make_release: postfix = main_project_versions['kiwix-desktop'] + extra_postfix = release_versions.get('kiwix-desktop') + if extra_postfix is None: + # We should not make archives for release not wanted + return + if extra_postfix: + postfix = "{}-{}".format(postfix, extra_postfix) archive_dir = RELEASE_KIWIX_ARCHIVES_DIR/'kiwix-desktop' src_dir = SOURCE_DIR/'kiwix-desktop_release' else: @@ -126,6 +133,12 @@ def make_archive(project, platform): if make_release: postfix = main_project_versions[project] + extra_postfix = release_versions.get(project) + if extra_postfix is None: + # We should not make archives for release not wanted + return + if extra_postfix: + postfix = "{}-{}".format(postfix, extra_postfix) if project in ('kiwix-lib', 'kiwix-tools'): archive_dir = RELEASE_KIWIX_ARCHIVES_DIR/project else: @@ -322,7 +335,7 @@ for target in TARGETS: make_release=make_release) if target == 'kiwix-desktop': create_app_image() - if make_release and PLATFORM == 'native_dyn': + if make_release and PLATFORM == 'native_dyn' and release_versions.get(target) == 0: run_kiwix_build(target, platform=PLATFORM, make_release=True, @@ -332,6 +345,9 @@ for target in TARGETS: # We have build everything. Now create archives for public deployement. if make_release and PLATFORM == 'native_dyn': for target in TARGETS: + if release_versions.get(target) != 0: + # Do not release project not in release_versions + continue if target in ('kiwix-lib', 'kiwix-tools', 'kiwix-desktop'): out_dir = DIST_KIWIX_ARCHIVES_DIR else: @@ -346,7 +362,8 @@ if make_release and PLATFORM == 'native_dyn': in_file = BASE_DIR/target/'meson-dist'/'{}-{}.tar.xz'.format( target, main_project_versions[target]) - shutil.copy(str(in_file), str(out_dir/target)) + if in_file.exists(): + shutil.copy(str(in_file), str(out_dir/target)) elif PLATFORM == 'native_static': for target in ('kiwix-tools', 'zim-tools', 'zimwriterfs'): make_archive(target, 'linux-x86_64')