2025-02-19 01:19:42 +01:00
|
|
|
name: Gitea Release
|
|
|
|
|
|
|
|
on:
|
2025-02-19 10:24:43 +01:00
|
|
|
workflow_call:
|
2025-02-19 12:09:12 +01:00
|
|
|
inputs:
|
|
|
|
gitea_ref_name:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
gitea_server_url:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
gitea_repository:
|
|
|
|
required: true
|
|
|
|
type: string
|
2025-02-19 11:38:37 +01:00
|
|
|
secrets:
|
|
|
|
GITEA_TOKEN:
|
|
|
|
required: true
|
2025-02-19 01:19:42 +01:00
|
|
|
|
|
|
|
jobs:
|
2025-02-19 10:24:43 +01:00
|
|
|
create-release:
|
2025-02-19 09:39:41 +01:00
|
|
|
runs-on: ubuntu-latest
|
2025-02-19 01:19:42 +01:00
|
|
|
steps:
|
2025-02-20 15:41:14 +01:00
|
|
|
- uses: actions/checkout@v4
|
2025-02-20 15:53:22 +01:00
|
|
|
|
2025-02-20 15:41:14 +01:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: '3.x'
|
2025-02-20 15:53:22 +01:00
|
|
|
|
|
|
|
- name: Install PlatformIO
|
2025-02-19 11:58:26 +01:00
|
|
|
run: |
|
2025-02-20 15:41:14 +01:00
|
|
|
python -m pip install --upgrade pip
|
2025-02-20 16:14:49 +01:00
|
|
|
pip install --upgrade platformio esptool
|
2025-02-20 15:53:22 +01:00
|
|
|
|
2025-02-19 11:46:17 +01:00
|
|
|
- name: Build Firmware
|
2025-02-19 11:38:37 +01:00
|
|
|
run: |
|
2025-02-20 15:53:22 +01:00
|
|
|
pio run -t buildfs # Build SPIFFS
|
|
|
|
pio run # Build firmware
|
2025-02-20 15:07:13 +01:00
|
|
|
|
2025-02-20 16:14:49 +01:00
|
|
|
- name: Prepare binaries
|
2025-02-20 15:53:22 +01:00
|
|
|
run: |
|
2025-02-20 16:14:49 +01:00
|
|
|
cd .pio/build/esp32dev
|
2025-02-20 15:07:13 +01:00
|
|
|
|
2025-02-20 16:15:48 +01:00
|
|
|
# Create OTA binary (firmware only)
|
2025-02-20 16:14:49 +01:00
|
|
|
cp firmware.bin filaman_ota.bin
|
|
|
|
|
2025-02-20 16:15:48 +01:00
|
|
|
# Create basic flash layout
|
|
|
|
echo "Creating initial 4MB flash image..."
|
|
|
|
dd if=/dev/zero bs=1M count=4 of=flash_4mb.bin
|
|
|
|
|
|
|
|
# Create partition layout
|
|
|
|
echo "Writing bootloader..."
|
|
|
|
dd if=bootloader.bin of=flash_4mb.bin bs=1 seek=$((0x1000)) conv=notrunc
|
|
|
|
|
|
|
|
echo "Writing partitions..."
|
|
|
|
dd if=partitions.bin of=flash_4mb.bin bs=1 seek=$((0x8000)) conv=notrunc
|
2025-02-20 16:14:49 +01:00
|
|
|
|
2025-02-20 16:15:48 +01:00
|
|
|
echo "Writing firmware..."
|
|
|
|
dd if=firmware.bin of=flash_4mb.bin bs=1 seek=$((0x10000)) conv=notrunc
|
2025-02-20 16:14:49 +01:00
|
|
|
|
2025-02-20 16:15:48 +01:00
|
|
|
echo "Writing SPIFFS..."
|
|
|
|
dd if=spiffs.bin of=flash_4mb.bin bs=1 seek=$((0x3D0000)) conv=notrunc
|
2025-02-20 16:14:49 +01:00
|
|
|
|
2025-02-20 16:15:48 +01:00
|
|
|
# Rename to final name
|
|
|
|
cp flash_4mb.bin filaman_full.bin
|
|
|
|
|
|
|
|
# Verify file sizes and content
|
2025-02-20 16:14:49 +01:00
|
|
|
echo "File sizes:"
|
|
|
|
ls -lh *.bin
|
2025-02-20 16:15:48 +01:00
|
|
|
|
|
|
|
echo "Binary information:"
|
|
|
|
esptool.py --chip esp32 image_info filaman_ota.bin || true
|
|
|
|
echo "Full binary info:"
|
|
|
|
xxd -l 64 filaman_full.bin
|
2025-02-19 10:24:43 +01:00
|
|
|
|
2025-02-19 11:18:05 +01:00
|
|
|
- name: Create Release
|
2025-02-19 10:24:43 +01:00
|
|
|
env:
|
2025-02-19 11:38:37 +01:00
|
|
|
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
2025-02-19 09:39:41 +01:00
|
|
|
run: |
|
2025-02-20 15:41:14 +01:00
|
|
|
TAG="${{ inputs.gitea_ref_name }}"
|
|
|
|
API_URL="${{ inputs.gitea_server_url }}/api/v1"
|
|
|
|
REPO="${{ inputs.gitea_repository }}"
|
2025-02-19 10:07:41 +01:00
|
|
|
|
2025-02-19 11:46:17 +01:00
|
|
|
# Create release
|
|
|
|
RESPONSE=$(curl -k -s \
|
2025-02-19 11:18:05 +01:00
|
|
|
-X POST \
|
2025-02-19 11:38:37 +01:00
|
|
|
-H "Authorization: token ${TOKEN}" \
|
2025-02-19 10:24:43 +01:00
|
|
|
-H "Content-Type: application/json" \
|
2025-02-20 15:41:14 +01:00
|
|
|
-d "{
|
|
|
|
\"tag_name\":\"${TAG}\",
|
|
|
|
\"name\":\"Release ${TAG}\",
|
|
|
|
\"body\":\"${{ steps.changelog.outputs.CHANGES }}\"
|
|
|
|
}" \
|
2025-02-19 11:46:17 +01:00
|
|
|
"${API_URL}/repos/${REPO}/releases")
|
2025-02-19 10:37:41 +01:00
|
|
|
|
2025-02-19 11:38:37 +01:00
|
|
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n1)
|
2025-02-19 10:24:43 +01:00
|
|
|
|
2025-02-19 14:11:44 +01:00
|
|
|
if [ -n "$RELEASE_ID" ]; then
|
2025-02-19 11:18:05 +01:00
|
|
|
echo "Release created with ID: $RELEASE_ID"
|
2025-02-19 10:37:41 +01:00
|
|
|
|
2025-02-20 15:41:14 +01:00
|
|
|
# Upload binaries
|
2025-02-20 15:53:22 +01:00
|
|
|
cd .pio/build/esp32dev
|
2025-02-20 15:41:14 +01:00
|
|
|
for file in filaman_full.bin filaman_ota.bin; do
|
2025-02-19 11:18:05 +01:00
|
|
|
echo "Uploading $file..."
|
2025-02-19 11:46:17 +01:00
|
|
|
curl -k -s \
|
2025-02-19 11:18:05 +01:00
|
|
|
-X POST \
|
2025-02-19 11:38:37 +01:00
|
|
|
-H "Authorization: token ${TOKEN}" \
|
2025-02-19 11:18:05 +01:00
|
|
|
-H "Content-Type: application/octet-stream" \
|
2025-02-20 15:53:22 +01:00
|
|
|
--data-binary "@$file" \
|
2025-02-20 15:41:14 +01:00
|
|
|
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
|
2025-02-19 11:18:05 +01:00
|
|
|
done
|
|
|
|
else
|
2025-02-19 11:46:17 +01:00
|
|
|
echo "Failed to create release. Response:"
|
|
|
|
echo "$RESPONSE"
|
2025-02-19 11:18:05 +01:00
|
|
|
exit 1
|
|
|
|
fi
|