name: Build and Package Firmware on: push: tags: - 'v*' jobs: build: runs-on: ubuntu-latest container: espressif/idf:v5.2.1 permissions: contents: write steps: - name: Install Modern Node.js and jq (Gitea Compatibility) run: apt-get update && apt-get install -y ca-certificates curl gnupg jq && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs - name: Checkout Repository uses: actions/checkout@v4 with: submodules: recursive - name: Configure Safe Directory run: git config --global --add safe.directory "*" - name: Set Version Identifier run: | TAG=${GITHUB_REF#refs/tags/} echo "TAG=$TAG" >> $GITHUB_ENV echo "$TAG" > version.txt echo "Build version (tag): $TAG" - name: Build and Run Host Unit Tests run: . $IDF_PATH/export.sh && cmake -S tests -B tests/build && cmake --build tests/build && ./tests/build/test_decoder - name: Build Firmware run: . $IDF_PATH/export.sh && idf.py build - name: Create Flashing Instructions Document run: | mkdir -p dist && cat << 'EOF' > dist/README_FLASHING.txt ESP32 ALDL Bridge Firmware Flash Instructions ============================================= Prerequisites: - Python 3 installed - esptool installed: pip install esptool Connect your ESP32 to your PC, identify its serial port, and run the following command to flash: esptool.py --chip esp32 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 2MB --flash_freq 40m 0x1000 bootloader.bin 0x8000 partition-table.bin 0x10000 esp32-aldl.bin EOF - name: Stage Firmware Binaries run: cp build/esp32-aldl.bin dist/ && cp build/bootloader/bootloader.bin dist/ && cp build/partition_table/partition-table.bin dist/ - name: Package Release run: | echo "Packaging with TAG: $TAG" tar -czvf "esp32-aldl-${TAG}.tar.gz" -C dist . - name: Upload Firmware Package uses: actions/upload-artifact@v4 with: name: esp32-aldl-firmware-${{ github.sha }} path: esp32-aldl-*.tar.gz if-no-files-found: error - name: Create Release and Upload Asset env: TOKEN: ${{ secrets.GITHUB_TOKEN }} API_URL: ${{ github.api_url }} REPO: ${{ github.repository }} TAG: ${{ env.TAG }} run: | FILE="esp32-aldl-${TAG}.tar.gz" NAME="${TAG}" echo "Creating release with FILE: $FILE, NAME: $NAME" # 1. Create the release RESP=$(curl -s -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"$NAME\",\"body\":\"Release $TAG\"}" \ "$API_URL/repos/$REPO/releases") # 2. Extract upload endpoint UPLOAD_URL=$(echo "$RESP" | jq -r '.upload_url // empty') RELEASE_ID=$(echo "$RESP" | jq -r '.id // empty') # 3. Upload asset if [ -n "$UPLOAD_URL" ]; then # GitHub style (upload_url contains {?name,label}) UPLOAD_URL="${UPLOAD_URL%\{?name,label\}}" curl -s -H "Authorization: token $TOKEN" \ -H "Content-Type: application/gzip" \ --data-binary @$FILE \ "${UPLOAD_URL}?name=${FILE}" elif [ -n "$RELEASE_ID" ]; then # Gitea style (POST to /releases/{id}/assets) curl -s -H "Authorization: token $TOKEN" \ -H "Content-Type: application/gzip" \ --data-binary @$FILE \ "$API_URL/repos/$REPO/releases/$RELEASE_ID/assets?name=${FILE}" else echo "Failed to create release" echo "$RESP" exit 1 fi