build.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. name: Build and Pack
  2. on: [push]
  3. jobs:
  4. #########################################################################################
  5. ## Build Firmware
  6. #########################################################################################
  7. build:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - uses: actions/checkout@v2
  11. with:
  12. submodules: recursive
  13. - name: Set Variables
  14. id: vars
  15. run: |
  16. echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
  17. - name: Cache PlatformIO
  18. uses: actions/cache@v2
  19. with:
  20. path: ~/.platformio
  21. key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
  22. - name: Set up Python
  23. uses: actions/setup-python@v2
  24. - name: Install PlatformIO
  25. run: |
  26. python -m pip install --upgrade pip
  27. pip install --upgrade platformio
  28. - name: Build Firmware
  29. # run: echo "Testing... ${{ github.ref_name }}, ${{ steps.vars.outputs.sha_short }}" > ./sd-card/html/version.txt; mkdir -p ./code/.pio/build/esp32cam/; cd ./code/.pio/build/esp32cam/; echo "${{ steps.vars.outputs.sha_short }}" > firmware.bin; cp firmware.bin partitions.bin; cp firmware.bin bootloader.bin # Testing
  30. run: cd code; platformio run --environment esp32cam
  31. - name: Store generated files in cache
  32. uses: actions/cache@v3
  33. with:
  34. path: |
  35. ./code/.pio/build/esp32cam/firmware.bin
  36. ./code/.pio/build/esp32cam/partitions.bin
  37. ./code/.pio/build/esp32cam/bootloader.bin
  38. ./sd-card/html/version.txt
  39. key: ${{ github.run_number }}
  40. #########################################################################################
  41. ## Pack for old OTA (v1)
  42. #########################################################################################
  43. pack-for-OTA-v1:
  44. # Old OTA concept
  45. # firmware__*.zip needs to be unpacked before attaching to the release!
  46. # The bin filename can contain versioning.
  47. runs-on: ubuntu-latest
  48. needs: build
  49. steps:
  50. - uses: actions/checkout@v2
  51. - name: Get generated files from cache
  52. uses: actions/cache@v3
  53. with:
  54. path: |
  55. ./code/.pio/build/esp32cam/firmware.bin
  56. ./code/.pio/build/esp32cam/partitions.bin
  57. ./code/.pio/build/esp32cam/bootloader.bin
  58. ./sd-card/html/version.txt
  59. key: ${{ github.run_number }}
  60. - name: Set Variables
  61. id: vars
  62. run: |
  63. echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
  64. - name: Rename firmware file to contain versioning (old ota)
  65. run: |
  66. mkdir -p ./dist_old_ota
  67. cp "./code/.pio/build/esp32cam/firmware.bin" "./dist_old_ota/firmware__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }}).bin"
  68. - name: Upload Firmware artifact (old OTA concept)
  69. uses: actions/upload-artifact@v3
  70. with:
  71. # name: "firmware__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})__(extract_before_upload__only_needed_for_migration_from_11.3.1)"
  72. name: "firmware__(extract_before_upload)__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})"
  73. path: ./dist_old_ota/*
  74. - name: Upload Web interface artifact (old OTA concept)
  75. uses: actions/upload-artifact@v3
  76. with:
  77. name: "html__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})"
  78. path: ./sd-card/html/*
  79. #########################################################################################
  80. ## Pack for new OTA (v2)
  81. #########################################################################################
  82. pack-for-OTA-v2:
  83. # New OTA concept
  84. # update__version.zip file with following content:
  85. # - /firmware.bin
  86. # - (optional) /html/*
  87. # - (optional) /config/*.tfl
  88. runs-on: ubuntu-latest
  89. needs: build
  90. steps:
  91. - uses: actions/checkout@v2
  92. - name: Get generated files from cache
  93. uses: actions/cache@v3
  94. with:
  95. path: |
  96. ./code/.pio/build/esp32cam/firmware.bin
  97. ./code/.pio/build/esp32cam/partitions.bin
  98. ./code/.pio/build/esp32cam/bootloader.bin
  99. ./sd-card/html/version.txt
  100. key: ${{ github.run_number }}
  101. - name: Set Variables
  102. id: vars
  103. run: |
  104. echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
  105. - name: Prepare update.zip artifact
  106. run: |
  107. mkdir -p ./dist
  108. cp "./code/.pio/build/esp32cam/firmware.bin" "dist/firmware.bin"
  109. # - name: Upload update.zip Artifact (Firmware only)
  110. # uses: actions/upload-artifact@v3
  111. # with:
  112. # name: "update_firmware_only__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  113. # path: ./dist/*
  114. - name: Add Web UI to dist
  115. run: cp -r ./sd-card/html ./dist/
  116. # - name: Upload update.zip artifact (Firmware + Web UI)
  117. # uses: actions/upload-artifact@v3
  118. # with:
  119. # name: "update_firmware+webinterface__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  120. # path: ./dist/*
  121. - name: Add CNN to dist
  122. run: |
  123. mkdir ./dist/config/
  124. cp ./sd-card/config/*.tfl ./dist/config/ 2>/dev/null || true
  125. cp ./sd-card/config/*.tflite ./dist/config/ 2>/dev/null || true
  126. - name: Upload dist as update.zip artifact (Firmware + Web UI + CNN)
  127. uses: actions/upload-artifact@v3
  128. with:
  129. name: "update__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  130. path: ./dist/*
  131. - name: Store generated files in cache
  132. uses: actions/cache@v3
  133. with:
  134. path: |
  135. ./code/.pio/build/esp32cam/firmware.bin
  136. ./code/.pio/build/esp32cam/partitions.bin
  137. ./code/.pio/build/esp32cam/bootloader.bin
  138. ./sd-card/html/version.txt
  139. ./dist
  140. key: ${{ github.run_number }}-pack-for-OTA-v2
  141. #########################################################################################
  142. ## Pack for a fresh install (USB flashing) (initial_esp32_setup)
  143. #########################################################################################
  144. pack-for-fresh-install:
  145. # creates old style binaries for fresh installation (backward compatible to wiki)
  146. runs-on: ubuntu-latest
  147. needs: build
  148. steps:
  149. - uses: actions/checkout@v2
  150. - name: Get generated files from cache
  151. uses: actions/cache@v3
  152. with:
  153. path: |
  154. ./code/.pio/build/esp32cam/firmware.bin
  155. ./code/.pio/build/esp32cam/partitions.bin
  156. ./code/.pio/build/esp32cam/bootloader.bin
  157. ./sd-card/html/version.txt
  158. key: ${{ github.run_number }}
  159. - name: Prepare artifacts for release
  160. run: |
  161. mkdir -p firmware
  162. rm -rf firmware/*
  163. mkdir -p release
  164. # copy builds to firmware folder
  165. cp -f "./code/.pio/build/esp32cam/firmware.bin" "firmware/firmware.bin"
  166. cp -f "./code/.pio/build/esp32cam/bootloader.bin" "firmware/bootloader.bin"
  167. cp -f "./code/.pio/build/esp32cam/partitions.bin" "firmware/partitions.bin"
  168. zip -r ./firmware/sd-card.zip sd-card
  169. cd ../firmware
  170. zip -r ../release/initial_esp32_setup.zip .
  171. - name: Upload initial_esp32_setup.zip artifact (Firmware + Bootloader + Partitions + Web UI)
  172. uses: actions/upload-artifact@v3
  173. with:
  174. name: "initial_esp32_setup__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  175. path: ./firmware
  176. - name: Store generated files in cache
  177. uses: actions/cache@v3
  178. with:
  179. path: |
  180. ./firmware
  181. key: ${{ github.run_number }}-pack-for-fresh-install
  182. #########################################################################################
  183. ## Prepare and create release
  184. #########################################################################################
  185. release:
  186. runs-on: ubuntu-latest
  187. needs: [pack-for-OTA-v2, pack-for-fresh-install]
  188. steps:
  189. - uses: actions/checkout@v2
  190. - name: Get generated files from cache
  191. uses: actions/cache@v3
  192. with:
  193. path: |
  194. ./code/.pio/build/esp32cam/firmware.bin
  195. ./code/.pio/build/esp32cam/partitions.bin
  196. ./code/.pio/build/esp32cam/bootloader.bin
  197. ./sd-card/html/version.txt
  198. key: ${{ github.run_number }}
  199. # import the changes from
  200. - name: Get generated files from cache
  201. uses: actions/cache@v3
  202. with:
  203. path: |
  204. ./dist
  205. key: ${{ github.run_number }}-pack-for-OTA-v2
  206. # import cached artifacts from pack-for-fresh-install
  207. - name: Get generated files from cache
  208. uses: actions/cache@v3
  209. with:
  210. path: |
  211. ./firmware
  212. key: ${{ github.run_number }}-pack-for-fresh-install
  213. - name: Set Variables
  214. id: vars
  215. run: |
  216. echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
  217. - name: Prepare artifacts for release
  218. run: |
  219. mkdir -p release
  220. # create a update.zip like "update__rolling"
  221. cd ./dist
  222. zip -r ../release/update.zip .
  223. cd ../firmware
  224. zip -r ../release/initial_esp32_setup.zip .
  225. # extract the version used in next step
  226. - id: get_version
  227. if: startsWith(github.ref, 'refs/tags/')
  228. uses: battila7/get-version-action@v2
  229. # the changelog [unreleased] will now be changed to the release version
  230. - name: Update changelog
  231. uses: thomaseizinger/keep-a-changelog-new-release@v1
  232. if: startsWith(github.ref, 'refs/tags/')
  233. with:
  234. changelogPath: Changelog.md
  235. version: ${{ steps.get_version.outputs.version-without-v }}
  236. # the release notes will be extracted from changelog
  237. - name: Extract release notes
  238. id: extract-release-notes
  239. if: startsWith(github.ref, 'refs/tags/')
  240. uses: ffurrer2/extract-release-notes@v1
  241. with:
  242. changelog_file: Changelog.md
  243. # Releases should only be created on master by tagging the last commit.
  244. # all artifacts in firmware folder pushed to the release
  245. - name: Release
  246. uses: softprops/action-gh-release@v1
  247. if: startsWith(github.ref, 'refs/tags/')
  248. with:
  249. name: ${{ steps.get_version.outputs.version-without-v }}
  250. body: ${{ steps.extract-release-notes.outputs.release_notes }}
  251. files: |
  252. release/*
  253. # Commit&Push Changelog to master branch. Must be manually merged back to rolling
  254. - name: Commit changes and push changes
  255. if: startsWith(github.ref, 'refs/tags/')
  256. run: |
  257. git config user.name github-actions
  258. git config user.email github-actions@github.com
  259. git add Changelog.md
  260. git commit Changelog.md -m "Update Changelog.md for ${{github.event.inputs.versionIncrement}} release"
  261. git push origin HEAD:master