name: Gitea Release on: workflow_call: secrets: GITEA_TOKEN: required: true jobs: create-release: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Install Build Dependencies run: | # Add PlatformIO repository curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules sudo curl -fsSL -o /etc/apt/trusted.gpg.d/platformio.gpg https://github.com/platformio/platformio-core/releases/download/v6.1.11/platformio-keyring.gpg echo "deb https://github.com/platformio/platformio-core/releases/download/v6.1.11/ any/" | sudo tee /etc/apt/sources.list.d/platformio.list # Install dependencies sudo apt-get update sudo apt-get install -y platformio-core python3-pip build-essential # Install esptool sudo pip3 install esptool==4.5.1 echo "Verifying installations:" pio --version python3 --version esptool.py version - name: Build Firmware run: | # Initialize project pio project init --board esp32dev echo "Building SPIFFS..." pio run -t buildfs -v echo "Building firmware..." pio run -v - name: Create Release Files run: | echo "Creating release files..." esptool.py --chip esp32 merge_bin \ --flash_mode dio \ --flash_freq 40m \ --flash_size 4MB \ -o .pio/build/esp32dev/filaman_full.bin \ 0x1000 .pio/build/esp32dev/bootloader.bin \ 0x8000 .pio/build/esp32dev/partitions.bin \ 0x10000 .pio/build/esp32dev/firmware.bin \ 0x290000 .pio/build/esp32dev/spiffs.bin cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_ota.bin - name: Create Release env: TOKEN: ${{ secrets.GITEA_TOKEN }} run: | TAG="${GITEA_REF_NAME}" API_URL="${GITEA_SERVER_URL}/api/v1" REPO="${GITEA_REPOSITORY}" echo "Debug environment:" echo "TAG: ${TAG}" echo "API_URL: ${API_URL}" echo "REPO: ${REPO}" echo "Creating release for ${TAG} on ${REPO}..." # Create release RESPONSE=$(curl -k -s \ -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${TAG}\"}" \ "${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 files 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