Switch from zip to tar, fix prep
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1 +1 @@
|
|||||||
LocalMods.zip filter=lfs diff=lfs merge=lfs -text
|
LocalMods.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
|||||||
@@ -28,13 +28,12 @@ jobs:
|
|||||||
-e "ssh -i ~/.ssh/deploy_key" \
|
-e "ssh -i ~/.ssh/deploy_key" \
|
||||||
./ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/opt/barotrauma/
|
./ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/opt/barotrauma/
|
||||||
|
|
||||||
- name: Unzip LocalMods on server
|
- name: Extract LocalMods on server
|
||||||
run: |
|
run: |
|
||||||
ssh -i ~/.ssh/deploy_key \
|
ssh -i ~/.ssh/deploy_key \
|
||||||
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \
|
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \
|
||||||
"cd /opt/barotrauma && \
|
"cd /opt/barotrauma && \
|
||||||
apt-get install -y -qq unzip 2>/dev/null; \
|
[ -f LocalMods.tar.gz ] && tar -xzf LocalMods.tar.gz && rm -f LocalMods.tar.gz && echo 'LocalMods extracted' || echo 'No LocalMods.tar.gz'"
|
||||||
[ -f LocalMods.zip ] && unzip -o LocalMods.zip && rm -f LocalMods.zip && echo 'LocalMods extracted' || echo 'No LocalMods.zip'"
|
|
||||||
|
|
||||||
- name: Restart server
|
- name: Restart server
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
3
LocalMods.tar.gz
Normal file
3
LocalMods.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:f17f7bab21a55065f6bd0a7df69caba7af69bd5dcff90508aad798c425ad5280
|
||||||
|
size 965179803
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:2dd15e8e70921976b33e76c085c9062ac0280c939218c353f8ffa4511b5b5570
|
|
||||||
size 969188423
|
|
||||||
63
prep
Normal file → Executable file
63
prep
Normal file → Executable file
@@ -1,16 +1,15 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Prepare local mods, zip them, generate config, and commit."""
|
"""Prepare local mods, tar them, generate config, and commit."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||||
SCRIPTS = os.path.join(BASE, "scripts")
|
|
||||||
PREPARE_LOCAL = os.path.join(BASE, "prepare_local")
|
PREPARE_LOCAL = os.path.join(BASE, "prepare_local")
|
||||||
AUTOGEN = os.path.join(SCRIPTS, "autogen_config.py")
|
AUTOGEN = os.path.join(BASE, "scripts", "autogen_config.py")
|
||||||
LOCALMODS_DIR = os.path.join(BASE, "LocalMods")
|
LOCALMODS_DIR = os.path.join(BASE, "LocalMods")
|
||||||
ZIP_PATH = os.path.join(BASE, "LocalMods.zip")
|
TAR_PATH = os.path.join(BASE, "LocalMods.tar.gz")
|
||||||
|
|
||||||
|
|
||||||
def log_ok(msg):
|
def log_ok(msg):
|
||||||
@@ -22,65 +21,37 @@ def log_info(msg):
|
|||||||
def log_err(msg):
|
def log_err(msg):
|
||||||
print(f"\033[91m✗\033[0m {msg}", file=sys.stderr)
|
print(f"\033[91m✗\033[0m {msg}", file=sys.stderr)
|
||||||
|
|
||||||
def run(cmd, cwd=None):
|
|
||||||
result = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
|
|
||||||
if result.returncode != 0:
|
|
||||||
print(result.stdout)
|
|
||||||
print(result.stderr, file=sys.stderr)
|
|
||||||
sys.exit(result.returncode)
|
|
||||||
return result.stdout.strip()
|
|
||||||
|
|
||||||
|
|
||||||
def zip_localmods():
|
|
||||||
import zipfile
|
|
||||||
log_info(f"Zipping {LOCALMODS_DIR} → {ZIP_PATH}")
|
|
||||||
|
|
||||||
if os.path.exists(ZIP_PATH):
|
|
||||||
os.remove(ZIP_PATH)
|
|
||||||
|
|
||||||
count = 0
|
|
||||||
with zipfile.ZipFile(ZIP_PATH, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
||||||
for root, dirs, files in os.walk(LOCALMODS_DIR):
|
|
||||||
for fn in files:
|
|
||||||
full = os.path.join(root, fn)
|
|
||||||
arcname = os.path.relpath(full, BASE)
|
|
||||||
zf.write(full, arcname)
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
size = os.path.getsize(ZIP_PATH)
|
|
||||||
log_ok(f"Zipped {count} files ({size / 1024:.1f} KB)")
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
msg = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "Update LocalMods"
|
msg = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "Update LocalMods"
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("╔════════════════════════════════════╗")
|
print("╔════════════════════════════════════╗")
|
||||||
print("║ Prep: mods → zip → commit ║")
|
print("║ Prep: mods → tar → commit ║")
|
||||||
print("╚════════════════════════════════════╝")
|
print("╚════════════════════════════════════╝")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# 1. Run prepare_local
|
log_info("Step 1/4: Copy mods from workshop...")
|
||||||
log_info("Step 1: Copy mods from workshop...")
|
subprocess.run([sys.executable, PREPARE_LOCAL], check=True)
|
||||||
run([sys.executable, PREPARE_LOCAL])
|
|
||||||
log_ok("LocalMods ready")
|
log_ok("LocalMods ready")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# 2. Zip LocalMods
|
log_info("Step 2/4: Taring LocalMods/...")
|
||||||
log_info("Step 2: Zipping LocalMods/...")
|
if os.path.exists(TAR_PATH):
|
||||||
zip_localmods()
|
os.remove(TAR_PATH)
|
||||||
|
subprocess.run(["tar", "-czf", TAR_PATH, "-C", BASE, "LocalMods"], check=True)
|
||||||
|
size = os.path.getsize(TAR_PATH)
|
||||||
|
log_ok(f"Created {TAR_PATH} ({size / 1024:.1f} KB)")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# 3. Run autogen_config
|
log_info("Step 3/4: Generating config_player.xml...")
|
||||||
log_info("Step 3: Generating config_player.xml...")
|
subprocess.run([sys.executable, AUTOGEN], check=True)
|
||||||
run([sys.executable, AUTOGEN])
|
|
||||||
log_ok("config_player.xml generated")
|
log_ok("config_player.xml generated")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# 4. Git add and commit (no push)
|
log_info("Step 4/4: Committing...")
|
||||||
log_info("Step 4: Committing...")
|
subprocess.run(["git", "add", "-A"], cwd=BASE, check=True)
|
||||||
run(["git", "add", "-A"], cwd=BASE)
|
subprocess.run(["git", "commit", "-m", msg], cwd=BASE, check=True)
|
||||||
run(["git", "commit", "-m", msg], cwd=BASE)
|
|
||||||
log_ok(f"Committed: {msg}")
|
log_ok(f"Committed: {msg}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|||||||
32
unpack
Normal file → Executable file
32
unpack
Normal file → Executable file
@@ -1,13 +1,12 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Unpack LocalMods.zip into LocalMods/ and remove the archive."""
|
"""Unpack LocalMods.tar.gz into LocalMods/ and remove the archive."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import zipfile
|
|
||||||
|
|
||||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||||
ZIP_PATH = os.path.join(BASE, "LocalMods.zip")
|
TAR_PATH = os.path.join(BASE, "LocalMods.tar.gz")
|
||||||
LOCALMODS_DIR = os.path.join(BASE, "LocalMods")
|
|
||||||
|
|
||||||
|
|
||||||
def log_ok(msg):
|
def log_ok(msg):
|
||||||
@@ -16,9 +15,6 @@ def log_ok(msg):
|
|||||||
def log_info(msg):
|
def log_info(msg):
|
||||||
print(f"• {msg}")
|
print(f"• {msg}")
|
||||||
|
|
||||||
def log_warn(msg):
|
|
||||||
print(f"\033[93m⚠\033[0m {msg}")
|
|
||||||
|
|
||||||
def log_err(msg):
|
def log_err(msg):
|
||||||
print(f"\033[91m✗\033[0m {msg}", file=sys.stderr)
|
print(f"\033[91m✗\033[0m {msg}", file=sys.stderr)
|
||||||
|
|
||||||
@@ -26,23 +22,17 @@ def log_err(msg):
|
|||||||
def main():
|
def main():
|
||||||
print()
|
print()
|
||||||
|
|
||||||
if not os.path.isfile(ZIP_PATH):
|
if not os.path.isfile(TAR_PATH):
|
||||||
log_err(f"Not found: {ZIP_PATH}")
|
log_err(f"Not found: {TAR_PATH}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
log_info(f"Unzipping: {ZIP_PATH}")
|
log_info(f"Extracting: {TAR_PATH}")
|
||||||
with zipfile.ZipFile(ZIP_PATH, "r") as zf:
|
subprocess.run(["tar", "-xzf", TAR_PATH, "-C", BASE], check=True)
|
||||||
zf.extractall(BASE)
|
|
||||||
|
|
||||||
size = os.path.getsize(ZIP_PATH)
|
size = os.path.getsize(TAR_PATH)
|
||||||
file_count = 0
|
os.remove(TAR_PATH)
|
||||||
for root, dirs, files in os.walk(LOCALMODS_DIR):
|
log_ok(f"Extracted to {os.path.join(BASE, 'LocalMods')}/")
|
||||||
file_count += len(files)
|
log_ok(f"Removed archive ({size / 1024:.1f} KB freed)")
|
||||||
|
|
||||||
log_ok(f"Extracted {file_count} files to {LOCALMODS_DIR}/")
|
|
||||||
|
|
||||||
os.remove(ZIP_PATH)
|
|
||||||
log_ok(f"Removed: {ZIP_PATH} ({size / 1024:.1f} KB freed)")
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user