fix: switch OTA delivery to direct attached artifacts
Some checks failed
OTA build / build-ota (push) Failing after 1m22s
Some checks failed
OTA build / build-ota (push) Failing after 1m22s
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
name: OTA build
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
@@ -34,50 +30,29 @@ jobs:
|
||||
- name: Prepare direct OTA files
|
||||
run: |
|
||||
set -eu
|
||||
rm -rf dist/ota
|
||||
project_name="${GITHUB_REPOSITORY#*/}"
|
||||
project_name="${project_name#PlatformIO_}"
|
||||
timestamp="$(date -u +%Y-%m-%dT%H-%M-%SZ)"
|
||||
mkdir -p dist/ota
|
||||
found=0
|
||||
for fw in .pio/build/*/firmware.bin; do
|
||||
for fw in .pio/build/*/firmware.bin .pio/build/*/firmware.hex; do
|
||||
[ -f "$fw" ] || continue
|
||||
env_name="$(basename "$(dirname "$fw")")"
|
||||
cp "$fw" "dist/ota/${project_name}_${env_name}_${timestamp}.bin"
|
||||
ext="${fw##*.}"
|
||||
cp "$fw" "dist/ota/${project_name}_${env_name}_${timestamp}.${ext}"
|
||||
found=1
|
||||
done
|
||||
if [ "$found" -eq 0 ]; then
|
||||
echo 'No firmware.bin artifacts were produced.' >&2
|
||||
echo 'No firmware.bin or firmware.hex artifacts were 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
|
||||
- name: Upload direct OTA files as artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ota-files
|
||||
path: dist/ota/*
|
||||
if-no-files-found: error
|
||||
archive: false
|
||||
|
||||
Reference in New Issue
Block a user