build.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. name: Build
  2. on:
  3. push:
  4. branches:
  5. - main
  6. jobs:
  7. compile:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Check out repository
  11. uses: actions/checkout@v4
  12. - name: Set up Arduino CLI
  13. uses: arduino/setup-arduino-cli@v2
  14. - name: Set up Python
  15. uses: actions/setup-python@v5
  16. with:
  17. python-version: '3.x'
  18. - name: Install adafruit-nrfutil
  19. # The Adafruit nRF52 build recipe shells out to adafruit-nrfutil to
  20. # package the DFU .zip; it is not bundled with the core on the runner.
  21. run: pip install adafruit-nrfutil
  22. - name: Install Adafruit nRF52 core
  23. run: |
  24. arduino-cli config init --overwrite
  25. arduino-cli config set board_manager.additional_urls https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
  26. arduino-cli core update-index
  27. arduino-cli core install adafruit:nrf52
  28. - name: Generate version header
  29. run: ./gen_version.sh
  30. - name: Compile OpenPuck
  31. run: |
  32. mkdir -p build/openpuck build/cache/openpuck
  33. arduino-cli compile \
  34. -b adafruit:nrf52:feather52840 \
  35. --clean \
  36. --build-path build/cache/openpuck \
  37. --output-dir build/openpuck \
  38. --build-property "build.extra_flags=-DNRF52840_XXAA {build.flags.usb} -DCFG_TUD_HID=4" \
  39. OpenPuck
  40. - name: Generate UF2 image
  41. run: |
  42. UF2_FAMILY_ID=0xADA52840
  43. CORE_DIR="$(find "${HOME}/.arduino15/packages/adafruit/hardware/nrf52" \
  44. -mindepth 1 -maxdepth 1 -type d | sort -V | tail -n 1)"
  45. UF2CONV="${CORE_DIR}/tools/uf2conv/uf2conv.py"
  46. if [ ! -f "${UF2CONV}" ]; then
  47. echo "UF2 converter not found: ${UF2CONV}"
  48. exit 1
  49. fi
  50. if [ ! -f build/openpuck/OpenPuck.ino.hex ]; then
  51. echo "HEX output not found: build/openpuck/OpenPuck.ino.hex"
  52. exit 1
  53. fi
  54. python3 "${UF2CONV}" -f "${UF2_FAMILY_ID}" -c \
  55. -o build/openpuck/OpenPuck.ino.uf2 \
  56. build/openpuck/OpenPuck.ino.hex
  57. - name: List build outputs
  58. run: |
  59. find build/openpuck -maxdepth 1 -type f -print | sort
  60. - name: Upload build artifacts
  61. uses: actions/upload-artifact@v4
  62. with:
  63. name: openpuck-firmware
  64. retention-days: 7
  65. path: |
  66. build/openpuck/*.uf2
  67. build/openpuck/*.bin
  68. build/openpuck/*.hex
  69. build/openpuck/*.elf
  70. build/openpuck/*.map
  71. build/openpuck/*.zip