Skip to content

Build and Release ESP32 Firmware #283

Build and Release ESP32 Firmware

Build and Release ESP32 Firmware #283

Workflow file for this run

name: Build and Release ESP32 Firmware
on:
workflow_dispatch: # Manual trigger only
jobs:
build-and-release:
runs-on: ubuntu-latest
env:
RCLONE_CONF: ${{ secrets.RCLONE_CONF }}
strategy:
matrix:
include:
- board: NERDQAXEPLUS
upload_www: true
label: NerdQAxe+
- board: NERDOCTAXEPLUS
upload_www: false
label: NerdOCTAXE+
- board: NERDQAXEPLUS2
upload_www: false
label: NerdQAxe++
- board: NERDAXE
upload_www: false
label: NerdAxe
- board: NERDOCTAXEGAMMA
upload_www: false
label: NerdOCTAXE-Gamma
- board: NERDAXEGAMMA
upload_www: false
label: NerdAxeGamma
- board: NERDHAXEGAMMA
upload_www: false
label: NerdHaxe-Gamma
- board: NERDEKO
upload_www: false
label: NerdEKO
- board: NERDQX
upload_www: false
label: NerdQX
- board: Q1370
upload_www: false
label: Q1370
- board: Q1373
upload_www: false
label: Q1373
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Get Version Tag
id: version_tag
run: |
git fetch --tags # Ensure all tags are fetched
version=$(git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD)
echo "VERSION_TAG=${version}" >> $GITHUB_ENV
echo "${version}" > version.txt
echo "VERSION_TAG=${version}"
- name: Install GitHub CLI
run: |
sudo apt-get update -y
sudo apt-get install -y gh
- name: Check if release exists
id: check_release
run: |
if gh release view "${{ env.VERSION_TAG }}" >/dev/null 2>&1; then
echo "RELEASE_EXISTS=true" >> $GITHUB_ENV
else
echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Insert Version
run: |
#!/bin/bash
set -e
COMMIT_HASH=$(git rev-parse --short HEAD)
sed -e "s|__COMMIT__|${COMMIT_HASH}|g" -i ./main/http_server/axe-os/src/app/app.module.ts
sed -e "s|__VERSION__|${VERSION_TAG}|g" -i ./main/http_server/axe-os/src/app/app.module.ts
for l in de en es fr it pl ro; do
mv "./main/http_server/axe-os/src/assets/i18n/${l}.json" "./main/http_server/axe-os/src/assets/i18n/${l}.${COMMIT_HASH}.json"
done
- name: Set Target
run: |
# Run the Docker container to set ESP32-S3 target
docker run --rm --user root -e BOARD=${{ matrix.board }} -v $PWD:/home/builder/project \
shufps/esp-idf-builder:0.0.1 idf.py set-target esp32s3
- name: Compile Binaries
run: |
# Run the Docker container to build the project
docker run --rm --user root -e BOARD=${{ matrix.board }} -v $PWD:/home/builder/project \
shufps/esp-idf-builder:0.0.1 idf.py build
- name: Merge Binaries
run: |
docker run --rm --user root -v $PWD:/home/builder/project \
shufps/esp-idf-builder:0.0.1 esptool.py --chip esp32s3 merge_bin --flash_mode dio --flash_size 16MB --flash_freq 80m \
0x0 build/bootloader/bootloader.bin \
0x8000 build/partition_table/partition-table.bin \
0x10000 build/esp-miner.bin \
0x410000 build/www.bin \
0xf10000 build/ota_data_initial.bin \
-o esp-miner-factory-${{ matrix.label }}-${{ env.VERSION_TAG }}.bin
- name: Rename Build Artifacts
run: |
sudo mv build/esp-miner.bin build/esp-miner-${{ matrix.label }}.bin
sudo mv build/esp-miner.elf build/esp-miner-${{ matrix.label }}.elf
- name: Upload factory binary
if: env.RELEASE_EXISTS == 'false'
uses: actions/upload-artifact@v4
with:
name: esp-miner-factory-${{ matrix.label }}-${{ env.VERSION_TAG }}.bin
path: esp-miner-factory-${{ matrix.label }}-${{ env.VERSION_TAG }}.bin
retention-days: 7
- name: Upload BIN firmware
if: env.RELEASE_EXISTS == 'false'
uses: actions/upload-artifact@v4
with:
name: esp-miner-${{ matrix.label }}.bin
path: build/esp-miner-${{ matrix.label }}.bin
retention-days: 7
- name: Upload www.bin (only once)
if: env.RELEASE_EXISTS == 'false' && matrix.board == 'NERDQAXEPLUS'
uses: actions/upload-artifact@v4
with:
name: www.bin
path: build/www.bin
retention-days: 7
- name: Create files list
run: |
echo "esp-miner-factory-${{ matrix.label }}-${{ env.VERSION_TAG }}.bin" > file_list.txt
echo "build/esp-miner-${{ matrix.label }}.bin" >> file_list.txt
echo "build/esp-miner-${{ matrix.label }}.elf" >> file_list.txt
if [ "${{ matrix.upload_www }}" == "true" ]; then
echo "build/www.bin" >> file_list.txt
fi
- name: Set files variable
id: set_files_var
run: |
echo "files=$(grep -v '\.elf$' file_list.txt | tr '\n' ',')" >> $GITHUB_ENV
echo "r2_files=$(cat file_list.txt | tr '\n' ',')" >> $GITHUB_ENV
# Skip release upload if no release exists
- name: Skip release upload if not tagged
if: env.RELEASE_EXISTS == 'false'
run: echo "No GitHub release found for '${{ env.VERSION_TAG }}' — skipping release upload."
- name: Upload to Existing Release
if: env.RELEASE_EXISTS == 'true'
uses: softprops/action-gh-release@v1
with:
files: ${{ env.files }}
tag_name: ${{ env.VERSION_TAG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install rclone
if: env.RCLONE_CONF != ''
run: |
curl -fsSL https://rclone.org/install.sh | sudo bash
- name: Upload to Cloudflare R2 using rclone
if: env.RCLONE_CONF != ''
run: |
mkdir -p ~/.config/rclone
echo "$RCLONE_CONF" > ~/.config/rclone/rclone.conf
TARGET_DIR="webflasher/${{ env.VERSION_TAG }}"
echo "$r2_files" | tr ',' '\n' | grep -v '^$' | while read file; do
rclone copyto "$file" "r2:${TARGET_DIR}/$(basename "$file")" --s3-acl public-read
done