Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/actions/restore-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Restore Python
inputs:
python-version:
description: Python version to restore
required: true
type: string
cache-key:
description: Cache key to use
required: true
type: string
outputs:
python-version:
description: Python version restored
value: ${{ steps.python.outputs.python-version }}
runs:
using: "composite"
steps:
- name: Set up Python ${{ inputs.python-version }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ inputs.python-version }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache/[email protected]
with:
path: venv
# yamllint disable-line rule:line-length
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ inputs.cache-key }}

- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true' && runner.os != 'Windows'
shell: bash
run: |
python -m venv venv
source venv/bin/activate
python --version
pip install -r requirements.txt

- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true' && runner.os == 'Windows'
shell: bash
run: |
python -m venv venv
./venv/Scripts/activate
python --version
pip install -r requirements.txt
100 changes: 100 additions & 0 deletions .github/workflows/build_latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: ESPHome-latest

on:
- push
- pull_request
- workflow_dispatch

env:
DEFAULT_PYTHON: "3.9"


jobs:
common:
name: Create common environment
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Generate cache-key
id: cache-key
run: echo key="${{ hashFiles('requirements.txt') }}" >> $GITHUB_OUTPUT
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/[email protected]
with:
path: venv
# yamllint disable-line rule:line-length
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ steps.cache-key.outputs.key }}
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
python --version
pip install -r requirements.txt

build-list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Find all YAML satellite files
id: set-matrix
run: echo "matrix=$(ls config/satellite*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT


build:
name: Build YAML config ${{ matrix.file }}
runs-on: ubuntu-latest
needs:
- common
- build-list
strategy:
fail-fast: false
max-parallel: 2
matrix:
file: ${{ fromJson(needs.build-list.outputs.matrix) }}
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Restore Python
uses: ./.github/actions/restore-python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache-key: ${{ needs.common.outputs.cache-key }}

- name: Run esphome compile ${{ matrix.file }}
run: |
. venv/bin/activate
esphome compile ${{ matrix.file }}
esphome config ${{ matrix.file }} >> ${{ matrix.file }}.cmpl.yaml

- name: Parse name
id: get_node_name
uses: mikefarah/yq@master
with:
cmd: yq '.esphome.name' ${{ matrix.file }}.cmpl.yaml

- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get_node_name.outputs.result }}.firmware.factory.bin
path: config/.esphome/build/${{ steps.get_node_name.outputs.result }}/.pioenvs/${{ steps.get_node_name.outputs.result }}/firmware.factory.bin
retention-days: 30

- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get_node_name.outputs.result }}.firmware.bin
path: config/.esphome/build/${{ steps.get_node_name.outputs.result }}/.pioenvs/${{ steps.get_node_name.outputs.result }}/firmware.bin
retention-days: 30