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-20 18:01:16 +01:00
|
|
|
- name: Install xxd
|
2025-02-20 18:04:00 +01:00
|
|
|
run: |
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install xxd
|
2025-02-20 18:01:16 +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 17:11:22 +01:00
|
|
|
pio run -e esp32dev_ota -t buildfs # Build SPIFFS
|
|
|
|
pio run -e esp32dev_ota # Build firmware
|
|
|
|
cp .pio/build/esp32dev_ota/firmware.bin .pio/build/esp32dev_ota/filaman.bin
|
|
|
|
cp .pio/build/esp32dev_ota/spiffs.bin .pio/build/esp32dev_ota/filaman_spiffs.bin
|
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 17:11:22 +01:00
|
|
|
cd .pio/build/esp32dev_ota
|
2025-02-20 15:07:13 +01:00
|
|
|
|
2025-02-20 17:52:18 +01:00
|
|
|
# Create OTA binary (already has correct magic byte)
|
2025-02-20 16:14:49 +01:00
|
|
|
cp firmware.bin filaman_ota.bin
|
|
|
|
|
2025-02-20 17:52:18 +01:00
|
|
|
# Create a magic byte prepended binary for the bootloader
|
|
|
|
echo -ne '\xE9' > bootloader_with_magic.bin
|
|
|
|
cat bootloader.bin >> bootloader_with_magic.bin
|
|
|
|
|
|
|
|
echo "Creating full binary with magic byte..."
|
2025-02-20 16:24:57 +01:00
|
|
|
esptool.py --chip esp32 merge_bin \
|
2025-02-20 17:52:18 +01:00
|
|
|
--fill-flash-size 4MB \
|
2025-02-20 16:24:57 +01:00
|
|
|
--flash_mode dio \
|
|
|
|
--flash_freq 40m \
|
|
|
|
--flash_size 4MB \
|
|
|
|
-o filaman_full.bin \
|
2025-02-20 17:52:18 +01:00
|
|
|
0x0000 bootloader_with_magic.bin \
|
2025-02-20 16:24:57 +01:00
|
|
|
0x8000 partitions.bin \
|
|
|
|
0x10000 firmware.bin \
|
2025-02-20 19:09:28 +01:00
|
|
|
0x390000 spiffs.bin
|
2025-02-20 16:15:48 +01:00
|
|
|
|
2025-02-20 17:52:18 +01:00
|
|
|
# Verify magic bytes
|
|
|
|
echo "Checking magic bytes:"
|
|
|
|
echo "Full binary first bytes:"
|
2025-02-20 18:01:16 +01:00
|
|
|
xxd -l 16 filaman_full.bin
|
2025-02-20 17:52:18 +01:00
|
|
|
|
|
|
|
# Verify file sizes
|
2025-02-20 16:14:49 +01:00
|
|
|
echo "File sizes:"
|
|
|
|
ls -lh *.bin
|
2025-02-20 16:15:48 +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 17:11:22 +01:00
|
|
|
cd .pio/build/esp32dev_ota
|
2025-02-20 18:37:51 +01:00
|
|
|
for file in filaman_full.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
|