Merge pull request #13 from FoamyGuy/release_updater
Some checks failed
GitHub Release Actions / validate-build (push) Has been cancelled
Some checks failed
GitHub Release Actions / validate-build (push) Has been cancelled
working on release updater
This commit is contained in:
commit
d80e33d35b
4 changed files with 22 additions and 2 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -30,4 +30,4 @@ jobs:
|
|||
- name: Build assets
|
||||
shell: bash
|
||||
run: |
|
||||
python build.py
|
||||
python release_updater.py
|
||||
|
|
|
|||
8
build.py
8
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)
|
||||
|
||||
|
|
@ -152,6 +156,10 @@ def main():
|
|||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
Loading…
Reference in a new issue