- ci/scripts/read_meta.py legge version|build_from da config.yaml/json - ci/scripts/update_repo.py upserta repository.json - ci/scripts/lint_addon.sh hadolint + yaml/json + shellcheck - ci/scripts/git_push_repo.sh commit e push di repository.json Rimuove writeFile /tmp/ dal Jenkinsfile Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
33 lines
784 B
Python
33 lines
784 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Legge version e build_from.amd64 dalla config di un addon HA.
|
|
|
|
Uso: python3 read_meta.py <addon_dir>
|
|
Output su stdout: version|build_from_amd64
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
try:
|
|
import yaml
|
|
HAS_YAML = True
|
|
except ImportError:
|
|
HAS_YAML = False
|
|
|
|
addon = sys.argv[1]
|
|
|
|
for filename in ('config.yaml', 'config.json'):
|
|
path = os.path.join(addon, filename)
|
|
if not os.path.exists(path):
|
|
continue
|
|
with open(path) as f:
|
|
cfg = yaml.safe_load(f) if (filename.endswith('.yaml') and HAS_YAML) else json.load(f)
|
|
version = str(cfg.get('version', 'latest'))
|
|
build_from = (cfg.get('build_from') or {}).get('amd64', '')
|
|
print(f'{version}|{build_from}')
|
|
sys.exit(0)
|
|
|
|
# Nessuna config trovata
|
|
print('latest|')
|