Build frozen firmware #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/build-firmware.yml | |
| name: Build frozen firmware | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| micropython_ref: | |
| description: "MicroPython git tag/branch to build from" | |
| type: string | |
| default: "v1.28.0" | |
| push: | |
| tags: ["v*.*.*"] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| role: [student, helper] | |
| env: | |
| MICROPYTHON_REF: ${{ inputs.micropython_ref || 'v1.28.0' }} | |
| BOARD: RPI_PICO2 | |
| steps: | |
| - name: Checkout alpaca | |
| uses: actions/checkout@v4 | |
| with: | |
| path: alpaca-src | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| working-directory: alpaca-src | |
| - name: Collect ${{ matrix.role }} files | |
| working-directory: alpaca-src | |
| run: uv run alpaca collect-files ${{ matrix.role }} | |
| - name: Checkout MicroPython | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: micropython/micropython | |
| ref: ${{ env.MICROPYTHON_REF }} | |
| path: micropython | |
| submodules: false | |
| - name: Install ARM toolchain | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential cmake ninja-build \ | |
| gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib | |
| - name: Build mpy-cross | |
| run: make -C micropython/mpy-cross | |
| - name: Fetch rp2 submodules | |
| run: make -C micropython/ports/rp2 BOARD="$BOARD" submodules | |
| - name: Write freeze manifest | |
| run: | | |
| ROOT="$GITHUB_WORKSPACE/alpaca-src/.alpaca/${{ matrix.role }}_root" | |
| cat > "$GITHUB_WORKSPACE/manifest.py" <<EOF | |
| # Auto-generated by build-firmware.yml | |
| include("\$(PORT_DIR)/boards/manifest.py") | |
| freeze("$ROOT") | |
| EOF | |
| echo "----- manifest.py -----" | |
| cat "$GITHUB_WORKSPACE/manifest.py" | |
| echo "----- frozen root -----" | |
| find "$ROOT" -type f | sort | |
| - name: Build firmware | |
| run: | | |
| make -C micropython/ports/rp2 \ | |
| BOARD="$BOARD" \ | |
| FROZEN_MANIFEST="$GITHUB_WORKSPACE/manifest.py" | |
| - name: Stage artifact | |
| run: | | |
| mkdir -p dist | |
| VERSION="$(cd alpaca-src && uv run python -c 'import importlib.metadata as m; print(m.version("alpaca"))')" | |
| SRC="micropython/ports/rp2/build-$BOARD/firmware.uf2" | |
| DEST="dist/alpaca-${{ matrix.role }}-${BOARD}-v${VERSION}-mp${MICROPYTHON_REF}.uf2" | |
| cp "$SRC" "$DEST" | |
| echo "Built $DEST" | |
| ls -la dist | |
| - name: Upload firmware | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: alpaca-${{ matrix.role }}-firmware | |
| path: dist/*.uf2 | |
| if-no-files-found: error |