Fix CI #114
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: PlatformIO build | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare data | |
run: | | |
set -x | |
pushd data | |
for f in $(curl -sL https://api.github.com/repos/coderus/led-lamp-webui/releases/latest | jq -r '.assets[].browser_download_url'); do curl $f -OL; done | |
for f in $(curl -sL https://api.github.com/repos/coderus/wifimanager-react-page/releases/latest | jq -r '.assets[].browser_download_url'); do curl $f -OL; done | |
popd | |
zip -r data.zip data | |
- name: Cache pip | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/platformio.ini') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Cache PlatformIO | |
uses: actions/cache@v4 | |
with: | |
path: ~/.platformio | |
key: ${{ runner.os }}-pio-${{ hashFiles('**/platformio.ini') }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
- name: Install PlatformIO | |
run: | | |
set -x | |
python3 -m pip install --upgrade pip | |
pip3 install --upgrade platformio | |
- name: Build env esp32dev | |
run: | | |
set -x | |
platformio run -e esp32dev | |
platformio run -e esp32dev --target buildfs | |
- name: Build env nodemcu | |
run: | | |
set -x | |
platformio run -e nodemcu | |
platformio run -e nodemcu --target buildfs | |
- name: Build env sonoff-r1 | |
run: | | |
set -x | |
platformio run -e sonoff-r1 | |
platformio run -e sonoff-r1 --target buildfs | |
- name: Build env sonoff-r1-4m | |
run: | | |
set -x | |
platformio run -e sonoff-r1-4m | |
platformio run -e sonoff-r1-4m --target buildfs | |
- name: Build env esp01s | |
run: | | |
set -x | |
platformio run -e esp01s | |
platformio run -e esp01s --target buildfs | |
- name: Prepare artifacts | |
run: | | |
set -x | |
mkdir -p artifacts | |
cp data.zip artifacts/data.zip | |
cp .pio/build/esp32dev/firmware.bin artifacts/esp32dev.bin | |
cp .pio/build/esp32dev/spiffs.bin artifacts/esp32dev-fs.bin | |
cp .pio/build/nodemcu/firmware.bin artifacts/nodemcu.bin | |
cp .pio/build/nodemcu/fs.bin artifacts/nodemcu-fs.bin | |
cp .pio/build/sonoff-r1/firmware.bin artifacts/sonoff-r1.bin | |
cp .pio/build/sonoff-r1/fs.bin artifacts/sonoff-r1-fs.bin | |
cp .pio/build/sonoff-r1-4m/firmware.bin artifacts/sonoff-r1-4m.bin | |
cp .pio/build/sonoff-r1-4m/fs.bin artifacts/sonoff-r1-4m-fs.bin | |
cp .pio/build/esp01s/firmware.bin artifacts/esp01s.bin | |
cp .pio/build/esp01s/fs.bin artifacts/esp01s-fs.bin | |
- name: Upload build result | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts | |
path: artifacts | |
- name: Create release | |
if: github.ref == 'refs/heads/master' | |
run: | | |
set -x | |
assets=() | |
for asset in artifacts/*.bin; do | |
assets+=("$asset") | |
done | |
for asset in artifacts/*.zip; do | |
assets+=("$asset") | |
done | |
RELEASE_TAG="$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)" | |
gh release create "$RELEASE_TAG" "${assets[@]}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |