name: Gitea Release on: workflow_call: inputs: gitea_ref_name: required: true type: string gitea_server_url: required: true type: string gitea_repository: required: true type: string secrets: GITEA_TOKEN: required: true jobs: create-release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies run: | python -m pip install --upgrade pip pip install platformio esptool - name: Build Firmware run: | # Build SPIFFS first platformio run -t buildfs # Then build firmware platformio run - name: Prepare Release Files run: | cd .pio/build/esp32dev # Get bootloader BOOTLOADER_PATH=$(find ~/.platformio -name "bootloader_dio_40m.bin" | head -n 1) if [ ! -f "$BOOTLOADER_PATH" ]; then echo "Error: bootloader not found!" exit 1 fi echo "Using bootloader from: $BOOTLOADER_PATH" cp "$BOOTLOADER_PATH" bootloader.bin # Create OTA update binary (firmware only) cp firmware.bin filaman_ota.bin # Create full binary echo "Creating full binary..." esptool.py --chip esp32 merge_bin \ -o filaman_full.bin \ --flash_mode dio \ --flash_freq 40m \ --flash_size 4MB \ 0x1000 bootloader.bin \ 0x8000 partitions.bin \ 0x10000 firmware.bin \ 0x3D0000 spiffs.bin # Verify results echo "File sizes:" ls -l bootloader.bin partitions.bin firmware.bin spiffs.bin filaman_full.bin filaman_ota.bin echo "Firmware info:" esptool.py --chip esp32 image_info firmware.bin echo "Full binary first 16 bytes:" hexdump -C -n 16 filaman_full.bin - name: Read CHANGELOG.md id: changelog run: | VERSION=${GITHUB_REF_NAME#v} CHANGELOG=$(awk "/## \\[$VERSION\\]/{p=1;print;next} /## \\[/{p=0} p" CHANGELOG.md) echo "CHANGES<> $GITHUB_OUTPUT echo "$CHANGELOG" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - name: Create Release env: TOKEN: ${{ secrets.GITEA_TOKEN }} run: | TAG="${{ inputs.gitea_ref_name }}" API_URL="${{ inputs.gitea_server_url }}/api/v1" REPO="${{ inputs.gitea_repository }}" # Create release RESPONSE=$(curl -k -s \ -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ -d "{ \"tag_name\":\"${TAG}\", \"name\":\"Release ${TAG}\", \"body\":\"${{ steps.changelog.outputs.CHANGES }}\" }" \ "${API_URL}/repos/${REPO}/releases") RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n1) if [ -n "$RELEASE_ID" ]; then echo "Release created with ID: $RELEASE_ID" # Upload binaries for file in filaman_full.bin filaman_ota.bin; do echo "Uploading $file..." curl -k -s \ -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/octet-stream" \ --data-binary "@.pio/build/esp32dev/$file" \ "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file" done else echo "Failed to create release. Response:" echo "$RESPONSE" exit 1 fi