diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e4266f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +*.py[cod] +*$py.class diff --git a/esphome-dev/build.json b/esphome-dev/build.json index 929a2bd..73d35c1 100644 --- a/esphome-dev/build.json +++ b/esphome-dev/build.json @@ -1,10 +1,9 @@ { "args": {}, "build_from": { - "aarch64": "esphome/esphome-hassio-base-aarch64:2.3.3", - "amd64": "esphome/esphome-hassio-base-amd64:2.3.3", - "armv7": "esphome/esphome-hassio-base-armv7:2.3.3", - "i386": "esphome/esphome-hassio-base-i386:2.3.3" + "aarch64": "esphome/esphome-hassio-base-aarch64:2.3.4", + "amd64": "esphome/esphome-hassio-base-amd64:2.3.4", + "armv7": "esphome/esphome-hassio-base-armv7:2.3.4" }, "squash": false } \ No newline at end of file diff --git a/esphome-dev/config.json b/esphome-dev/config.json index 69c0515..2db67d9 100644 --- a/esphome-dev/config.json +++ b/esphome-dev/config.json @@ -1,7 +1,6 @@ { "arch": [ "amd64", - "i386", "armv7", "aarch64" ], @@ -28,7 +27,7 @@ "6052/tcp": null }, "ports_description": { - "6052/tcp": "Web interface (Not required for Hass.io Ingress)" + "6052/tcp": "Web interface (Not required for Home Assistant Ingress)" }, "schema": { "certfile": "str?", @@ -41,6 +40,7 @@ "streamer_mode": "bool?" }, "slug": "esphome-dev", + "stage": "experimental", "startup": "application", "url": "https://next.esphome.io/", "version": "dev", diff --git a/script/bump-version.py b/script/bump-version.py index 2f05c2e..cc0e357 100755 --- a/script/bump-version.py +++ b/script/bump-version.py @@ -5,6 +5,10 @@ import re import subprocess from dataclasses import dataclass import sys +import os + +sys.path.append(os.path.dirname(__file__)) +import generate @dataclass @@ -65,29 +69,20 @@ def write_version(target: str, version: Version): def main(): parser = argparse.ArgumentParser() parser.add_argument('new_version', type=str) - parser.add_argument('--beta', action='store_true', help="Update the beta addon") - parser.add_argument('--stable', action='store_true', help="Update the stable addon") - parser.add_argument('--commit', action='store_true') args = parser.parse_args() - if not any([args.beta, args.stable]): - print("At least one of beta or stable has to be bumped") - return 1 - - if args.commit and subprocess.call(["git", "diff", "--quiet"]) == 1: - print("Cannot use --commit because git is dirty.") - return 1 - version = Version.parse(args.new_version) + assert not version.dev + print(f"Bumping to {version}") - if args.beta: + if version.beta: write_version('beta', version) - if args.stable: + generate.main(['beta']) + else: assert not version.beta write_version('stable', version) - - if args.commit: - subprocess.check_call(["git", "commit", "-nam", f"Bump version to v{version}"]) + write_version('beta', version) + generate.main(['stable', 'beta']) return 0 diff --git a/script/generate.py b/script/generate.py index aea7a68..fd4400e 100755 --- a/script/generate.py +++ b/script/generate.py @@ -6,43 +6,50 @@ from pathlib import Path from enum import Enum import json from shutil import copyfile +import sys class Channel(Enum): stable = 'stable' beta = 'beta' dev = 'dev' -parser = argparse.ArgumentParser(description='Generate ESPHome Home Assistant config.json') -parser.add_argument('channels', nargs='+', type=Channel, choices=list(Channel)) -args = parser.parse_args() -root = Path(__file__).parent.parent -templ = root / 'template' +def main(args): + parser = argparse.ArgumentParser(description='Generate ESPHome Home Assistant config.json') + parser.add_argument('channels', nargs='+', type=Channel, choices=list(Channel)) + args = parser.parse_args(args) -with open(templ / "config.yaml", 'r') as f: - config = yaml.safe_load(f) + root = Path(__file__).parent.parent + templ = root / 'template' -copyf = config['copy_files'] + with open(templ / "config.yaml", 'r') as f: + config = yaml.safe_load(f) -for channel in args.channels: - conf = config[f'esphome-{channel.value}'] - base_image = conf.pop('base_image') - dir_ = root / conf.pop('directory') - path = dir_ / 'config.json' - with open(path, 'w') as f: - json.dump(conf, f, indent=2, sort_keys=True) + copyf = config['copy_files'] - for file_, conf_ in copyf.items(): - copyfile(templ / file_, dir_ / file_) - - if channel == Channel.dev: - path = dir_ / 'build.json' - build_conf = { - 'squash': False, - "build_from": {arch: base_image.format(arch=arch) for arch in conf['arch']}, - "args": {} - } + for channel in args.channels: + conf = config[f'esphome-{channel.value}'] + base_image = conf.pop('base_image') + dir_ = root / conf.pop('directory') + path = dir_ / 'config.json' with open(path, 'w') as f: - json.dump(build_conf, f, indent=2, sort_keys=True) + json.dump(conf, f, indent=2, sort_keys=True) - print(f"Wrote {path}") + for file_, conf_ in copyf.items(): + copyfile(templ / file_, dir_ / file_) + + if channel == Channel.dev: + path = dir_ / 'build.json' + build_conf = { + 'squash': False, + "build_from": {arch: base_image.format(arch=arch) for arch in conf['arch']}, + "args": {} + } + with open(path, 'w') as f: + json.dump(build_conf, f, indent=2, sort_keys=True) + + print(f"Wrote {path}") + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/template/config.yaml b/template/config.yaml index 5ad3d5b..bd20d6f 100644 --- a/template/config.yaml +++ b/template/config.yaml @@ -6,7 +6,6 @@ base: &base boot: auto arch: - amd64 - - i386 - armv7 - aarch64 # Uses Hass.io API (auth) @@ -26,7 +25,7 @@ base: &base ports: '6052/tcp': null ports_description: - '6052/tcp': "Web interface (Not required for Hass.io Ingress)" + '6052/tcp': "Web interface (Not required for Home Assistant Ingress)" map: - ssl:ro - config:rw @@ -39,7 +38,7 @@ base: &base streamer_mode: bool? relative_url: str? status_use_ping: bool? - base_image: esphome/esphome-hassio-base-{arch}:2.3.3 + base_image: esphome/esphome-hassio-base-{arch}:2.3.4 esphome-dev: <<: *base @@ -49,6 +48,7 @@ esphome-dev: slug: esphome-dev description: "Development Version! Manage and program ESP8266/ESP32 microcontrollers through YAML configuration files" url: https://next.esphome.io/ + stage: experimental options: esphome_version: dev @@ -61,6 +61,7 @@ esphome-beta: description: "Beta version of ESPHome Hass.io add-on." url: https://beta.esphome.io/ image: esphome/esphome-hassio-{arch} + stage: experimental options: {} esphome-stable: @@ -71,6 +72,7 @@ esphome-stable: slug: esphome description: "ESPHome Hass.io add-on for intelligently managing all your ESP8266/ESP32 devices." image: esphome/esphome-hassio-{arch} + stage: stable options: {} copy_files: