feat: standardize author profiles & add devcontainer

This commit is contained in:
George Cushen committed 2025-12-07 01:50:48 +00:00
1 parent 75234c306b
commit f0eb4a7e9c
80 files changed
+1327 -1019

No files matched your search

+35 -23
View File
@@ -9,7 +9,7 @@ Features:
- Updates special module metadata (blox-tailwind data/hugoblox.yaml version)
- Updates dependent modules' go.mod "require" versions when a dependency is released
- Tags changed modules with annotated tags and pushes tags
- Updates templates' go.mod to latest released module versions and bumps Hugo version in CI/Netlify config
- Updates templates' go.mod to latest released module versions and bumps Hugo version in template configs (hugoblox.yaml, Netlify, devcontainer)
Usage examples:
poetry run python scripts/release_modules.py --dry-run --log-level INFO
@@ -113,6 +113,36 @@ def update_go_mod_require_pseudo_version(go_mod_text: str, dep_module_path: str,
return re.sub(pattern_line, replacement_line, go_mod_text)
def update_devcontainer_hugo(starter_dir: Path, latest_hugo: Optional[str], updated_paths: List[Path]) -> None:
"""Update devcontainer Hugo feature version if present."""
if not latest_hugo:
return
devcontainer = starter_dir / ".devcontainer" / "devcontainer.json"
if not devcontainer.exists():
return
try:
data = json.loads(devcontainer.read_text(encoding="utf-8"))
except Exception as exc: # pragma: no cover - defensive
logging.warning("starter %s: failed to parse devcontainer.json (%s)", starter_dir.name, exc)
return
features = data.get("features", {})
hugo_feature = features.get("ghcr.io/devcontainers/features/hugo:1")
if not isinstance(hugo_feature, dict):
return
current = hugo_feature.get("version")
if current == latest_hugo:
return
hugo_feature["version"] = latest_hugo
features["ghcr.io/devcontainers/features/hugo:1"] = hugo_feature
data["features"] = features
devcontainer.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
updated_paths.append(devcontainer)
logging.info("starter %s: devcontainer Hugo version -> %s", starter_dir.name, latest_hugo)
@dataclass
class Module:
name: str # e.g., blox-tailwind
@@ -512,17 +542,8 @@ def update_starters(modules: Dict[str, Module], commit: bool, push: bool) -> Non
updated_paths.append(netlify)
logging.info("starter %s: netlify.toml HUGO_VERSION -> %s", starter_dir.name, latest_hugo)
# bump deploy.yml env WC_HUGO_VERSION
workflow = starter_dir / ".github" / "workflows" / "deploy.yml"
if latest_hugo and workflow.exists():
with workflow.open("r", encoding="utf-8") as f:
wf = yaml.load(f) or {}
if "env" in wf and wf["env"].get("WC_HUGO_VERSION") != latest_hugo:
wf["env"]["WC_HUGO_VERSION"] = latest_hugo
with workflow.open("w", encoding="utf-8") as f:
yaml.dump(wf, f)
updated_paths.append(workflow)
logging.info("starter %s: deploy.yml WC_HUGO_VERSION -> %s", starter_dir.name, latest_hugo)
# bump devcontainer Hugo version (new location for Hugo pin)
update_devcontainer_hugo(starter_dir, latest_hugo, updated_paths)
if updated_paths:
stage_and_maybe_commit(updated_paths, "chore(templates): bump modules and Hugo", commit, push)
@@ -591,17 +612,8 @@ def update_starters_to_commits(modules: Dict[str, Module], commit: bool, push: b
updated_paths.append(netlify)
logging.info("starter %s: netlify.toml HUGO_VERSION -> %s", starter_dir.name, latest_hugo)
# bump deploy.yml env WC_HUGO_VERSION (same as regular update_starters)
workflow = starter_dir / ".github" / "workflows" / "deploy.yml"
if latest_hugo and workflow.exists():
with workflow.open("r", encoding="utf-8") as f:
wf = yaml.load(f) or {}
if "env" in wf and wf["env"].get("WC_HUGO_VERSION") != latest_hugo:
wf["env"]["WC_HUGO_VERSION"] = latest_hugo
with workflow.open("w", encoding="utf-8") as f:
yaml.dump(wf, f)
updated_paths.append(workflow)
logging.info("starter %s: deploy.yml WC_HUGO_VERSION -> %s", starter_dir.name, latest_hugo)
# bump devcontainer Hugo version (same as regular update_starters)
update_devcontainer_hugo(starter_dir, latest_hugo, updated_paths)
if updated_paths:
stage_and_maybe_commit(updated_paths, "chore(templates): update modules to latest commits", commit, push)
+92
View File
@@ -0,0 +1,92 @@
#!/usr/bin/env python3
import argparse
import re
import json
import sys
from pathlib import Path
def update_file_regex(path, pattern, replacement):
file_path = Path(path)
if not file_path.exists():
print(f"Warning: {path} not found.")
return False
content = file_path.read_text()
if re.search(pattern, content):
new_content = re.sub(pattern, replacement, content)
file_path.write_text(new_content)
print(f"Updated {path}")
return True
else:
print(f"Warning: Pattern not found in {path}")
return False
def update_devcontainer(path, new_version):
file_path = Path(path)
if not file_path.exists():
print(f"Warning: {path} not found.")
return False
try:
content = json.loads(file_path.read_text())
# Update Hugo feature version
features = content.get("features", {})
hugo_feature = features.get("ghcr.io/devcontainers/features/hugo:1")
if hugo_feature:
hugo_feature["version"] = new_version
file_path.write_text(json.dumps(content, indent=2) + "\n") # standard json formatting
print(f"Updated {path}")
return True
else:
print(f"Warning: Hugo feature not found in {path}")
return False
except Exception as e:
print(f"Error updating {path}: {e}")
return False
def main():
parser = argparse.ArgumentParser(description="Update Hugo version in template files")
parser.add_argument("version", help="New Hugo version (e.g., 0.152.2)")
args = parser.parse_args()
version = args.version
# List of templates to update
templates = [
"academic-cv",
"blog",
"documentation",
"landing-page",
"link-in-bio",
"resume"
]
for template in templates:
print(f"\nProcessing template: {template}")
template_dir = Path(f"templates/{template}")
# 1. Update hugoblox.yaml
update_file_regex(
template_dir / "hugoblox.yaml",
r"hugo_version: .*",
f"hugo_version: '{version}'"
)
# 2. Update netlify.toml
update_file_regex(
template_dir / "netlify.toml",
r'HUGO_VERSION = ".*"',
f'HUGO_VERSION = "{version}"'
)
# 3. Update devcontainer.json
update_devcontainer(
template_dir / ".devcontainer/devcontainer.json",
version
)
print(f"\nSuccessfully updated all templates to Hugo v{version}")
print("Note: .github/workflows/deploy.yml is configured to read the version dynamically from hugoblox.yaml.")
if __name__ == "__main__":
main()