Skip to content

Commit

Permalink
Output project name and version (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Jul 4, 2024
1 parent 153c014 commit 0ebedcd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ This action is used by the [ESPHome publish workflow](https://github.com/esphome

## Outputs

| Name | Description |
| --------------- | --------------------------------------------------------------------------------- |
| `name` | The name of the device in yaml with the platform (eg. ESP32 or ESP8266) appended. |
| `version` | The ESPHome version used during build. |
| `original_name` | The original name of the device in yaml. |
| Name | Description |
| ----------------- | --------------------------------------------------------------------------------- |
| `name` | The name of the device in yaml with the platform (eg. ESP32 or ESP8266) appended. |
| `version` | The ESPHome version used during build. |
| `original-name` | The original name of the device in yaml. |
| `project-name` | The name of the project in yaml. `esphome.project.name` |
| `project-version` | The version of the project in yaml. `esphome.project.version` |

## Output files

Expand Down
11 changes: 10 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@ outputs:
description: ESPHome version
value: ${{ steps.build-step.outputs.esphome-version }}
original_name:
description: "Original name of device extracted from configuration (DEPRECATED: Use `original-name` instead)"
value: ${{ steps.build-step.outputs.original-name }}
original-name:
description: Original name of device extracted from configuration
value: ${{ steps.build-step.outputs.original_name }}
value: ${{ steps.build-step.outputs.original-name }}
project-name:
description: Project name extracted from configuration
value: ${{ steps.build-step.outputs.project-name }}
project-version:
description: Project version extracted from configuration
value: ${{ steps.build-step.outputs.project-version }}

runs:
using: composite
Expand Down
14 changes: 12 additions & 2 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class Config:
platform: str
original_name: str

raw_config: dict | None = None

def dest_factory_bin(self, file_base: Path) -> Path:
"""Get the destination factory binary path."""
if self.platform == "rp2040":
Expand Down Expand Up @@ -116,7 +118,7 @@ def get_config(filename: Path, outputs_file: str | None) -> tuple[Config | None,

if outputs_file:
with open(outputs_file, "a", encoding="utf-8") as output:
print(f"original_name={original_name}", file=output)
print(f"original-name={original_name}", file=output)

platform = ""
if "esp32" in config:
Expand All @@ -131,8 +133,16 @@ def get_config(filename: Path, outputs_file: str | None) -> tuple[Config | None,
if outputs_file:
with open(outputs_file, "a", encoding="utf-8") as output:
print(f"name={name}", file=output)

if project_config := config["esphome"].get("project"):
if outputs_file:
with open(outputs_file, "a", encoding="utf-8") as output:
print(f"project-name={project_config['name']}", file=output)
print(f"project-version={project_config['version']}", file=output)
print("::endgroup::")
return Config(name=name, platform=platform, original_name=original_name), 0
return Config(
name=name, platform=platform, original_name=original_name, raw_config=config
), 0


def get_idedata(filename: Path) -> tuple[dict | None, int]:
Expand Down
3 changes: 3 additions & 0 deletions tests/test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
esphome:
name: test
project:
name: esphome.example-project
version: "3.5.0"

esp32:
board: esp32dev

0 comments on commit 0ebedcd

Please sign in to comment.