mirror of
https://github.com/esphome/esphome.git
synced 2026-06-02 03:02:19 +08:00
[ci] Support URL and version extras in generate-esp32-boards.py (#14828)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
@@ -7,17 +7,26 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from esphome import config_validation as cv
|
||||||
from esphome.components.esp32 import PLATFORM_VERSION_LOOKUP
|
from esphome.components.esp32 import PLATFORM_VERSION_LOOKUP
|
||||||
from esphome.helpers import write_file_if_changed
|
from esphome.helpers import write_file_if_changed
|
||||||
|
|
||||||
ver = PLATFORM_VERSION_LOOKUP["recommended"]
|
ver = PLATFORM_VERSION_LOOKUP["recommended"]
|
||||||
version_str = f"{ver.major}.{ver.minor:02d}.{ver.patch:02d}"
|
|
||||||
root = Path(__file__).parent.parent
|
root = Path(__file__).parent.parent
|
||||||
boards_file_path = root / "esphome" / "components" / "esp32" / "boards.py"
|
boards_file_path = root / "esphome" / "components" / "esp32" / "boards.py"
|
||||||
|
|
||||||
|
|
||||||
def get_boards():
|
def get_boards():
|
||||||
with tempfile.TemporaryDirectory() as tempdir:
|
with tempfile.TemporaryDirectory() as tempdir:
|
||||||
|
if isinstance(ver, cv.Version):
|
||||||
|
branch = f"{ver.major}.{ver.minor:02d}.{ver.patch:02d}"
|
||||||
|
if ver.extra:
|
||||||
|
branch += f"-{ver.extra}"
|
||||||
|
repo = "https://github.com/pioarduino/platform-espressif32"
|
||||||
|
else:
|
||||||
|
# URL format: "https://github.com/user/repo.git#branch"
|
||||||
|
url = str(ver)
|
||||||
|
repo, branch = url.rsplit("#", 1) if "#" in url else (url, "main")
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
"git",
|
"git",
|
||||||
@@ -28,8 +37,8 @@ def get_boards():
|
|||||||
"--depth",
|
"--depth",
|
||||||
"1",
|
"1",
|
||||||
"--branch",
|
"--branch",
|
||||||
f"{ver.major}.{ver.minor:02d}.{ver.patch:02d}",
|
branch,
|
||||||
"https://github.com/pioarduino/platform-espressif32",
|
repo,
|
||||||
tempdir,
|
tempdir,
|
||||||
],
|
],
|
||||||
check=True,
|
check=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user