fix: switch OTA delivery to direct attached artifacts
Some checks failed
OTA build / build-ota (push) Failing after 2m35s
Some checks failed
OTA build / build-ota (push) Failing after 2m35s
This commit is contained in:
@@ -1,9 +1,5 @@
|
|||||||
name: OTA build
|
name: OTA build
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -34,50 +30,29 @@ jobs:
|
|||||||
- name: Prepare direct OTA files
|
- name: Prepare direct OTA files
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
|
rm -rf dist/ota
|
||||||
project_name="${GITHUB_REPOSITORY#*/}"
|
project_name="${GITHUB_REPOSITORY#*/}"
|
||||||
project_name="${project_name#PlatformIO_}"
|
project_name="${project_name#PlatformIO_}"
|
||||||
timestamp="$(date -u +%Y-%m-%dT%H-%M-%SZ)"
|
timestamp="$(date -u +%Y-%m-%dT%H-%M-%SZ)"
|
||||||
mkdir -p dist/ota
|
mkdir -p dist/ota
|
||||||
found=0
|
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
|
[ -f "$fw" ] || continue
|
||||||
env_name="$(basename "$(dirname "$fw")")"
|
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
|
found=1
|
||||||
done
|
done
|
||||||
if [ "$found" -eq 0 ]; then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
find dist/ota -maxdepth 1 -type f | sort
|
find dist/ota -maxdepth 1 -type f | sort
|
||||||
|
|
||||||
- name: Upload direct OTA files to Gitea Packages
|
- name: Upload direct OTA files as artifacts
|
||||||
env:
|
uses: actions/upload-artifact@v7
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
with:
|
||||||
run: |
|
name: ota-files
|
||||||
set -eu
|
path: dist/ota/*
|
||||||
package_name="$(printf '%s' "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')-ota"
|
if-no-files-found: error
|
||||||
package_version="${GITHUB_SHA}"
|
archive: false
|
||||||
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user