mirror of
https://github.com/m5stack/CardputerZero-AppBuilder.git
synced 2026-05-20 11:51:57 -07:00
Migrate all files from M5Stack-AppBuilder
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
eggfly
co-authored by
Claude Opus 4.6
parent
e2f791c30a
commit
39158de976
@@ -0,0 +1,164 @@
|
||||
name: Build DEB Package
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
repo_url:
|
||||
description: "Git repository URL (HTTP, e.g. https://github.com/eggfly/M5CardputerZero-UserDemo.git)"
|
||||
required: true
|
||||
type: string
|
||||
branch:
|
||||
description: "Branch (leave empty for default branch)"
|
||||
required: false
|
||||
default: ""
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
discover:
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
projects: ${{ steps.scan.outputs.projects }}
|
||||
steps:
|
||||
- name: Checkout AppBuilder
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Clone user repository
|
||||
run: |
|
||||
BRANCH="${{ inputs.branch }}"
|
||||
if [ -z "$BRANCH" ]; then
|
||||
git clone --recursive --depth=1 "${{ inputs.repo_url }}" /tmp/user-repo
|
||||
else
|
||||
git clone --recursive --depth=1 -b "$BRANCH" "${{ inputs.repo_url }}" /tmp/user-repo
|
||||
fi
|
||||
|
||||
- name: Scan for app-builder.json
|
||||
id: scan
|
||||
run: |
|
||||
python3 scripts/discover_projects.py /tmp/user-repo
|
||||
|
||||
build:
|
||||
needs: discover
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
project: ${{ fromJson(needs.discover.outputs.projects) }}
|
||||
|
||||
steps:
|
||||
- name: Checkout AppBuilder
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache apt packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/apt-cache
|
||||
key: apt-aarch64-cross-v1
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
if [ -d ~/apt-cache ] && [ "$(ls ~/apt-cache/*.deb 2>/dev/null | wc -l)" -gt 0 ]; then
|
||||
echo "Restoring apt cache..."
|
||||
sudo cp ~/apt-cache/*.deb /var/cache/apt/archives/ 2>/dev/null || true
|
||||
fi
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
python3 python3-pip \
|
||||
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
|
||||
dpkg-dev \
|
||||
libffi-dev
|
||||
pip3 install parse scons requests tqdm
|
||||
mkdir -p ~/apt-cache
|
||||
cp /var/cache/apt/archives/*.deb ~/apt-cache/ 2>/dev/null || true
|
||||
|
||||
- name: Clone user repository
|
||||
run: |
|
||||
BRANCH="${{ inputs.branch }}"
|
||||
if [ -z "$BRANCH" ]; then
|
||||
git clone --recursive --depth=1 "${{ inputs.repo_url }}" /tmp/user-repo
|
||||
else
|
||||
git clone --recursive --depth=1 -b "$BRANCH" "${{ inputs.repo_url }}" /tmp/user-repo
|
||||
fi
|
||||
|
||||
- name: Compute cache keys
|
||||
id: cache-keys
|
||||
working-directory: /tmp/user-repo
|
||||
run: |
|
||||
CONFIG_HASH=$(sha256sum "${{ matrix.project.path }}/config_defaults.mk" | cut -c1-16)
|
||||
echo "config_hash=$CONFIG_HASH" >> "$GITHUB_OUTPUT"
|
||||
|
||||
SDK_COMMIT=$(git -C SDK rev-parse HEAD 2>/dev/null || echo "no-sdk")
|
||||
echo "sdk_commit=$SDK_COMMIT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
LVGL_COMMIT=$(grep -oP "git_commit\s*=\s*'[a-f0-9]+'" SDK/components/lvgl_component/SConstruct | tail -1 | grep -oP "[a-f0-9]{40}" || echo "unknown")
|
||||
echo "lvgl_commit=$LVGL_COMMIT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Cache LVGL source
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /tmp/user-repo/SDK/github_source/lvgl
|
||||
key: lvgl-src-${{ steps.cache-keys.outputs.lvgl_commit }}
|
||||
|
||||
- name: Cache static_lib BSP
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /tmp/user-repo/${{ matrix.project.path }}/static_lib
|
||||
key: static-lib-${{ matrix.project.path }}-${{ steps.cache-keys.outputs.sdk_commit }}
|
||||
|
||||
- name: Cache SCons build objects
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /tmp/user-repo/${{ matrix.project.path }}/build
|
||||
key: scons-${{ matrix.project.path }}-${{ steps.cache-keys.outputs.config_hash }}-${{ steps.cache-keys.outputs.sdk_commit }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
scons-${{ matrix.project.path }}-${{ steps.cache-keys.outputs.config_hash }}-${{ steps.cache-keys.outputs.sdk_commit }}-
|
||||
|
||||
- name: Build ${{ matrix.project.app_name }}
|
||||
working-directory: /tmp/user-repo/${{ matrix.project.path }}
|
||||
env:
|
||||
CardputerZero: "y"
|
||||
CONFIG_REPO_AUTOMATION: "y"
|
||||
run: |
|
||||
scons -j$(nproc)
|
||||
|
||||
- name: Package DEB
|
||||
run: |
|
||||
python3 scripts/pack_deb.py \
|
||||
--package-name "${{ matrix.project.package_name }}" \
|
||||
--version "${{ matrix.project.version }}" \
|
||||
--bin-name "${{ matrix.project.bin_name }}" \
|
||||
--app-name "${{ matrix.project.app_name }}" \
|
||||
--src-folder "/tmp/user-repo/${{ matrix.project.path }}/dist" \
|
||||
--output-dir /tmp/deb-output
|
||||
|
||||
- name: Upload DEB artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.project.package_name }}_${{ matrix.project.version }}_arm64
|
||||
path: /tmp/deb-output/*.deb
|
||||
retention-days: 90
|
||||
|
||||
- name: Job summary
|
||||
run: |
|
||||
DEB_FILE=$(ls /tmp/deb-output/*.deb | head -1)
|
||||
DEB_NAME=$(basename "$DEB_FILE")
|
||||
DEB_SIZE=$(du -h "$DEB_FILE" | cut -f1)
|
||||
cat >> "$GITHUB_STEP_SUMMARY" << EOF
|
||||
## ${{ matrix.project.app_name }}
|
||||
|
||||
| Item | Value |
|
||||
|------|-------|
|
||||
| Package | \`${DEB_NAME}\` |
|
||||
| Size | ${DEB_SIZE} |
|
||||
| Project path | \`${{ matrix.project.path }}\` |
|
||||
| Architecture | arm64 (aarch64 cross-compiled) |
|
||||
|
||||
### Install on device
|
||||
\`\`\`bash
|
||||
scp ${DEB_NAME} pi@<device-ip>:/tmp/
|
||||
ssh pi@<device-ip> "sudo dpkg -i /tmp/${DEB_NAME}"
|
||||
\`\`\`
|
||||
EOF
|
||||
Reference in New Issue
Block a user