release.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. name: Release
  2. on:
  3. push:
  4. branches:
  5. - main
  6. permissions:
  7. contents: write
  8. jobs:
  9. build-release:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Check out repository
  13. uses: actions/checkout@v4
  14. - name: Set up Arduino CLI
  15. uses: arduino/setup-arduino-cli@v2
  16. - name: Set up Python
  17. uses: actions/setup-python@v5
  18. with:
  19. python-version: '3.x'
  20. - name: Install adafruit-nrfutil
  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 (standard)
  41. run: ./gen_uf2.sh build/openpuck/OpenPuck.ino.hex build/openpuck/OpenPuck.ino.uf2
  42. - name: Compile recovery build
  43. run: |
  44. mkdir -p build/openpuck-recovery build/cache/openpuck-recovery
  45. arduino-cli compile \
  46. -b adafruit:nrf52:feather52840 \
  47. --clean \
  48. --build-path build/cache/openpuck-recovery \
  49. --output-dir build/openpuck-recovery \
  50. --build-property "build.extra_flags=-DNRF52840_XXAA {build.flags.usb} -DCFG_TUD_HID=4 -DOPK_FACTORY_RESET=1" \
  51. OpenPuck
  52. - name: Generate UF2 (recovery)
  53. run: ./gen_uf2.sh build/openpuck-recovery/OpenPuck.ino.hex build/openpuck-recovery/OpenPuck.ino.uf2
  54. - name: Collect artifacts
  55. run: |
  56. mkdir -p release_assets
  57. REF="${GITHUB_REF_NAME}"
  58. SAFE_REF="$(printf '%s' "$REF" | tr -c 'A-Za-z0-9._-' '-')"
  59. SHA_SHORT="$(git rev-parse --short=8 HEAD)"
  60. VERSION="${SAFE_REF}-${SHA_SHORT}"
  61. find build/openpuck build/openpuck-recovery \
  62. -maxdepth 1 -type f \
  63. \( -name '*.uf2' -o -name '*.zip' \) \
  64. -print | while read -r f; do
  65. # Keep only the extension; the arduino base name (OpenPuck.ino.*)
  66. # is redundant once we prefix with OpenPuck-<version>-<flavor>.
  67. ext="${f##*.}"
  68. dir="$(basename "$(dirname "$f")")"
  69. if [ "$dir" = "openpuck-recovery" ]; then
  70. flavor="factory-reset"
  71. else
  72. flavor="standard"
  73. fi
  74. cp "$f" "release_assets/OpenPuck-${VERSION}-${flavor}.${ext}"
  75. done
  76. test -n "$(find release_assets -maxdepth 1 -type f -print -quit)"
  77. ls -la release_assets
  78. - name: Create GitHub Release
  79. uses: softprops/action-gh-release@v2
  80. with:
  81. tag_name: ${{ format('build-{0}', github.sha) }}
  82. target_commitish: ${{ github.sha }}
  83. name: ${{ format('Build {0}', github.sha) }}
  84. prerelease: true
  85. files: release_assets/*
  86. body: |
  87. OpenPuck Firmware Release
  88. Build: ${{ github.sha }}
  89. Ref: ${{ github.ref_name }}
  90. ### Files included:
  91. - `.zip` files for Adafruit DFU tool
  92. - `.uf2` files for drag-and-drop flashing (BOOT/UF2 drive)
  93. env:
  94. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}