Include license files in firmware zip files. #233
Workflow file for this run
This file contains 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
name: Firmware Build | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
BUILD_THREADS: 4 | |
BUILD_TYPE: Release | |
# Pico-SDK version | |
PICO_SDK_REF: 2.0.0 | |
PICOTOOL_REF: 2.0.0 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
fanpico_version: ${{steps.version-check.outputs.FANPICO_VERSION}} | |
build_date: ${{steps.version-check.outputs.BUILD_DATE}} | |
compiler_version: ${{steps.compiler-version.outputs.CC_VERSION}} | |
strategy: | |
matrix: | |
fanpico_board: ["0804", "0804D", "0401D" ] | |
pico_board: ["pico", "pico_w", "pico2"] | |
steps: | |
- name: Arm GNU Toolchain (arm-none-eabi-gcc) | |
uses: carlosperate/arm-none-eabi-gcc-action@v1 | |
- name: Check GCC Version | |
id: compiler-version | |
run: | | |
arm-none-eabi-gcc --version | |
ver=$(arm-none-eabi-gcc --version | head -1) | |
echo "CC_VERSION=$ver" >> $GITHUB_OUTPUT | |
- name: Cache Pico-SDK | |
id: cache-pico-sdk | |
uses: actions/cache@v4 | |
with: | |
path: pico-sdk | |
key: ${{runner.os}}-pico-sdk-${{env.PICO_SDK_REF}} | |
- name: Checkout Pico-SDK | |
if: ${{steps.cache-pico-sdk.outputs.cache-hit != 'true' }} | |
uses: actions/checkout@v4 | |
with: | |
repository: raspberrypi/pico-sdk | |
ref: ${{env.PICO_SDK_REF}} | |
path: pico-sdk | |
submodules: recursive | |
- name: Add PICO_SDK_PATH to Environment | |
run: | | |
echo "PICO_SDK_PATH=${{github.workspace}}/pico-sdk" >> $GITHUB_ENV | |
- name: Cache picotool | |
id: cache-picotool | |
uses: actions/cache@v4 | |
with: | |
path: picotool | |
key: ${{runner.os}}-picotool-${{env.PICOTOOL_REF}} | |
- name: Checkout picotool | |
if: ${{steps.cache-picotool.outputs.cache-hit != 'true' }} | |
uses: actions/checkout@v4 | |
with: | |
repository: raspberrypi/picotool | |
ref: ${{env.PICOTOOL_REF}} | |
path: picotool-src | |
submodules: recursive | |
- name: Build picotool | |
if: ${{steps.cache-picotool.outputs.cache-hit != 'true' }} | |
run: | | |
cmake -S picotool-src -B picotool-src/build -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/picotool -DPICOTOOL_FLAT_INSTALL=1 | |
cd picotool-src/build | |
make -j ${{env.BUILD_THREADS}} install | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
submodules: recursive | |
- name: Configure CMake | |
run: cmake -S main -B ${{github.workspace}}/main/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPICO_BOARD=${{matrix.pico_board}} -DFANPICO_BOARD=${{matrix.fanpico_board}} -Dpicotool_DIR=${{github.workspace}}/picotool/picotool | |
- name: Check Source Version | |
id: version-check | |
run: | | |
ver=$(awk '/FANPICO_VERSION[[:space:]]/ { gsub(/"/,""); print $3; exit; }' main/build/config.h) | |
echo "FANPICO_VERSION=$ver" >> $GITHUB_ENV | |
echo "FANPICO_VERSION=$ver" >> $GITHUB_OUTPUT | |
date=$(date +%Y%m%d) | |
echo "BUILD_DATE=$date" >> $GITHUB_ENV | |
echo "BUILD_DATE=$date" >> $GITHUB_OUTPUT | |
- name: Build | |
run: cmake --build ${{github.workspace}}/main/build --config ${{env.BUILD_TYPE}} -j ${{env.BUILD_THREADS}} | |
- name: Test | |
working-directory: ${{github.workspace}}/main/build | |
# Execute tests defined by the CMake configuration. | |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
run: | | |
ls -l fanpico.* | |
sha256sum fanpico.uf2 | |
- name: Gather Artifact Files | |
working-directory: ${{github.workspace}}/main/build | |
run: | | |
mkdir dist | |
cp -av fanpico.uf2 dist/fanpico-${{matrix.fanpico_board}}-${{matrix.pico_board}}.uf2 | |
cp -av fanpico.elf dist/fanpico-${{matrix.fanpico_board}}-${{matrix.pico_board}}.elf | |
cp -av fanpico.elf.map dist/fanpico-${{matrix.fanpico_board}}-${{matrix.pico_board}}.elf.map | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: firmware-${{matrix.fanpico_board}}-${{matrix.pico_board}}-build${{github.run_number}}-${{env.BUILD_DATE}} | |
path: main/build/dist | |
- name: Gather License Files | |
if: ${{ matrix.fanpico_board == '0804' && matrix.pico_board == 'pico' }} | |
working-directory: ${{github.workspace}}/main | |
run: | | |
mkdir -p licenses/licenses | |
cp -v LICENSE credits.txt licenses/ | |
licenses=$(find libs/ -name 'LICENSE*'; find ${PICO_SDK_PATH}/ -maxdepth 3 -name 'LICENSE*') | |
for file in $licenses; do | |
dir=$(dirname $file) | |
name=$(basename $file) | |
lib=$(basename $dir) | |
cp -v "$file" "licenses/licenses/${name}.${lib}" | |
done | |
- name: Upload License Artifact | |
if: ${{ matrix.fanpico_board == '0804' && matrix.pico_board == 'pico' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: licenses | |
path: main/licenses | |
merge: | |
runs-on: ubuntu-latest | |
needs: build | |
env: | |
FANPICO_VERSION: ${{needs.build.outputs.fanpico_version}} | |
BUILD_DATE: ${{needs.build.outputs.build_date}} | |
COMPILER_VERSION: ${{needs.build.outputs.compiler_version}} | |
steps: | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: bundle | |
pattern: firmware-* | |
merge-multiple: true | |
- name: Calculate checksums | |
working-directory: bundle | |
run: | | |
sha256sum * > sha256sums.txt | |
ls -la | |
echo "### Compiler Used" >> $GITHUB_STEP_SUMMARY | |
echo "${{env.COMPILER_VERSION}}" >> $GITHUB_STEP_SUMMARY | |
echo "### Generated firmware files" >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
cat sha256sums.txt >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
- name: Upload checksum artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: firmware-checksums | |
path: bundle/*.txt | |
- name: Merge Artifacts | |
uses: actions/upload-artifact/merge@v4 | |
with: | |
name: fanpico-firmware-${{env.BUILD_DATE}}-${{env.FANPICO_VERSION}}-build${{github.run_number}} | |
delete-merged: true | |