Skip to content

Extract Protos

Extract Protos #17

name: Extract Protos
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Runs at 00:00 on Sunday
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: 'recursive'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10'
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: 'stable'
- name: Install apkeep
run: cargo install apkeep
- name: Download APK (direct URL, fallback to apkeep)
shell: bash
run: |
set -euo pipefail
mkdir -p downloads
if curl -L --fail --retry 5 --retry-delay 2 --connect-timeout 20 --max-time 600 -o downloads/app-release.apk "https://ecoflow-service-us-cdn.ecoflow.com/apk/app-release.apk"; then
echo "Downloaded from EcoFlow CDN"
ls -lh downloads/app-release.apk
exit 0
fi
echo "Direct download failed; falling back to apkeep"
apkeep -a com.ecoflow downloads
ls -lh downloads
- name: Export file descriptor set from APK
run: |
fileName="$(ls -1 downloads | head -n 1)"
if [ -z "$fileName" ]; then
echo "No file downloaded into ./downloads"
exit 1
fi
if [ "$(ls -1 downloads | wc -l)" -ne 1 ]; then
echo "Expected exactly 1 file in ./downloads, got:"
ls -la downloads
exit 1
fi
dotnet run --project src/EcoFlow.Exporter.Protos -i "downloads/$fileName" -o file_descriptor_set.pb
- name: Generate protos from descriptor set
run: |
rm -rf protos
cd src/EcoFlow.Proto.Decoder
go mod tidy
go run . ../../file_descriptor_set.pb ../../protos
- name: Commit protos back to current branch
run: |
if [ -z "${GITHUB_REF_NAME}" ]; then
echo "GITHUB_REF_NAME is empty"
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add protos
if git diff --cached --quiet; then
echo "No changes in protos to commit"
exit 0
fi
git commit -m "Update protos"
git push origin "HEAD:${GITHUB_REF_NAME}"