Extend the build definition with P(ublish) and S(ource)

This allow us to better control what we publish.
This fix #628
This commit is contained in:
Matthieu Gautier 2023-07-26 15:04:37 +02:00
parent 1876b5f542
commit 07e72ffba4
2 changed files with 59 additions and 45 deletions

View File

@ -9,50 +9,53 @@ import csv, io, re
# Lines composed of `-` , or `=`, or starting by `#` are ignored. # Lines composed of `-` , or `=`, or starting by `#` are ignored.
# 'B' letter means that the project is build in the CI # 'B' letter means that the project is build in the CI
# 'd' letter means that the project's dependencies are build and published to be used by the project's CI. # 'd' letter means that the project's dependencies are build and published to be used by the project's CI.
# If a cell contains both, both are done. # 'P' letter means that (build) project must be publish when we do a release.
# (This is used to avoid two publication of the same archive)
# 'S' letter means that source code must be publish (almost by definition, S should be put only with a P)
# If a cell contains several letters, all are done.
BUILD_DEF = """ BUILD_DEF = """
| OS_NAME | PLATFORM_TARGET | libzim | libkiwix | zim-tools | kiwix-tools | kiwix-desktop | | OS_NAME | PLATFORM_TARGET | libzim | libkiwix | zim-tools | kiwix-tools | kiwix-desktop |
============================================================================================== ==============================================================================================
# Bionic is a special case as we need to compile libzim on old arch for python # Bionic is a special case as we need to compile libzim on old arch for python
| bionic | | B | | | | | | bionic | | BP | | | | |
---------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------
# Osx builds, build binaries on native_dyn and native_static. On anyother things, build only the libraries # Osx builds, build binaries on native_dyn and native_static. On anyother things, build only the libraries
| macos | native_dyn | d | d | dB | B | | | macos | native_dyn | d | d | dB | B | |
| macos | native_static | | | B | B | | | macos | native_static | | | BP | BP | |
| macos | native_mixed | B | B | | | | | macos | native_mixed | BP | BP | | | |
| macos | iOS_arm64 | dB | B | | | | | macos | iOS_arm64 | dB | B | | | |
| macos | iOS_x86_64 | dB | B | | | | | macos | iOS_x86_64 | dB | B | | | |
| macos | iOS_Mac_ABI | B | B | | | | | macos | iOS_Mac_ABI | B | B | | | |
| macos | macOS_arm64_static | | | | | | | macos | macOS_arm64_static | | | | | |
| macos | macOS_arm64_mixed | B | B | | | | | macos | macOS_arm64_mixed | BP | BP | | | |
| macos | macOS_x86_64 | B | B | | | | | macos | macOS_x86_64 | B | B | | | |
---------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------
| | flatpak | | | | | B | | | flatpak | | | | | BP |
| | native_static | d | d | dB | dB | | | | native_static | d | d | dBPS | dBPS | |
| | native_dyn | d | d | dB | dB | B | | | native_dyn | d | d | dB | dB | BPS |
| | native_mixed | B | B | | | | | | native_mixed | BPS | BPS | | | |
# libzim CI is building alpine_dyn but not us # libzim CI is building alpine_dyn but not us
| | android_arm | dB | dB | | | | | | android_arm | dBP | dBP | | | |
| | android_arm64 | dB | dB | | | | | | android_arm64 | dBP | dBP | | | |
| | android_x86 | B | B | | | | | | android_x86 | BP | BP | | | |
| | android_x86_64 | B | B | | | | | | android_x86_64 | BP | BP | | | |
| | armv6_static | | | B | B | | | | armv6_static | | | BP | BP | |
| | armv6_dyn | | | B | B | | | | armv6_dyn | | | B | B | |
| | armv6_mixed | B | | | | | | | armv6_mixed | BP | | | | |
| | armv8_static | | | B | B | | | | armv8_static | | | BP | BP | |
| | armv8_dyn | | | B | B | | | | armv8_dyn | | | B | B | |
| | armv8_mixed | B | | | | | | | armv8_mixed | BP | | | | |
| | aarch64_static | | | B | B | | | | aarch64_static | | | BP | BP | |
| | aarch64_dyn | d | | B | B | | | | aarch64_dyn | d | | B | B | |
| | aarch64_mixed | B | | | | | | | aarch64_mixed | BP | | | | |
| | aarch64_musl_static| | | B | B | | | | aarch64_musl_static| | | BP | BP | |
| | aarch64_musl_dyn | d | | B | B | | | | aarch64_musl_dyn | d | | B | B | |
| | aarch64_musl_mixed | B | | | | | | | aarch64_musl_mixed | BP | | | | |
| | win32_static | d | dB | dB | dB | | | | win32_static | d | dB | dBP | dBP | |
| | win32_dyn | d | dB | dB | dB | | | | win32_dyn | d | dB | dB | dB | |
| | i586_static | | | B | B | | | | i586_static | | | BP | BP | |
| | i586_dyn | | | B | B | | | | i586_dyn | | | B | B | |
| | wasm | dB | | | | | | | wasm | dBP | | | | |
""" """
@ -96,6 +99,8 @@ class Context(NamedTuple):
BUILD = "B" BUILD = "B"
PUBLISH = "P"
SOURCE_PUBLISH = "S"
DEPS = "d" DEPS = "d"
def select_build_targets(criteria): def select_build_targets(criteria):

