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
179 changes: 179 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: Build

on:
workflow_call:
inputs:
files:
description: Newline separated list of files to build
required: true
type: string
esphome-version:
description: Version of ESPHome to build with
required: false
type: string
default: latest
release-summary:
description: Summary of the release
required: false
type: string
default: ""
release-url:
description: URL to the release notes
required: false
type: string
default: ""
release-version:
description: Version of the release
required: false
type: string
default: ""
combined-name:
description: Combine all files into a single manifest under this name
required: false
type: string
default: ""

outputs:
version:
description: Version of the firmware generated
value: ${{ jobs.prepare.outputs.version }}

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
files: ${{ steps.files-array.outputs.files }}
version: ${{ steps.version.outputs.version }}
artifact-prefix: ${{ steps.artifact-name.outputs.artifact-prefix }}
steps:
- name: Split files input into JSON array
id: files-array
run: |
files=$(echo "${{ inputs.files }}" | jq -RcSn '[inputs | select(length>0)]')
echo files=$files >> $GITHUB_OUTPUT
- name: Generate version
id: version
run: |
if [ -n "${{ inputs.release-version }}" ]; then
version=${{ inputs.release-version }}
else
version=dev-$(date +'%Y%m%d-%H%M')
fi

echo version=$version >> $GITHUB_OUTPUT
- name: Generated random artifact prefix
id: artifact-name
run: |
artifact_prefix=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo)
echo artifact-prefix=$artifact_prefix >> $GITHUB_OUTPUT

build:
name: ${{ matrix.file }}
needs: [prepare]
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
file: ${{ fromJson(needs.prepare.outputs.files) }}
steps:
- name: Checkout code
uses: actions/[email protected]
with:
ref: ${{ github.ref }}

- name: Update version in satellite1.yaml
run: |
file=config/satellite1.yaml
tag="${{ needs.prepare.outputs.version }}"
sed -i "s/^\(\s*esp32_fw_version:\s*\).*/\1\"${tag}\"/" "$file"

- name: Check version update
run: |
grep esp32_fw_version config/satellite1.yaml
- name: Build Firmware
uses: esphome/[email protected]
id: esphome-build
with:
yaml-file: ${{ matrix.file }}
version: ${{ inputs.esphome-version }}
complete-manifest: true
release-summary: ${{ inputs.release-summary }}
release-url: ${{ inputs.release-url }}
- name: Move files for versioning
run: |
mkdir -p output/${{ needs.prepare.outputs.version }}
mv ${{ steps.esphome-build.outputs.name }}/* output/${{ needs.prepare.outputs.version }}/

- name: Rename firmware output files
run: |
NEW_NAME=$(basename ${{ matrix.file }} .yaml) # Replace with your desired base name

for ext in ota.bin factory.bin elf; do
for f in *.${ext}; do
[ -e "$f" ] || continue # skip if no match
mv "$f" "${NEW_NAME}.${ext}"
done
done
shell: bash
working-directory: output/${{ needs.prepare.outputs.version }}

- name: Set artifact name
id: artifact_name
run: |
echo "basename=$(basename ${{ matrix.file }})" >> $GITHUB_OUTPUT

- name: Upload artifact
uses: actions/[email protected]
with:
name: ${{ format('{0}-{1}', steps.artifact_name.outputs.basename, steps.esphome-build.outputs.name) || steps.esphome-build.outputs.original-name }}
path: output

combine:
name: Combine manifests
needs:
- prepare
- build
runs-on: ubuntu-latest
if: inputs.combined-name != ''
steps:
- name: Download artifacts
uses: actions/[email protected]
with:
path: files
pattern: ${{ needs.prepare.outputs.artifact-prefix }}-*

- name: Get artifact names
id: artifacts
run: |
artifacts=$(ls --format=single-column files)
echo "artifacts<<EOF" >> $GITHUB_OUTPUT
echo "$artifacts" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Delete prefixed artifacts
uses: geekyeggo/[email protected]
with:
name: ${{ steps.artifacts.outputs.artifacts }}

- name: Combine all parts into a single manifest
run: |
version="${{ needs.prepare.outputs.version }}"
mkdir -p "output/$version"
pushd files
for device in *; do
pushd $device
pushd $version
cp * "../../../output/$version/"
popd
popd
done
popd
jq -s '(.[0] | del(.builds)) + {"builds": (reduce .[].builds as $b ([]; . + $b))}' files/*/$version/manifest.json > output/$version/manifest.json

- name: Upload artifact
uses: actions/[email protected]
with:
name: ${{ inputs.combined-name }}
path: output
6 changes: 4 additions & 2 deletions .github/workflows/build_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ env:
jobs:

build-firmware:
uses: esphome/workflows/.github/workflows/build.yml@main
uses: ./.github/workflows/build.yaml
with:
files: |
config/satellite1.factory.yaml
config/satellite1.yaml
config/satellite1.ld2410.yaml
config/satellite1.ld2450.yaml
esphome-version: 2025.4.0
release-summary: develop-branch
release-url:
Expand Down
45 changes: 29 additions & 16 deletions .github/workflows/build_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
uses: actions/[email protected]
with:
fetch-depth: 0

