Merge pull request #546 from kiwix/fix_release_detection
Fix release detection
This commit is contained in:
commit
3c7c6048c9
|
@ -18,15 +18,10 @@ from common import (
|
|||
OS_NAME,
|
||||
PLATFORM_TARGET,
|
||||
DESKTOP,
|
||||
MAKE_RELEASE,
|
||||
notarize_macos_build,
|
||||
)
|
||||
|
||||
|
||||
if os.environ.get('GITHUB_EVENT_NAME') == 'schedule':
|
||||
RELEASE = False
|
||||
else:
|
||||
RELEASE = True
|
||||
|
||||
if PLATFORM_TARGET.startswith("android_") or PLATFORM_TARGET.startswith("iOS"):
|
||||
TARGETS = ("libzim", "libkiwix")
|
||||
elif PLATFORM_TARGET.startswith("native_"):
|
||||
|
@ -47,34 +42,34 @@ else:
|
|||
TARGETS = ("libzim", "zim-tools", "libkiwix", "kiwix-tools")
|
||||
|
||||
# Filter what to build if we are doing a release.
|
||||
if RELEASE:
|
||||
if MAKE_RELEASE:
|
||||
def release_filter(project):
|
||||
return release_versions.get(project) is not None
|
||||
TARGETS = tuple(filter(release_filter, TARGETS))
|
||||
|
||||
for target in TARGETS:
|
||||
run_kiwix_build(target, platform=PLATFORM_TARGET, make_release=RELEASE)
|
||||
run_kiwix_build(target, platform=PLATFORM_TARGET, make_release=MAKE_RELEASE)
|
||||
if target == "kiwix-desktop":
|
||||
archive = create_desktop_image(make_release=RELEASE)
|
||||
archive = create_desktop_image(make_release=MAKE_RELEASE)
|
||||
else:
|
||||
if PLATFORM_TARGET == "native_mixed" and OS_NAME == "osx":
|
||||
fix_macos_rpath(target)
|
||||
notarize_macos_build(target)
|
||||
archive = make_archive(target, make_release=RELEASE)
|
||||
archive = make_archive(target, make_release=MAKE_RELEASE)
|
||||
if archive:
|
||||
upload_archive(archive, target, make_release=RELEASE)
|
||||
if RELEASE and target in ("zim-tools", "kiwix-tools"):
|
||||
upload_archive(archive, target, make_release=MAKE_RELEASE)
|
||||
if MAKE_RELEASE and target in ("zim-tools", "kiwix-tools"):
|
||||
trigger_docker_publish(target)
|
||||
|
||||
# We have few more things to do for release:
|
||||
if RELEASE:
|
||||
if MAKE_RELEASE:
|
||||
# Publish source archives
|
||||
if PLATFORM_TARGET in ("native_dyn", "native_mixed") and OS_NAME != "osx":
|
||||
for target in TARGETS:
|
||||
if release_versions.get(target) != 0:
|
||||
continue
|
||||
run_kiwix_build(
|
||||
target, platform=PLATFORM_TARGET, make_release=RELEASE, make_dist=True
|
||||
target, platform=PLATFORM_TARGET, make_release=MAKE_RELEASE, make_dist=True
|
||||
)
|
||||
full_target_name = "{}-{}".format(target, main_project_versions[target])
|
||||
if target == "kiwix-desktop":
|
||||
|
@ -88,7 +83,7 @@ if RELEASE:
|
|||
/ "meson-dist"
|
||||
/ "{}.tar.xz".format(full_target_name)
|
||||
)
|
||||
upload_archive(archive, target, make_release=RELEASE)
|
||||
upload_archive(archive, target, make_release=MAKE_RELEASE)
|
||||
|
||||
# Publish flathub
|
||||
if PLATFORM_TARGET == "flatpak" and "kiwix-desktop" in TARGETS:
|
||||
|
|
|
@ -37,6 +37,7 @@ KIWIX_DESKTOP_ONLY = False
|
|||
|
||||
_ref = _environ.get("GITHUB_REF", "").split("/")[-1]
|
||||
MAKE_RELEASE = re.fullmatch(r"r_[0-9]+", _ref) is not None
|
||||
MAKE_RELEASE = MAKE_RELEASE and (_environ.get('GITHUB_EVENT_NAME') != 'schedule')
|
||||
|
||||
RELEASE_OS_NAME = "macos" if OS_NAME == "osx" else "linux"
|
||||
|
||||
|
@ -225,7 +226,7 @@ def upload(file_to_upload, host, dest_path):
|
|||
|
||||
command = [
|
||||
"scp",
|
||||
"-r",
|
||||
"-rp",
|
||||
"-P",
|
||||
port,
|
||||
"-i",
|
||||
|
@ -240,6 +241,10 @@ def upload(file_to_upload, host, dest_path):
|
|||
|
||||
|
||||
def upload_archive(archive, project, make_release):
|
||||
if not archive.exists():
|
||||
print_message("No archive {} to upload!", archive)
|
||||
return
|
||||
|
||||
if project.startswith("kiwix-") or project in ['libkiwix']:
|
||||
host = "ci@master.download.kiwix.org:30022"
|
||||
dest_path = "/data/download/"
|
||||
|
@ -252,6 +257,10 @@ def upload_archive(archive, project, make_release):
|
|||
else:
|
||||
dest_path = dest_path + "nightly/" + DATE
|
||||
|
||||
# Make the archive read only. This way, scp will preserve rights.
|
||||
# If somehow we try to upload twice the same archive, scp will fails.
|
||||
archive.chmod(0o444)
|
||||
|
||||
upload(archive, host, dest_path)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue