Files
MTGcompanion/.gitea/workflows/releases.yml
Rasmus d7a108463d
Some checks failed
ESP32 Build & Release / build (push) Failing after 4s
ci: use espressif/idf:v5.5 container image to eliminate cache timeout
2026-09-12 15:21:42 +02:00

143 lines
4.5 KiB
YAML

name: ESP32 Build & Release
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
container:
image: espressif/idf:v5.5
steps:
# ------------------------------------------------------------
# Checkout
# ------------------------------------------------------------
- name: Checkout
uses: actions/checkout@v4
- name: Configure Git Safe Directory
shell: bash
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE" || true
# ------------------------------------------------------------
# Build firmware & merged binary
# ------------------------------------------------------------
- name: Build firmware
shell: bash
run: |
. /opt/esp/idf/export.sh
idf.py --version
idf.py set-target esp32
idf.py build
idf.py merge-bin
# ------------------------------------------------------------
# Prepare release artifacts
# ------------------------------------------------------------
# ------------------------------------------------------------
# Prepare release artifacts & calculate hashes
# ------------------------------------------------------------
- name: Prepare release
shell: bash
run: |
mkdir -p release
# Primary OTA application binary
if [ -f build/mtg-rfid-companion.bin ]; then
cp build/mtg-rfid-companion.bin release/mtg-rfid-companion.bin
cp build/mtg-rfid-companion.bin release/firmware.bin
else
echo "ERROR: build/mtg-rfid-companion.bin not found!"
exit 1
fi
# Merged binary for USB factory flashing
if [ -f build/merged-binary.bin ]; then
cp build/merged-binary.bin release/merged-firmware.bin
fi
# ELF for debugging
find build -maxdepth 1 -type f -name "*.elf" -exec cp {} release/ \;
# Calculate hashes
BIN_SHA256=$(sha256sum release/mtg-rfid-companion.bin | awk '{print $1}')
IMG_SHA256=$(python3 -c "with open('release/mtg-rfid-companion.bin','rb') as f: f.seek(-32,2); print(f.read().hex())")
echo "BIN_SHA256=${BIN_SHA256}" >> $GITHUB_ENV
echo "IMG_SHA256=${IMG_SHA256}" >> $GITHUB_ENV
echo "Firmware SHA256: ${BIN_SHA256}" > release/firmware.sha256
echo "Image SHA256: ${IMG_SHA256}" >> release/firmware.sha256
echo "Commit: ${{ github.sha }}" >> release/firmware.sha256
echo "OTA Release prepared:"
echo " Binary: release/mtg-rfid-companion.bin"
echo " File SHA-256: ${BIN_SHA256}"
echo " Image SHA-256: ${IMG_SHA256}"
ls -lh release/
# ------------------------------------------------------------
# Delete existing "latest" release
# ------------------------------------------------------------
- name: Delete existing latest release
shell: bash
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
API="${{ github.server_url }}/api/v1"
echo "Removing existing latest release..."
curl -fsSL \
-X DELETE \
-H "Authorization: token ${GITEA_TOKEN}" \
"${API}/repos/${{ github.repository }}/releases/tags/latest" \
|| true
# Delete the tag as well
curl -fsSL \
-X DELETE \
-H "Authorization: token ${GITEA_TOKEN}" \
"${API}/repos/${{ github.repository }}/tags/latest" \
|| true
# ------------------------------------------------------------
# Create latest release
# ------------------------------------------------------------
- name: Create latest release
uses: akkuman/gitea-release-action@v1
with:
server_url: ${{ github.server_url }}
repository: ${{ github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: latest
name: "Latest ESP32 Firmware"
body: |
Automatically built from the `main` branch.
Commit:
${{ github.sha }}
SHA256:
${{ env.IMG_SHA256 }}
File-SHA256:
${{ env.BIN_SHA256 }}
ESP-IDF:
5.5
Target:
ESP32
This release is automatically replaced on every push to `main`.
files: |
release/*