Skip to content

Commit

Permalink
If LICENSE is missing from the plugin path but available in the paren…
Browse files Browse the repository at this point in the history
…t path when packaging, include that
  • Loading branch information
nirvn committed Aug 1, 2024
1 parent b8c8bbd commit 13c6247
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions qgispluginci/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import re
import shutil
import sys
import tarfile
import xmlrpc.client
Expand Down Expand Up @@ -193,6 +194,16 @@ def create_archive(
continue
tt.add(m.name)

# add LICENSE if not already in plugin path but available in its parent
parent_folder_license_copied = False
if not Path(f"{parameters.plugin_path}/LICENSE").is_file():
parent_license = Path(f"{parameters.plugin_path}/../LICENSE")
if parent_license.is_file():
shutil.copy(str(parent_license.resolve()), f"{parameters.plugin_path}/LICENSE")
parent_folder_license_copied = True
with tarfile.open(top_tar_file, mode="a") as tt:
tt.add(f"{parameters.plugin_path}/LICENSE")

# add translation files
if add_translations:
with tarfile.open(top_tar_file, mode="a") as tt:
Expand Down Expand Up @@ -265,6 +276,9 @@ def create_archive(
info.compress_type = zf.compression
zf.writestr(info, fl)

if parent_folder_license_copied:
os.remove(f"{parameters.plugin_path}/LICENSE")

logger.debug("-" * 40)
logger.debug(f"Files in ZIP archive ({archive_name}):")
with zipfile.ZipFile(file=archive_name, mode="r") as zf:
Expand Down

0 comments on commit 13c6247

Please sign in to comment.