80 lines
2.5 KiB
YAML
80 lines
2.5 KiB
YAML
name: OTA build
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-ota:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install PlatformIO
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install platformio
|
|
|
|
- name: Build filesystem-aware OTA package
|
|
run: python scripts/build_ota_package.py
|
|
|
|
- name: Prepare direct OTA files
|
|
run: |
|
|
set -eu
|
|
mkdir -p dist/ota
|
|
count=0
|
|
for file in dist/*.tslpkg; do
|
|
[ -f "$file" ] || continue
|
|
cp "$file" dist/ota/
|
|
count=$((count+1))
|
|
done
|
|
if [ "$count" -eq 0 ]; then
|
|
echo 'No .tslpkg OTA package was produced.' >&2
|
|
exit 1
|
|
fi
|
|
find dist/ota -maxdepth 1 -type f | sort
|
|
|
|
- name: Upload direct OTA files to Gitea Packages
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
set -eu
|
|
package_name="$(printf '%s' "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')-ota"
|
|
package_version="${GITHUB_SHA}"
|
|
base_url="${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/${package_name}/${package_version}"
|
|
for file in dist/ota/*; do
|
|
[ -f "$file" ] || continue
|
|
curl --fail --silent --show-error --user "${GITHUB_ACTOR}:${GITEA_TOKEN}" --upload-file "$file" "${base_url}/$(basename "$file")"
|
|
echo "Uploaded $(basename "$file")"
|
|
done
|
|
|
|
- name: Verify uploaded OTA files
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
set -eu
|
|
package_name="$(printf '%s' "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')-ota"
|
|
package_version="${GITHUB_SHA}"
|
|
curl --fail --silent --show-error --user "${GITHUB_ACTOR}:${GITEA_TOKEN}" "${GITHUB_SERVER_URL}/api/v1/packages/${GITHUB_REPOSITORY_OWNER}/generic/${package_name}/${package_version}/files" > /tmp/package-files.json
|
|
python3 - <<'PY'
|
|
import json
|
|
from pathlib import Path
|
|
files=json.loads(Path('/tmp/package-files.json').read_text())
|
|
assert files, 'no package files returned'
|
|
for item in files:
|
|
print(item.get('name') or item.get('file_name') or item)
|
|
PY
|