diff --git a/scripts/publish.py b/scripts/publish.py index 3413f44..f61b940 100755 --- a/scripts/publish.py +++ b/scripts/publish.py @@ -8,6 +8,7 @@ import re from typing import Set, Dict import logging from datetime import datetime +from dotenv import load_dotenv # Configure logging logging.basicConfig( @@ -21,11 +22,21 @@ logging.basicConfig( def load_env_vars() -> tuple[Path, Path]: """Load environment variables and return source and destination directories.""" + # Load .env file from the same directory as the script + script_dir = Path(__file__).parent.parent + env_path = script_dir / '.env' + + if not env_path.exists(): + logging.error(f".env file not found at {env_path}") + sys.exit(1) + + load_dotenv(env_path) + source_dir = os.getenv('SOURCE_DIR') dest_dir = os.getenv('DEST_DIR') if not source_dir or not dest_dir: - logging.error("SOURCE_DIR and DEST_DIR must be set in environment variables") + logging.error("SOURCE_DIR and DEST_DIR must be set in .env file") sys.exit(1) # Expand environment variables like $HOME