ref: ${{ github.ref }}

- name: Set Manual Tag (if provided)
id: set_tag
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }}
Expand Down Expand Up @@ -68,28 +69,17 @@ jobs:
echo "long_version=${{ steps.set_release_tag.outputs.release_tag }}_$(date +%Y-%m-%d)_$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "label_version=$(echo "${{ steps.set_release_tag.outputs.release_tag }}" | sed 's/\./dot/g' | sed 's/-/dash/g')" >> $GITHUB_OUTPUT
echo "previous_tag=$(git describe --abbrev=0 --tags)" >> $GITHUB_OUTPUT
echo "files=$(ls config/satellite*.factory.yaml | jq --slurp --raw-input )" >> $GITHUB_OUTPUT

- name: Update YAML files
run: |
files=$(echo ${{ steps.dump.outputs.files }} \
| sed 's/^"//' \
| sed 's/"$//' \
| sed 's/\\n/\n/g')
tag="${{ steps.set_release_tag.outputs.release_tag }}"
for file in $files; do
echo "Updating $file"
# Use sed to match the esp32_fw_version line and replace its value
sed -i "s/^\(\s*esp32_fw_version:\s*\).*/\1\"${tag}\"/" "$file"
done
build-firmware:
name: Build Firmware
needs:
- prepare
uses: esphome/workflows/.github/workflows/build.yml@main
uses: ./.github/workflows/build.yaml
with:
files: |
config/satellite1.factory.yaml
config/satellite1.yaml
config/satellite1.ld2410.yaml
config/satellite1.ld2450.yaml
esphome-version: 2025.4.0
release-version: ${{ needs.prepare.outputs.next_tag }}

Expand All @@ -106,6 +96,28 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}

- name: Create Manual Tag (if provided and does not exist)
id: crate_manual_tag
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }}
run: |
tag="${{ github.event.inputs.tag }}"

# Fetch tags from remote
git fetch --tags

if git rev-parse "refs/tags/$tag" >/dev/null 2>&1; then
echo "Tag '$tag' already exists."
else
echo "Creating tag '$tag'"
git config user.name "github-actions"
git config user.email "[email protected]"
git tag "$tag"
git push origin "$tag"
fi

echo "manual_tag=$tag" >> "$GITHUB_OUTPUT"

- name: Bump version and push tag
if: ${{ !github.event.inputs.tag }}
Expand Down Expand Up @@ -160,6 +172,7 @@ jobs:
tag_name: ${{ needs.prepare.outputs.next_tag }}

- name: Update Documentation
if: ${{ github.ref_name == 'main' || github.ref_name == 'staging' }}
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
Expand Down
2 changes: 1 addition & 1 deletion config/satellite1.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ota:
id: ota_esphome

dashboard_import:
package_import_url: github://futureproofhomes/satellite1-esphome/config/satellite1.yaml@develop
package_import_url: github://futureproofhomes/satellite1-esphome/config/satellite1.dashboard.yaml@develop
import_full_config: true


Expand Down
53 changes: 53 additions & 0 deletions config/satellite1.dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
substitutions:
name: satellite1
friendly_name: Satellite1
xmos_fw_version: "v1.0.2"

# OPTIONALLY, set the log level to debug, info, warn, error
log_level: debug

esphome:
name: ${name}
name_add_mac_suffix: true
friendly_name: ${friendly_name}

packages:
FutureProofHomes.Satellite1:
url: https://github.com/futureproofhomes/satellite1-esphome
ref: develop
refresh: 1s
files:
# Main config files, don't remove
- config/satellite1.base.yaml
- config/common/components.external.yaml

## OPTIONALLY, uncomment if you have the smaller LD2410 mmWave sensor connected to your HAT.
#- config/common/mmwave_ld2410.yaml

## OPTIONALLY, uncomment if you have the larger LD2450 mmWave sensor connected to your HAT.
#- config/common/mmwave_ld2450.yaml

## OPTIONALLY, uncomment if want extra memory, wifi and xmos control of the device.
#- config/common/debug.yaml

logger:
level: ${log_level}

## OPTIONALLY, enable transport encryption for the API layer by uncommenting the following lines
## and replacing "REPLACE_BY_32_BIT_RANDOM_KEY" with a 32-character random key.
## For more information, refer to the ESPHome documentation:
## https://esphome.io/components/api.html
## Note: The documentation also provides a tool to generate a random key

#api:
# encryption:
# key: REPLACE_BY_32_BIT_RANDOM_KEY

## OPTIONALLY, override the default Wi-Fi credentials provisioned on the Satellite1 device
## during setup by using your Wi-Fi credentials stored in the `secrets.yaml` file of the
## ESPHome dashboard. Uncomment the below lines to enable this feature, allowing you
## to manage Wi-Fi credentials centrally for all your devices.

#wifi:
# ssid: !secret wifi_ssid
# password: !secret wifi_password
Loading