forked from BlueOne/factorio-scenario
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.py
29 lines (22 loc) · 874 Bytes
/
release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# file: release.py
# Create a zip of the factorio mod, excluding hidden files [only in the top level currently] and python scripts.
import json
import os
import zipfile
mod_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(mod_dir)
with open('info.json') as f:
mod_info = json.load(f)
mod_name = mod_info["name"]
version = mod_info["version"]
mod_file_name = mod_name + '_' + version
with zipfile.ZipFile(os.path.join('..', mod_file_name + '.zip'), 'w', zipfile.ZIP_DEFLATED) as zipf:
for root, dirs, files in os.walk('.'):
if root[2:].startswith("."): # strip './'
continue
for file in files:
path = os.path.join(mod_file_name, root[2:], file)
if file.startswith('.') or file.endswith('.py'):
continue
zipf.write(os.path.join(root, file), path)