Skip to content

Commit 84ad200

Browse files
authored
Merge pull request #166 from FutureProofHomes/staging
Initial Release
2 parents 4d6e8ec + 00c1860 commit 84ad200

File tree

111 files changed

+24002
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+24002
-308
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: "Bug report \U0001F41E"
3+
about: Create a bug report
4+
labels: bug
5+
6+
---
7+
8+
## Describe the bug
9+
A clear and concise description of what the bug is.
10+
11+
### Steps to reproduce
12+
Steps to reproduce the behavior.
13+
14+
### Expected behavior
15+
A clear and concise description of what you expected to happen.
16+
17+
### Environment
18+
- OS: [e.g. Arch Linux]
19+
- Other details that you think may affect.
20+
21+
### Additional context
22+
Add any other context about the problem here.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: "Feature request \U0001F680"
3+
about: Suggest an idea
4+
labels: enhancement
5+
6+
---
7+
8+
## Summary
9+
Brief explanation of the feature.
10+
11+
### Basic example
12+
Include a basic example or links here.
13+
14+
### Motivation
15+
Why are we doing this? What use cases does it support? What is the expected outcome?
Lines changed: 33 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,48 @@
1-
name: ESPHome-latest
1+
name: Build-Satellite-Firmware
22

33
on:
4-
- push
5-
- pull_request
6-
- workflow_dispatch
4+
push:
5+
branches:
6+
- develop
7+
workflow_dispatch:
78

89
env:
910
DEFAULT_PYTHON: "3.9"
1011

11-
1212
jobs:
13-
common:
14-
name: Create common environment
15-
runs-on: ubuntu-latest
16-
outputs:
17-
cache-key: ${{ steps.cache-key.outputs.key }}
18-
steps:
19-
- name: Check out code from GitHub
20-
uses: actions/[email protected]
21-
- name: Generate cache-key
22-
id: cache-key
23-
run: echo key="${{ hashFiles('requirements.txt') }}" >> $GITHUB_OUTPUT
24-
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
25-
id: python
26-
uses: actions/[email protected]
27-
with:
28-
python-version: ${{ env.DEFAULT_PYTHON }}
29-
- name: Restore Python virtual environment
30-
id: cache-venv
31-
uses: actions/[email protected]
32-
with:
33-
path: venv
34-
# yamllint disable-line rule:line-length
35-
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ steps.cache-key.outputs.key }}
36-
- name: Create Python virtual environment
37-
if: steps.cache-venv.outputs.cache-hit != 'true'
38-
run: |
39-
python -m venv venv
40-
. venv/bin/activate
41-
python --version
42-
pip install -r requirements.txt
4313

44-
build-list:
45-
runs-on: ubuntu-latest
46-
outputs:
47-
matrix: ${{ steps.set-matrix.outputs.matrix }}
48-
steps:
49-
- name: Check out code from GitHub
50-
uses: actions/[email protected]
51-
- name: Find all YAML satellite files
52-
id: set-matrix
53-
run: echo "matrix=$(ls config/satellite*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
14+
build-firmware:
15+
uses: esphome/workflows/.github/workflows/build.yml@main
16+
with:
17+
files: |
18+
config/satellite1.yaml
19+
esphome-version: 2024.11.2
20+
release-summary: develop-branch
21+
release-url:
22+
release-version:
5423

5524

56-
build:
57-
name: Build YAML config ${{ matrix.file }}
58-
runs-on: ubuntu-latest
25+
create_artifact_matrix:
26+
name: Create artifact matrix
5927
needs:
60-
- common
61-
- build-list
62-
strategy:
63-
fail-fast: false
64-
max-parallel: 2
65-
matrix:
66-
file: ${{ fromJson(needs.build-list.outputs.matrix) }}
28+
- build-firmware
29+
outputs:
30+
matrix: ${{ steps.artifacts.outputs.matrix }}
31+
runs-on: ubuntu-latest
6732
steps:
68-
- name: Check out code from GitHub
69-
uses: actions/[email protected]
70-
- name: Restore Python
71-
uses: ./.github/actions/restore-python
72-
with:
73-
python-version: ${{ env.DEFAULT_PYTHON }}
74-
cache-key: ${{ needs.common.outputs.cache-key }}
75-
76-
- name: Run esphome compile ${{ matrix.file }}
77-
run: |
78-
. venv/bin/activate
79-
esphome compile ${{ matrix.file }}
80-
esphome config ${{ matrix.file }} >> ${{ matrix.file }}.cmpl.yaml
81-
82-
- name: Parse name
83-
id: get_node_name
84-
uses: mikefarah/yq@master
33+
- name: Download artifacts
34+
uses: actions/[email protected]
8535
with:
86-
cmd: yq '.esphome.name' ${{ matrix.file }}.cmpl.yaml
36+
path: files
8737

