Skip to content

Commit

Permalink
Merge pull request #8 from aiden2480/auto-publish
Browse files Browse the repository at this point in the history
Use regex to sort files to be zipped
  • Loading branch information
aiden2480 authored Sep 6, 2021
2 parents bf99020 + 76fcf7d commit 62b48da
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/webstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import io
import os
import re
import time
import json
import zipfile
Expand Down Expand Up @@ -91,18 +92,16 @@ def generate_zipfile() -> io.BytesIO:
chrome webstore. The zipped file is stored in memory, in a BytesIO object
"""

buffer = io.BytesIO()
zipped = zipfile.ZipFile(buffer, "w")
skipfils = [".git\\", ".github\\", ".gitignore", "README.md"]
print("\nGenerating zip file")
zipped = zipfile.ZipFile(buffer := io.BytesIO(), "w")
pattern = re.compile(r".\\(.git\\|.github\\|.gitignore|README.md)")

for root, dirs, files in os.walk("."):
for name in files:
concat = os.path.join(root, name)

# TODO Find a better way to compare
if list(filter(lambda i: concat.startswith(".\\" + i), skipfils)):
continue
if re.match(pattern, concat):
continue # Skip certain files and dirs

print("* zipping", concat)
zipped.write(concat)
Expand Down

0 comments on commit 62b48da

Please sign in to comment.