From 1da22305270c6d1352ee079d21af5412f64624db Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 18 Jun 2025 15:23:55 -0500 Subject: [PATCH 1/2] use release_updater for actions test build. remove dist before building, print hashes and output message for both cases. --- .github/workflows/build.yml | 2 +- build.py | 6 +++++- release_updater.py | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb2f16c..420126e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,4 +30,4 @@ jobs: - name: Build assets shell: bash run: | - python build.py + python release_updater.py diff --git a/build.py b/build.py index bcfba0b..9f81863 100644 --- a/build.py +++ b/build.py @@ -151,7 +151,11 @@ def main(): src_dir = root_dir / "src" learn_projects_dir = root_dir / "learn-projects" output_dir = root_dir / "dist" - + + # delete output dir if it exists + if output_dir.exists(): + shutil.rmtree(output_dir) + # Create output directory output_dir.mkdir(parents=True, exist_ok=True) diff --git a/release_updater.py b/release_updater.py index b801efa..d128081 100644 --- a/release_updater.py +++ b/release_updater.py @@ -26,6 +26,10 @@ def get_file_sha256(file_path): return "File not found." return sha256_hash.hexdigest() +def print_hashes(hash_dict): + for filename in sorted(hash_dict.keys()): + print(f"{filename}: {hash_dict[filename]}") + def is_release_required(): """ @@ -64,10 +68,18 @@ def is_release_required(): for dist_file in Path("dist").iterdir(): dist_file_hashes[dist_file.name] = get_file_sha256(dist_file) + print("Downloaded file hashes:") + print_hashes(downloaded_file_hashes) + + print("Dist file hashes:") + print_hashes(dist_file_hashes) + # compare hashes if dist_file_hashes != downloaded_file_hashes: print("Zip hashes differ, a release is required.") return True + + print("Zip hashes match, no release required.") return False From df7f64f05987a7c68349fff6b3b8476ccd453b8c Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 18 Jun 2025 16:04:25 -0500 Subject: [PATCH 2/2] hardcode modified time inside zip --- build.py | 4 ++++ src/__init__.py | 0 2 files changed, 4 insertions(+) create mode 100644 src/__init__.py diff --git a/build.py b/build.py index 9f81863..9d11140 100644 --- a/build.py +++ b/build.py @@ -1,3 +1,4 @@ +from datetime import datetime import os import time import zipfile @@ -118,6 +119,9 @@ def create_font_specific_zip(font_path: Path, src_dir: Path, learn_projects_dir: with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zf: for file_path in temp_dir.rglob("*"): if file_path.is_file(): + modification_time = datetime(2000, 1, 1, 0, 0, 0) + modification_timestamp = modification_time.timestamp() + os.utime(file_path, (modification_timestamp, modification_timestamp)) arcname = file_path.relative_to(temp_dir) zf.write(file_path, arcname) diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29