View File

@ -19,15 +19,19 @@ from common import (
notarize_macos_build, notarize_macos_build,
) )
from build_definition import select_build_targets, BUILD from build_definition import select_build_targets, BUILD, PUBLISH, SOURCE_PUBLISH
TARGETS = select_build_targets(BUILD)
# Filter what to build if we are doing a release. # Filter what to build if we are doing a release.
if MAKE_RELEASE: if MAKE_RELEASE:
TARGETS = select_build_targets(PUBLISH)
def release_filter(project): def release_filter(project):
return release_versions.get(project) is not None return release_versions.get(project) is not None
TARGETS = tuple(filter(release_filter, TARGETS)) TARGETS = tuple(filter(release_filter, TARGETS))
else:
TARGETS = select_build_targets(BUILD)
for target in TARGETS: for target in TARGETS:
run_kiwix_build(target, platform=PLATFORM_TARGET, make_release=MAKE_RELEASE) run_kiwix_build(target, platform=PLATFORM_TARGET, make_release=MAKE_RELEASE)
@ -46,26 +50,31 @@ for target in TARGETS:
# We have few more things to do for release: # We have few more things to do for release:
if MAKE_RELEASE: if MAKE_RELEASE:
# Publish source archives # Publish source archives
if PLATFORM_TARGET in ("native_dyn", "native_mixed") and OS_NAME != "macos": source_published_targets = select_build_targets(SOURCE_PUBLISH)
for target in TARGETS: for target in TARGETS:
if release_versions.get(target) != 0: # Looping on TARGETS instead of source_published_targets ensures we are
continue # publishing sources only for target we are building.
run_kiwix_build( # (source_published_targets must be a subset of TARGETS)
target, platform=PLATFORM_TARGET, make_release=MAKE_RELEASE, make_dist=True if release_versions.get(target) != 0:
continue
if target not in source_published_targets:
continue
run_kiwix_build(
target, platform=PLATFORM_TARGET, make_release=MAKE_RELEASE, make_dist=True
)
full_target_name = "{}-{}".format(target, main_project_versions[target])
if target == "kiwix-desktop":
archive = (
BASE_DIR / full_target_name / "{}.tar.gz".format(full_target_name)
) )
full_target_name = "{}-{}".format(target, main_project_versions[target]) else:
if target == "kiwix-desktop": archive = (
archive = ( BASE_DIR
BASE_DIR / full_target_name / "{}.tar.gz".format(full_target_name) / full_target_name
) / "meson-dist"
else: / "{}.tar.xz".format(full_target_name)
archive = ( )
BASE_DIR upload_archive(archive, target, make_release=MAKE_RELEASE)
/ full_target_name
/ "meson-dist"
/ "{}.tar.xz".format(full_target_name)
)
upload_archive(archive, target, make_release=MAKE_RELEASE)
# Publish flathub # Publish flathub
if PLATFORM_TARGET == "flatpak" and "kiwix-desktop" in TARGETS: if PLATFORM_TARGET == "flatpak" and "kiwix-desktop" in TARGETS: