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..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) @@ -151,7 +155,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 diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29