Skip to content

fix(webui): use measurementInterval for index page polling (#299) #47

fix(webui): use measurementInterval for index page polling (#299)

fix(webui): use measurementInterval for index page polling (#299) #47

Workflow file for this run

name: Release V3.0 (Stable)
# Create a stable release: push a new tag (v1.0, v2.0, etc.)
# Manifests are deployed to GitHub Pages (melkati.github.io/CO2-Gadget/)
# Firmware .bin files are deployed via FTP to emariete.com
#
# Architecture:
# build_release (matrix, parallel) → uploads artifacts
# deploy (single job, after all builds) → gh-pages (manifests) + FTP (.bin) + GitHub Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g. 1.0.0)'
required: false
default: '0.0.0'
jobs:
build_release:
name: Build ${env} matrix.environment
runs-on: ubuntu-latest
strategy:
matrix:
environment:
- esp32dev
- esp32dev_OLED
- TTGO_TDISPLAY
- TTGO_TDISPLAY_SANDWICH
- TDISPLAY_S3
- esp32dev_ST7789_240x320
- ttgo-t5-EINKBOARDGDEM0213B74
- ttgo-t5-EINKBOARDDEPG0213BN
- ttgo-t5-EINKBOARDGDEW0213M21
- ttgo-t7-EINKBOARDGDEM029T94
- ttgo-t7-WEACT_GDEH0154D67
- ttgo-t7-WEACT_DEPG0213BN
- ttgo-t7-WEACT_GxEPD2_290_BS
env:
CHIP_FAMILY: ${ matrix.environment == 'TDISPLAY_S3' && 'ESP32-S3' || 'ESP32' }
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version
id: get_version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
VERSION="${{ github.event.inputs.version || '0.0.0' }}"
echo "Manual trigger — using version: $VERSION"
else
VERSION="${GITHUB_REF#refs/tags/}"
echo "Tag trigger — using version: $VERSION"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: |
~/.platformio
.pio/build
key: pio-${{ matrix.environment }}-${{ hashFiles('platformio.ini') }}
restore-keys: |
pio-${{ matrix.environment }}-
pio-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U platformio
platformio update
- name: Get current date
id: date
run: |
echo "date=$(date +'%d-%m-%Y')" >> $GITHUB_OUTPUT
echo "time=$(date +'%H:%M:%S')" >> $GITHUB_OUTPUT
- name: Build firmware
run: |
pio run -e ${{ matrix.environment }}
- name: Build filesystem
run: |
pio run -e ${{ matrix.environment }} -t buildfs
- name: Create manifest with absolute .bin URLs
id: create_manifest
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
COMPILED_DATE: ${{ steps.date.outputs.date }}
COMPILED_TIME: ${{ steps.date.outputs.time }}
run: |
# SPIFFS offset differs for ESP32-S3
if [[ "${{ env.CHIP_FAMILY }}" == "ESP32-S3" ]]; then
bootloader_offset=0
partitions_offset=32768
firmware_offset=65536
spiffs_offset=13172736
else
bootloader_offset=4096
partitions_offset=32768
firmware_offset=65536
spiffs_offset=3604480
fi
# Base URL for .bin files on emariete.com (absolute paths in manifest)
# Stable releases go to /firmware/CO2-Gadget/ (NOT /beta/)
BIN_BASE_URL="https://emariete.com/wp-content/uploads/firmware/CO2-Gadget"
REPO_NAME="${{ github.event.repository.name }}"
ENV_NAME="${{ matrix.environment }}"
VER="${{ steps.get_version.outputs.VERSION }}"
cat > ${REPO_NAME}-${ENV_NAME}.manifest.json << EOF
{
"name": "${REPO_NAME}-${ENV_NAME}",
"flavour": "${ENV_NAME}",
"version": "${VER}",
"compilation_date": "${COMPILED_DATE}",
"compilation_time": "${COMPILED_TIME}",
"new_install_prompt_erase": true,
"new_install_improv_wait_time": 20,
"builds": [
{
"chipFamily": "${{ env.CHIP_FAMILY }}",
"improv": true,
"parts": [
{ "path": "${BIN_BASE_URL}/${REPO_NAME}-${ENV_NAME}-${VER}-bootloader.bin", "offset": ${bootloader_offset} },
{ "path": "${BIN_BASE_URL}/${REPO_NAME}-${ENV_NAME}-${VER}-partitions.bin", "offset": ${partitions_offset} },
{ "path": "${BIN_BASE_URL}/${REPO_NAME}-${ENV_NAME}-${VER}-firmware.bin", "offset": ${firmware_offset} },
{ "path": "${BIN_BASE_URL}/${REPO_NAME}-${ENV_NAME}-${VER}-spiffs.bin", "offset": ${spiffs_offset} }
]
}
]
}
EOF
- name: Upload artifact (all files for this environment)
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.environment }}
path: |
.pio/build/${{ matrix.environment }}/bootloader.bin
.pio/build/${{ matrix.environment }}/partitions.bin
.pio/build/${{ matrix.environment }}/firmware.bin
.pio/build/${{ matrix.environment }}/spiffs.bin
${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
retention-days: 2
deploy:
name: Deploy Stable Release
needs: build_release
runs-on: ubuntu-latest
if: needs.build_release.result == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./release_firmware
pattern: release-*
merge-multiple: false
- name: List downloaded files
run: |
echo "=== Downloaded files ==="
find ./release_firmware -type f | sort
- name: Extract version from any artifact name
id: get_version
run: |
MANIFEST=$(find ./release_firmware -name "*.manifest.json" | head -1)
if [ -n "$MANIFEST" ]; then
VERSION=$(grep -oP '"version":\s*"\K[^"]+' "$MANIFEST")
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Found version: $VERSION"
fi
- name: Organize files for GitHub Pages (manifests at root)
run: |
# Stable manifests go to root of gh-pages (not /beta/)
mkdir -p ./gh-pages
find ./release_firmware -name "*.manifest.json" -exec cp {} ./gh-pages/ \;
echo "=== Manifests for GitHub Pages ==="
ls -la ./gh-pages/
- name: Organize files for FTP (.bin only)
run: |
# .bin files go to /CO2-Gadget/ on emariete.com (stable, not /beta/)
mkdir -p ./ftp_firmware
find ./release_firmware -name "*.bin" -exec cp {} ./ftp_firmware/ \;
echo "=== Files for FTP ==="
ls -la ./ftp_firmware/
- name: Deploy manifests to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
enable_jekyll: false
force_orphan: true
clean: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.event.repository.name }}-${{ steps.get_version.outputs.VERSION }}
tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref }}
draft: false
generate_release_notes: true
files: |
./ftp_firmware/*.bin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: FTP Deploy .bin files to emariete.com
uses: SamKirkland/FTP-Deploy-Action@2.0.0
env:
FTP_SERVER: ${{ secrets.FTP_SERVER }}
FTP_USERNAME: ${{ secrets.FTP_USER }}
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
LOCAL_DIR: ./ftp_firmware/
REMOTE_DIR: /${{ github.event.repository.name }}/
METHOD: ftp
PORT: 21
ARGS: --verbose
- name: Clean eMariete.com Cache
run: curl https://emariete.com/clean_cache_litespeed.php