45 lines
1.4 KiB
YAML
45 lines
1.4 KiB
YAML
name: Build Release
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install PlatformIO
|
|
run: pip install platformio
|
|
|
|
- name: Build firmware
|
|
run: pio run
|
|
|
|
- name: Upload firmware.bin to release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
set -e
|
|
API="http://192.168.0.37:3000/api/v1/repos/rasmus/flyradar"
|
|
TAG="${GITHUB_REF_NAME}"
|
|
echo "Fetching release for tag $TAG ..."
|
|
RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
|
"$API/releases/tags/$TAG")
|
|
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
|
|
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
|
echo "Error: could not find release for tag $TAG"
|
|
echo "Response: $RELEASE_JSON"
|
|
exit 1
|
|
fi
|
|
echo "Uploading to release ID $RELEASE_ID ..."
|
|
curl -s -H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary @.pio/build/esp32dev/firmware.bin \
|
|
"$API/releases/$RELEASE_ID/assets?name=firmware.bin"
|
|
echo ""
|
|
echo "Upload complete." |