build action: add board specific subfolder #261
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: Build and Release | |
on: | |
push: | |
pull_request: | |
jobs: | |
######################################################################################### | |
## Create release - PART 1: Prepare Release PR / Create release tag | |
# | |
# Use of release-please action to create a 'Release PR' which gets maintained automatically. | |
# After merging the 'Release PR', a new tag and release is getting created. | |
######################################################################################### | |
prepare-release: | |
runs-on: ubuntu-latest | |
outputs: | |
release_created: ${{ steps.release.outputs.release_created }} | |
upload_url: ${{ steps.release.outputs.upload_url }} | |
version: "${{steps.release.outputs.major}}.${{steps.release.outputs.minor}}.${{steps.release.outputs.patch}}" | |
tag_name: ${{ steps.release.outputs.tag_name }} | |
steps: | |
- uses: googleapis/release-please-action@v4 | |
id: release | |
with: | |
target-branch: develop | |
config-file: .release-please-config.json | |
manifest-file: .release-please-manifest.json | |
######################################################################################### | |
## Build Firmware | |
# | |
# Build firmware and create artifact packages | |
######################################################################################### | |
build: | |
runs-on: ubuntu-latest | |
needs: [prepare-release] | |
strategy: | |
fail-fast: false | |
matrix: | |
plat: | |
- esp32cam | |
- xiao-esp32s3-sense | |
- freenove-esp32s3 | |
steps: | |
- name: Checkout branch | |
if: ${{ ! needs.prepare-release.outputs.release_created }} | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Checkout tag # checkout tagged version when build a release for this tag | |
if: ${{ needs.prepare-release.outputs.release_created }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.prepare-release.outputs.tag_name }} | |
submodules: recursive | |
- name: Set variables | |
id: vars | |
run: | | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
echo "branch=$(echo ${{ github.ref_name }} | tr / __)" >> $GITHUB_OUTPUT | |
- name: Cache pip & platformIO cache files | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/pip | |
~/.platformio/.cache | |
key: platformio-${{ github.run_id }} | |
restore-keys: platformio # This matches above key as it is only used as a prefix. It restores the nearest cache | |
- name: Cache PIO build files | |
if: ${{ ! needs.prepare-release.outputs.release_created }} # do not use cached data when building a release | |
uses: actions/cache@v4 | |
with: | |
path: ./code/.pio | |
key: build-${{ matrix.plat }}-${{ github.run_id }} | |
restore-keys: build-${{ matrix.plat }} # This matches above key as it is only used as a prefix. It restores the nearest cache | |
- name: Setup python environment | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install PlatformIO environment | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade platformio | |
- name: Build firmware | |
run: cd code; platformio run -e ${{ matrix.plat }} | |
- name: Prepare WebUI (Generate parameter tooltips, API docs and update hash) | |
run: | | |
python -m pip install markdown | |
python ./tools/parameter-tooltip-generator/generate-param-doc-tooltips.py | |
python ./tools/docs-generator/generate-api-docs.py | |
rm -rf ./html | |
mkdir ./html | |
cp -r ./sd-card/html/* ./html/ | |
echo "Update hash..." | |
cd ./html; find . -type f -exec sed -i 's/$COMMIT_HASH/${{ steps.vars.outputs.sha_short }}/g' {} \; | |
######################################################################################### | |
## Create package for OTA Update | |
# Package to be used with OTA updater on WebUI | |
# | |
# Package contents: | |
# - /firmware.bin | |
# - (optional) /html/* (inkl. subfolders) | |
# - (optional) /config/*.tflite | |
######################################################################################### | |
- name: OTA update package - Prepare artifact | |
run: | | |
rm -rf ./update | |
mkdir -p ./update | |
cp "./code/.pio/build/${{ matrix.plat }}/firmware.bin" "update/firmware.bin" | |
cp -r ./html ./update/ | |
rm -rf ./update/config/ | |
mkdir -p ./update/config/ | |
cp ./sd-card/config/*.tfl ./update/config/ 2>/dev/null || true | |
cp ./sd-card/config/*.tflite ./update/config/ 2>/dev/null || true | |
- name: OTA update package - Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "AI-on-the-edge-device__update__${{ matrix.plat }}__SLFork_${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
path: ./update | |
######################################################################################### | |
## Create package for Full Setup -> Complete fresh install | |
# Create a full setup with all binaries and sd-card files to do an full setup by USB | |
# | |
# Package contents: | |
# - /firmware.bin | |
# - /partitions.bin | |
# - /bootloader.bin | |
# - sd-card.zip (Content for sd-card -> extract to root folder) | |
######################################################################################### | |
- name: Manual setup package - Prepare artifact | |
run: | | |
rm -rf manual_setup | |
mkdir -p manual_setup | |
rm -rf manual_setup/*.zip | |
# copy builds to manual_setup folder | |
cp -f "./code/.pio/build/${{ matrix.plat }}/firmware.bin" "manual_setup/firmware.bin" | |
cp -f "./code/.pio/build/${{ matrix.plat }}/bootloader.bin" "manual_setup/bootloader.bin" | |
cp -f "./code/.pio/build/${{ matrix.plat }}/partitions.bin" "manual_setup/partitions.bin" | |
rm -rf ./sd-card/html | |
cp -r ./html ./sd-card/ # Overwrite the Web UI with the preprocessed files | |
cd sd-card; zip -r ../manual_setup/sd-card.zip *; cd .. | |
- name: Manual setup package - Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "AI-on-the-edge-device__manual-setup__${{ matrix.plat }}__SLFork_${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
path: ./manual_setup | |
######################################################################################### | |
## Create package for initial 2-step setup (Remote Setup) | |
# 1. WebUpdater: Install firmware binary | |
# 2. ESP Access Point: Install SD-Card content | |
# | |
# Package contents: | |
# - /html/* | |
# - /config/* | |
######################################################################################### | |
- name: Remote setup package - Prepare artifact | |
run: | | |
rm -rf ./remote_setup | |
mkdir -p ./remote_setup | |
cp -r ./html ./remote_setup/ | |
rm -rf ./remote_setup/config/ | |
mkdir -p ./remote_setup/config/ | |
cp ./sd-card/config/* ./remote_setup/config/ 2>/dev/null || true | |
- name: Remote setup package - Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "AI-on-the-edge-device__remote-setup__${{ matrix.plat }}__SLFork_${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
path: ./remote_setup | |
######################################################################################### | |
## Create package with additional files for debugging purpose | |
# | |
# Package contents: | |
# - firmware.elf | |
# - sdkconfig.defaults | |
# - sdkconfig.${{ matrix.plat }} | |
######################################################################################### | |
- name: Debug files package - Prepare artifact | |
run: | | |
rm -rf ./debug | |
mkdir -p ./debug | |
cp -f "./code/.pio/build/${{ matrix.plat }}/firmware.elf" "debug/firmware.elf" | |
cp -f "./code/sdkconfig.${{ matrix.plat }}" "debug/sdkconfig.${{ matrix.plat }}" | |
- name: Debug files package - Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "AI-on-the-edge-device__debug-files__${{ matrix.plat }}__SLFork_${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
path: ./debug | |
######################################################################################### | |
## Create release - PART 2: Upload release related artifacts | |
# | |
# Artifacts will gets uploaded to newly created release tag. | |
######################################################################################### | |
upload-release-artifacts: | |
runs-on: ubuntu-latest | |
needs: [prepare-release, build] | |
if: ${{ needs.prepare-release.outputs.release_created }} | |
strategy: | |
fail-fast: false | |
matrix: | |
plat: | |
- esp32cam | |
- xiao-esp32s3-sense | |
- freenove-esp32s3 | |
# Sets permissions of the GITHUB_TOKEN to allow downloading artifacts | |
permissions: | |
actions: read | |
contents: write | |
steps: | |
- name: Checkout tag | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.prepare-release.outputs.tag_name }} | |
- name: Set variables | |
id: vars | |
run: | | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
echo "branch=$(echo ${{ github.ref_name }} | tr / __)" >> $GITHUB_OUTPUT | |
- name: Pull artifacts | |
uses: actions/download-artifact@v4 | |
- name: Prepare artifacts for release | |
run: | | |
rm -rf release | |
mkdir -p release | |
cd "AI-on-the-edge-device__update__${{ matrix.plat }}__SLFork_${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
zip -r ../release/${{ matrix.plat }}/AI-on-the-edge-device__update__${{ matrix.plat }}__SLFork_v${{ needs.prepare-release.outputs.version }}.zip * | |
cd .. | |
cd "AI-on-the-edge-device__manual-setup__${{ matrix.plat }}__SLFork_${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
zip -r ../release/${{ matrix.plat }}/AI-on-the-edge-device__manual-setup__${{ matrix.plat }}__SLFork_v${{ needs.prepare-release.outputs.version }}.zip * | |
cd .. | |
cd "AI-on-the-edge-device__remote-setup__${{ matrix.plat }}__SLFork_${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
zip -r ../release/${{ matrix.plat }}/AI-on-the-edge-device__remote-setup__${{ matrix.plat }}__SLFork_v${{ needs.prepare-release.outputs.version }}.zip * | |
cd .. | |
cd "AI-on-the-edge-device__debug-files__${{ matrix.plat }}__SLFork_${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
zip -r ../release/${{ matrix.plat }}/AI-on-the-edge-device__debug-files__${{ matrix.plat }}__SLFork_v${{ needs.prepare-release.outputs.version }}.zip * | |
cd .. | |
- name: Upload artifacts to release tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | |
gh release upload ${{ needs.prepare-release.outputs.tag_name }} release/* |