-
Notifications
You must be signed in to change notification settings - Fork 12
90 lines (76 loc) · 3.01 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Compile ESPHome Binary
on:
push:
branches:
- main
- dev
paths:
- 'examples/full.yaml'
- 'components/**'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check for required secrets
run: |
if [ -z "${{ secrets.API_ENCRYPTION_KEY }}" ]; then
echo "Error: API_ENCRYPTION_KEY secret is not set" >&2
exit 1
fi
if [ -z "${{ secrets.OTA_PASSWORD }}" ]; then
echo "Error: OTA_PASSWORD secret is not set" >&2
exit 1
fi
if [ -z "${{ secrets.WIFI_SSID }}" ]; then
echo "Error: WIFI_SSID secret is not set" >&2
exit 1
fi
if [ -z "${{ secrets.WIFI_PASSWORD }}" ]; then
echo "Error: WIFI_PASSWORD secret is not set" >&2
exit 1
fi
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Set environment variables
run: |
echo "API_ENCRYPTION_KEY=${{ secrets.API_ENCRYPTION_KEY }}" >> $GITHUB_ENV
echo "OTA_PASSWORD=${{ secrets.OTA_PASSWORD }}" >> $GITHUB_ENV
echo "WIFI_SSID=${{ secrets.WIFI_SSID }}" >> $GITHUB_ENV
echo "WIFI_PASSWORD=${{ secrets.WIFI_PASSWORD }}" >> $GITHUB_ENV
- name: Install ESPHome and cels
run: |
python3 -m pip install esphome
# install latest version of cels by using wget, otherwise version 0.1.0 would be installed, which is buggy
wget https://files.pythonhosted.org/packages/18/82/14819c1cc67c67e909abdbd9824eb756adccd47a1dee1c846f7300716646/cels-0.3.1.tar.gz
python3 -m pip install cels-0.3.1.tar.gz
- name: Prepare full.yaml
run: |
cp examples/full.yaml .
cp .github/workflows/resources/secrets.yaml .
cp .github/workflows/src/extract_external_components_block.py .
cp .github/workflows/src/patch_full_yaml.sh .
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then
echo "dev branch run, take external components from dev branch"
source patch_full_yaml.sh
else
echo "not dev branch run, take external components from main"
fi
# print path used for external components
echo "The following external components will be used for compilation: "
python extract_external_components_block.py
- name: Compile ESPHome binary
run: |
# compile eshphome
esphome compile full.yaml
# rename file
mv .esphome/build/rotex/.pioenvs/rotex/firmware.factory.bin .esphome/build/rotex/.pioenvs/rotex/rotex.factory-gpios-tx05-rx06.bin
- name: Archive compiled binary
uses: actions/upload-artifact@v4
with:
name: compiled-binary
path: .esphome/build/rotex/.pioenvs/rotex/rotex.factory-gpios-tx05-rx06.bin