diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2eecd00..b0184b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,11 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +env: + TEST_RELEASE_SUMMARY: |- + Test "release" summary + * Multiple lines + jobs: build: name: Build test configuration for esphome:${{ matrix.esphome-version }} with ${{ matrix.manifest }} manifest @@ -33,22 +38,22 @@ jobs: - partial steps: - name: Checkout - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.2 - name: Run action uses: ./ id: esphome-build with: - yaml_file: tests/test.yaml + yaml-file: tests/test.yaml version: ${{ matrix.esphome-version }} platform: linux/amd64 cache: true - release_summary: "Test release summary" - release_url: "https://github.com/esphome/build-action" + release-summary: ${{ env.TEST_RELEASE_SUMMARY }} + release-url: "https://github.com/esphome/build-action" complete-manifest: ${{ matrix.manifest == 'complete' }} - name: Write version to file run: echo ${{ steps.esphome-build.outputs.version }} > ${{ steps.esphome-build.outputs.name }}/version - name: Upload ESPHome binary - uses: actions/upload-artifact@v4.3.4 + uses: actions/upload-artifact@v4.4.3 with: name: build-output-files-${{ matrix.esphome-version }}-${{ matrix.manifest }} path: ${{ steps.esphome-build.outputs.name }} @@ -69,7 +74,7 @@ jobs: - partial steps: - name: Checkout - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.2 - name: Download files uses: actions/download-artifact@v4.1.8 with: diff --git a/README.md b/README.md index 2b700d5..e7a3f4e 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ a device via [ESP Web Tools](https://esphome.github.io/esp-web-tools). ## Example usage ```yaml -uses: esphome/build-action@v1 +uses: esphome/build-action@v4.0.2 with: - yaml_file: my_configuration.yaml + yaml-file: my_configuration.yaml ``` This action is used by the [ESPHome publish workflow](https://github.com/esphome/workflows/blob/main/.github/workflows/publish.yml) that is used to compile firmware and publish simple GitHub pages sites for projects. @@ -20,12 +20,11 @@ This action is used by the [ESPHome publish workflow](https://github.com/esphome | Name | Default | Description | | ------------------- | ------------- | --------------------------------------------------------------------------------------- | -| `yaml_file` | _None_ | The YAML file to be compiled. | +| `yaml-file` | _None_ | The YAML file to be compiled. | | `version` | `latest` | The ESPHome version to build using. | | `platform` | `linux/amd64` | The docker platform to use during build. (linux/amd64, linux/arm64, linux/arm/v7) | -| `cache` | `false` | Whether to cache the build folder. | -| `release_summary` | _None_ | A small summary of the release that will be added to the manifest file. | -| `release_url` | _None_ | A URL to the release page that will be added to the manifest file. | +| `release-summary` | _None_ | A small summary of the release that will be added to the manifest file. | +| `release-url` | _None_ | A URL to the release page that will be added to the manifest file. | | `complete-manifest` | `false` | Whether to output a complete manifest file. Defaults to output a partial manifest only. | ## Outputs diff --git a/action.yml b/action.yml index 56ee8db..78def2b 100644 --- a/action.yml +++ b/action.yml @@ -2,7 +2,7 @@ name: ESPHome Builder description: Builds ESPHome binaries inputs: - yaml_file: + yaml-file: description: YAML file to use required: true version: @@ -17,11 +17,15 @@ inputs: description: Cache build directory required: false default: false - release_summary: + deprecationMessage: | + There is little to no gain in caching the build directory as + ESPHome will wipe the build artifacts in most cases for releases. + This will be removed in a future release. + release-summary: description: Release summary required: false default: "" - release_url: + release-url: description: Release URL required: false default: "" @@ -37,9 +41,6 @@ outputs: version: 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 }} @@ -56,47 +57,57 @@ runs: - name: Set up QEMU uses: docker/setup-qemu-action@v3.2.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.6.1 + uses: docker/setup-buildx-action@v3.7.1 with: platforms: ${{ inputs.platform }} - name: Build ESPHome image - uses: docker/build-push-action@v6.5.0 + uses: docker/build-push-action@v6.9.0 + env: + DOCKER_BUILD_SUMMARY: false + DOCKER_BUILD_RECORD_UPLOAD: false with: context: ${{ github.action_path }} load: true tags: esphome:${{ inputs.version }} build-args: VERSION=${{ inputs.version }} platforms: ${{ inputs.platform }} + - if: ${{ inputs.cache == 'true' }} id: data-dir shell: bash run: | - data_dir=$(dirname ${{ inputs.yaml_file }})/.esphome + data_dir=$(dirname ${{ inputs.yaml-file }})/.esphome echo "data_dir=$data_dir" >> $GITHUB_OUTPUT - if: ${{ inputs.cache == 'true' }} name: Cache platformio directory - uses: actions/cache@v4.0.2 + uses: actions/cache@v4.1.2 with: path: ~/.platformio - key: ${{ runner.os }}-esphome-${{ inputs.yaml_file }}-${{ inputs.version }}-platformio + key: ${{ runner.os }}-esphome-${{ inputs.yaml-file }}-${{ inputs.version }}-platformio - if: ${{ inputs.cache == 'true' }} name: Cache build directory - uses: actions/cache@v4.0.2 + uses: actions/cache@v4.1.2 with: path: ${{ steps.data-dir.outputs.data_dir }}/build - key: ${{ runner.os }}-esphome-${{ inputs.yaml_file }}-${{ inputs.version }}-build + key: ${{ runner.os }}-esphome-${{ inputs.yaml-file }}-${{ inputs.version }}-build save-always: true - if: ${{ inputs.cache == 'true' }} name: Cache storage directory - uses: actions/cache@v4.0.2 + uses: actions/cache@v4.1.2 with: path: ${{ steps.data-dir.outputs.data_dir }}/storage - key: ${{ runner.os }}-esphome-${{ inputs.yaml_file }}-${{ inputs.version }}-storage + key: ${{ runner.os }}-esphome-${{ inputs.yaml-file }}-${{ inputs.version }}-storage save-always: true + - name: Run container shell: bash id: build-step run: |- + summary=$(cat <<'ENDOFSUMMARY' + ${{ inputs.release-summary }} + ENDOFSUMMARY + ) + docker run --rm \ --platform ${{ inputs.platform }} \ --workdir /github/workspace \ @@ -104,9 +115,9 @@ runs: --user $(id -u):$(id -g) \ -e HOME \ esphome:${{ inputs.version }} \ - ${{ inputs.yaml_file }} \ - --release-summary "${{ inputs.release_summary }}" \ - --release-url "${{ inputs.release_url }}" \ + ${{ inputs.yaml-file }} \ + --release-summary "$summary" \ + --release-url "${{ inputs.release-url }}" \ --outputs-file "$GITHUB_OUTPUT" \ ${{ inputs.complete-manifest == 'true' && '--complete-manifest' || '--partial-manifest' }} diff --git a/entrypoint.py b/entrypoint.py index 7039903..1d8a3f9 100755 --- a/entrypoint.py +++ b/entrypoint.py @@ -105,6 +105,10 @@ def dest_ota_bin(self, file_base: Path) -> Path: """Get the destination OTA binary path.""" return file_base / f"{self.name}.ota.bin" + def dest_elf(self, file_base: Path) -> Path: + """Get the destination ELF path.""" + return file_base / f"{self.name}.elf" + def source_factory_bin(self, elf: Path) -> Path: """Get the source factory binary path.""" if self.platform == "rp2040": @@ -227,7 +231,7 @@ def generate_manifest_part( manifest = { "chipFamily": chip_family, "ota": { - "path": str(ota_bin), + "path": ota_bin.name, "md5": ota_md5, }, } @@ -240,7 +244,7 @@ def generate_manifest_part( if has_factory_part: manifest["parts"] = [ { - "path": str(factory_bin), + "path": str(factory_bin.name), "offset": 0x00, } ] @@ -283,12 +287,16 @@ def main(argv) -> int: source_ota_bin = config.source_ota_bin(elf) dest_ota_bin = config.dest_ota_bin(file_base) + dest_elf = config.dest_elf(file_base) + file_base.mkdir(parents=True, exist_ok=True) shutil.copyfile(source_factory_bin, dest_factory_bin) print("Copied factory binary to:", dest_factory_bin) shutil.copyfile(source_ota_bin, dest_ota_bin) print("Copied OTA binary to:", dest_ota_bin) + shutil.copyfile(elf, dest_elf) + print("Copied ELF file to:", dest_elf) print("::endgroup::") diff --git a/tests/complete-manifest-template.json b/tests/complete-manifest-template.json index 88087dd..31e0aa4 100644 --- a/tests/complete-manifest-template.json +++ b/tests/complete-manifest-template.json @@ -7,14 +7,14 @@ { "chipFamily": "ESP32", "ota": { - "path": "test-esp32/test-esp32.ota.bin", + "path": "test-esp32.ota.bin", "md5": "\($md5)", - "summary": "Test release summary", + "summary": "Test \"release\" summary\n* Multiple lines", "release_url": "https://github.com/esphome/build-action" }, "parts": [ { - "path": "test-esp32/test-esp32.factory.bin", + "path": "test-esp32.factory.bin", "offset": 0 } ] diff --git a/tests/partial-manifest-template.json b/tests/partial-manifest-template.json index e705442..144b74b 100644 --- a/tests/partial-manifest-template.json +++ b/tests/partial-manifest-template.json @@ -1,14 +1,14 @@ { "chipFamily": "ESP32", "ota": { - "path": "test-esp32/test-esp32.ota.bin", + "path": "test-esp32.ota.bin", "md5": "\($md5)", - "summary": "Test release summary", + "summary": "Test \"release\" summary\n* Multiple lines", "release_url": "https://github.com/esphome/build-action" }, "parts": [ { - "path": "test-esp32/test-esp32.factory.bin", + "path": "test-esp32.factory.bin", "offset": 0 } ]