Fixed release process

This commit is contained in:
EivindH06
2025-10-07 09:13:19 +02:00
parent 9d2835b439
commit 5991653708
2 changed files with 66 additions and 13 deletions

Binary file not shown.

View File

@@ -25,7 +25,7 @@ import json
import os
from pathlib import Path
from datetime import datetime, timezone
from typing import Dict, Iterable, Optional
from typing import Dict, Iterable, List, Optional
DEFAULT_CHANNEL = "stable"
DEFAULT_OUTPUT = Path("dist")
@@ -167,19 +167,71 @@ def package_environment(
}
def write_index(output_dir: Path, summary: Iterable[Dict[str, str]], published_at: str, version: str) -> None:
def write_index(output_dir: Path, summary: Iterable[Dict[str, str]], published_at: str, version: str) -> List[Dict[str, str]]:
summary_list = [item for item in summary if item]
if not summary_list:
return
if summary_list:
index_path = output_dir / "firmware" / "index.json"
index_path.parent.mkdir(parents=True, exist_ok=True)
index = {
"generated_at": published_at,
"version": version,
"artifacts": summary_list,
}
index_path.write_text(json.dumps(index, indent=2))
return summary_list
index_path = output_dir / "firmware" / "index.json"
index_path.parent.mkdir(parents=True, exist_ok=True)
index = {
"generated_at": published_at,
"version": version,
"artifacts": summary_list,
}
index_path.write_text(json.dumps(index, indent=2))
def write_root_index(output_dir: Path, artifacts: List[Dict[str, str]], channel: str, version: str, published_at: str) -> None:
index_path = output_dir / "index.html"
rows = []
for artifact in artifacts:
manifest_href = artifact.get("manifest")
binary_href = artifact.get("binary")
zip_href = artifact.get("zip")
chip = artifact.get("chip", "?")
env = artifact.get("env", "?")
row = f"<tr><td>{chip}</td><td>{env}</td><td><a href='{manifest_href}'>manifest</a></td>"
if binary_href:
row += f"<td><a href='{binary_href}'>binary</a></td>"
else:
row += "<td>n/a</td>"
if zip_href:
row += f"<td><a href='{zip_href}'>zip</a></td>"
else:
row += "<td>n/a</td>"
row += "</tr>"
rows.append(row)
table_rows = "\n".join(rows) if rows else "<tr><td colspan='5'>No firmware artifacts generated.</td></tr>"
html = f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Firmware packages {version}</title>
<style>
body {{ font-family: system-ui, sans-serif; margin: 2rem; }}
table {{ border-collapse: collapse; min-width: 60%; }}
th, td {{ border: 1px solid #ccc; padding: 0.5rem 0.75rem; text-align: left; }}
th {{ background: #f5f5f5; }}
</style>
</head>
<body>
<h1>Firmware packages ({version})</h1>
<p>Channel: <strong>{channel}</strong> &middot; Published at: <strong>{published_at}</strong></p>
<p>The table below lists all firmware bundles generated by the release workflow. Devices should download the manifest matching their chip.</p>
<table>
<thead>
<tr><th>Chip</th><th>Environment</th><th>Manifest</th><th>Binary</th><th>Zip</th></tr>
</thead>
<tbody>
{table_rows}
</tbody>
</table>
</body>
</html>
"""
index_path.write_text(html)
def main() -> None:
@@ -212,7 +264,8 @@ def main() -> None:
if summary:
summaries.append(summary)
write_index(args.output, summaries, published_at, version)
artifacts = write_index(args.output, summaries, published_at, version)
write_root_index(args.output, artifacts, args.channel, version, published_at)
if __name__ == "__main__":