update #54
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Compile ESPHome Binary | |
on: | |
push: | |
#branches: | |
# - main | |
# - dev | |
paths: | |
- '.github/**' | |
- '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 | |
#sudo apt install yq | |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq | |
sudo chmod +x /usr/local/bin/yq | |
yq --version | |
# 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_de.yaml | |
run: | | |
cp .github/workflows/resources/secrets.yaml examples/ | |
#sed -i 's/!/?/g' examples/full_de.yaml # make yaml pyyaml conform for cels | |
#cels patch examples/full_de.yaml .github/workflows/resources/external_components_dev.yaml > full_patched.yaml | |
#cat full_patched.yaml > examples/full_de.yaml | |
#sed -i 's/?/!/g' examples/full_de.yaml # make yaml esphome conform | |
yq eval '.external_components[0].source = {"type": "local", "path": "../components"}' -i examples/full_de.yaml | |
- name: Compile ESPHome binary | |
run: | | |
# compile eshphome | |
esphome compile examples/full_de.yaml | |
# rename file | |
mv examples/.esphome/build/hpsu-can/.pioenvs/hpsu-can/firmware.factory.bin hpsu-can.factory-gpios-tx05-rx06.bin | |
- name: Archive compiled binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: compiled-binary | |
path: hpsu-can.factory-gpios-tx05-rx06.bin |