88-
- name: 'Upload Artifact'
89-
uses: actions/upload-artifact@v4
90-
with:
91-
name: ${{ steps.get_node_name.outputs.result }}.firmware.factory.bin
92-
path: config/.esphome/build/${{ steps.get_node_name.outputs.result }}/.pioenvs/${{ steps.get_node_name.outputs.result }}/firmware.factory.bin
93-
retention-days: 30
38+
- run: tree
9439

95-
- name: 'Upload Artifact'
96-
uses: actions/upload-artifact@v4
97-
with:
98-
name: ${{ steps.get_node_name.outputs.result }}.firmware.bin
99-
path: config/.esphome/build/${{ steps.get_node_name.outputs.result }}/.pioenvs/${{ steps.get_node_name.outputs.result }}/firmware.bin
100-
retention-days: 30
40+
- name: Get artifact names
41+
id: artifacts
42+
run: |
43+
artifacts=$(ls --format=single-column files)
44+
echo "artifacts<<EOF" >> $GITHUB_OUTPUT
45+
echo "$artifacts" >> $GITHUB_OUTPUT
46+
echo "EOF" >> $GITHUB_OUTPUT
47+
echo "matrix=$(ls files | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
48+
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Build-and-Release-Satellite-Firmware
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- staging
8+
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: 'Tag for the release (optional). If not provided, it will be auto-generated.'
12+
required: false
13+
14+
env:
15+
DEFAULT_PYTHON: "3.9"
16+
permissions:
17+
contents: write
18+
pull-requests: read
19+
jobs:
20+
prepare:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
commit_id: ${{ steps.dump.outputs.commit }}
24+
previous_tag: ${{ steps.dump.outputs.previous_tag }}
25+
next_tag: ${{ steps.set_release_tag.outputs.release_tag }}
26+
steps:
27+
- name: Check out code from GitHub
28+
uses: actions/[email protected]
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set Manual Tag (if provided)
33+
id: set_tag
34+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }}
35+
run: echo "manual_tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
36+
37+
- name: Bump version
38+
# if manual tag is provided, use it
39+
if: ${{ !steps.set_tag.outputs.manual_tag }}
40+
uses: anothrNick/[email protected]
41+
id: bump
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
# To create a major bump add #major to commit message
45+
DEFAULT_BUMP: 'patch'
46+
WITH_V: true
47+
PRERELEASE: ${{ github.ref_name != 'main' }}
48+
PRERELEASE_SUFFIX: ${{ github.ref_name == 'staging' && 'beta' || 'alpha' }}
49+
DRY_RUN: true # Prevent action from pushing the tag.
50+
INITIAL_VERSION: 0.0.0
51+
52+
- name: Set tag for release
53+
if: ${{ steps.set_tag.outputs.manual_tag || steps.bump.outputs.tag }}
54+
id: set_release_tag
55+
run: |
56+
if [ -z "${{ steps.set_tag.outputs.manual_tag }}" ]; then
57+
echo "release_tag=${{ steps.bump.outputs.tag }}" >> $GITHUB_OUTPUT
58+
else
59+
echo "release_tag=${{ steps.set_tag.outputs.manual_tag }}" >> $GITHUB_OUTPUT
60+
fi
61+
62+
- id: dump
63+
name: Set outputs
64+
run: |
65+
echo "gh_env=${{ github.ref_name == 'main' && 'production' || github.ref_name == 'staging' && 'beta' || 'alpha' }}" >> $GITHUB_OUTPUT
66+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
67+
echo "long_version=${{ steps.set_release_tag.outputs.release_tag }}_$(date +%Y-%m-%d)_$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
68+
echo "label_version=$(echo "${{ steps.set_release_tag.outputs.release_tag }}" | sed 's/\./dot/g' | sed 's/-/dash/g')" >> $GITHUB_OUTPUT
69+
echo "previous_tag=$(git describe --abbrev=0 --tags)" >> $GITHUB_OUTPUT
70+
echo "files=$(ls config/satellite*.yaml | jq --slurp --raw-input )" >> $GITHUB_OUTPUT
71+
72+
- name: Update YAML files
73+
run: |
74+
files=$(echo ${{ steps.dump.outputs.files }} \
75+
| sed 's/^"//' \
76+
| sed 's/"$//' \
77+
| sed 's/\\n/\n/g')
78+
tag="${{ steps.set_release_tag.outputs.release_tag }}"
79+
for file in $files; do
80+
echo "Updating $file"
81+
# Use sed to match the esp32_fw_version line and replace its value
82+
sed -i "s/^\(\s*esp32_fw_version:\s*\).*/\1\"${tag}\"/" "$file"
83+
done
84+
build-firmware:
85+
name: Build Firmware
86+
needs:
87+
- prepare
88+
uses: esphome/workflows/.github/workflows/build.yml@main
89+
with:
90+
files: |
91+
config/satellite1.yaml
92+
esphome-version: 2024.11.2
93+
release-version: ${{ needs.prepare.outputs.next_tag }}
94+
95+
push-tag:
96+
name: Push tag to repository and build changelog.
97+
needs:
98+
- prepare
99+
- build-firmware
100+
runs-on: ubuntu-latest
101+
outputs:
102+
changelog: ${{ steps.changelog.outputs.changelog }}
103+
104+
steps:
105+
- uses: actions/checkout@v3
106+
with:
107+
fetch-depth: 0
108+
109+
- name: Bump version and push tag
110+
if: ${{ !github.event.inputs.tag }}
111+
uses: anothrNick/[email protected]
112+
id: bump
113+
env:
114+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
# To create a major bump add #major to commit message
116+
DEFAULT_BUMP: 'patch'
117+
WITH_V: true
118+
PRERELEASE: ${{ github.ref_name != 'main' }}
119+
PRERELEASE_SUFFIX: ${{ github.ref_name == 'staging' && 'beta' || 'alpha' }}
120+
DRY_RUN: false # Set the tag to the commit.
121+
INITIAL_VERSION: 0.0.0
122+
123+
- name: Release Changelog Builder
124+
id: changelog
125+
uses: mikepenz/release-changelog-builder-action@v5
126+
with:
127+
fromTag: ${{ needs.prepare.outputs.previous_tag }}
128+
129+
create_release:
130+
name: Create Release
131+
# only build release for staging and main branches
132+
# if: github.ref_name == 'main' || github.ref_name == 'staging'
133+
needs:
134+
- push-tag
135+
- prepare
136+
runs-on: ubuntu-latest
137+
steps:
138+
- name: Download artifacts
139+
uses: actions/download-artifact@v4
140+
with:
141+
path: files
142+
143+
- name: Create zip files
144+
run: |
145+
mkdir -p build
146+
echo "Copying all files to build directory"
147+
find files -name "*.bin" -exec cp {} build/ \;
148+
149+
- name: Create release
150+
uses: softprops/action-gh-release@v2
151+
with:
152+
files: build/*.bin
153+
generate_release_notes: true
154+
append_body: true
155+
body: ${{ needs.push-tag.outputs.changelog }}
156+
tag_name: ${{ needs.prepare.outputs.next_tag }}
157+
158+
- name: Update Documentation
159+
run: |
160+
curl -X POST \
161+
-H "Accept: application/vnd.github+json" \
162+
-H "Authorization: Bearer ${{ secrets.SECOND_REPO_PAT }}" \
163+
https://api.github.com/repos/FutureProofHomes/Documentation/actions/workflows/update-binaries-esp32.yaml/dispatches \
164+
-d '{"ref":"main", "inputs": {"esphome_release_tag": "${{ needs.prepare.outputs.next_tag }}"}}'
165+
env:
166+
SECOND_REPO_PAT: ${{ secrets.SECOND_REPO_PAT }}

.gitignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
__pycache__
22
*.pyc
33
.venv/
4-
**/.esphome/
54
*.egg-info/
65

76
.esphome_repo
@@ -17,4 +16,11 @@ managed_components/
1716
sdkconfig.esp32-idf
1817
sdkconfig.esp32-s3-idf
1918

20-
*/**/secrets.yaml
19+
**/.esphome/
20+
**/secrets.yaml
21+
22+
/testdata
23+
/wake-word-benchmark/
24+
/Docker/firmware_server/shared-folder
25+
26+
**/.DS_Store

Docker/firmware_server/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM nginx:alpine
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
location / {
6+
root /usr/share/nginx/html;
7+
index index.html index.htm;
8+
autoindex on;
9+
}
10+
11+
error_page 500 502 503 504 /50x.html;
12+
location = /50x.html {
13+
root /usr/share/nginx/html;
14+
}
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: '2'
2+
3+
services:
4+
web:
5+
build: .
6+
volumes:
7+
- ./config/default.conf:/etc/nginx/conf.d/default.conf
8+
- ./shared-folder:/usr/share/nginx/html
9+
ports:
10+
- 8080:80

0 commit comments

Comments
 (0)