Skip to content

Commit

Permalink
archive creator update
Browse files Browse the repository at this point in the history
now properly makes artifacts
  • Loading branch information
NSPC911 committed Dec 13, 2024
1 parent 928b44a commit 7ca710a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ jobs:

- name: Run Archive Creator script
run: |
python archive_creator.py
python archive_creator.py --workflow
- name: Upload as artifact
- name: Upload bash artifact
uses: actions/upload-artifact@v4
with:
path: archives/
name: bash
path: archives/bash
if-no-files-found: warn
compression-level: 9

- name: Upload bat artifact
uses: actions/upload-artifact@v4
with:
name: bat
path: archives/bat
if-no-files-found: warn
compression-level: 9
21 changes: 16 additions & 5 deletions archive_creator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import zipfile, os, hashlib
import os, hashlib, argparse
from zipfile import ZipFile, ZIP_DEFLATED
from colorama import *
init(strip=False, convert=False, autoreset=True)

parser = argparse.ArgumentParser(description=None)
parser.add_argument("--workflow", action="store_true", default=False, help="Enable workflow mode")
args = parser.parse_args()

root_dir = os.path.dirname(os.path.abspath(__file__))
archives_dir = os.path.join(root_dir, 'archives')
Expand All @@ -20,7 +23,7 @@

for archive_name, files_to_include in archive_specs.items():
archive_path = os.path.join(archives_dir, archive_name)
with zipfile.ZipFile(archive_path, 'w', zipfile.ZIP_DEFLATED) as archive:
with ZipFile(archive_path, 'w', ZIP_DEFLATED) as archive:
for file in files_to_include:
archive.write(os.path.join(root_dir, file), file)

Expand All @@ -34,5 +37,13 @@
for byte_block in iter(lambda: f.read(4096), b""):
hasher.update(byte_block)
bashhash = hasher.hexdigest()
print(f"{Fore.YELLOW}SHA256{Fore.WHITE} for {Fore.BLUE}bat.zip{Fore.WHITE} is {Fore.RED}{bathash}")
print(f"{Fore.YELLOW}SHA256{Fore.WHITE} for {Fore.BLUE}bash.zip{Fore.WHITE} is {Fore.RED}{bashhash}")
print(f"{Fore.YELLOW}SHA256{Fore.WHITE} for {Fore.LIGHTBLUE_EX}bat.zip{Fore.WHITE} is {Fore.RED}{bathash}")
print(f"{Fore.YELLOW}SHA256{Fore.WHITE} for {Fore.LIGHTBLUE_EX}bash.zip{Fore.WHITE} is {Fore.RED}{bashhash}")

if args.workflow:
with ZipFile(f'{archives_dir}/bat.zip', 'r', ZIP_DEFLATED) as archive:
archive.extractall(f'{archives_dir}/bat')
os.remove(f'{archives_dir}/bat.zip')
with ZipFile(f'{archives_dir}/bash.zip', 'r', ZIP_DEFLATED) as archive:
archive.extractall(f'{archives_dir}/bash')
os.remove(f'{archives_dir}/bash.zip')

0 comments on commit 7ca710a

Please sign in to comment.