build.yaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. #########################################################################################
  132. ## Pack for a fresh install (USB flashing)
  133. #########################################################################################
  134. pack-for-fresh-install:
  135. # creates old style binaries for fresh installation (backward compatible to wiki)
  136. runs-on: ubuntu-latest
  137. needs: build
  138. steps:
  139. - uses: actions/checkout@v2
  140. - name: Get generated files from cache
  141. uses: actions/cache@v3
  142. with:
  143. path: |
  144. ./code/.pio/build/esp32cam/firmware.bin
  145. ./code/.pio/build/esp32cam/partitions.bin
  146. ./code/.pio/build/esp32cam/bootloader.bin
  147. ./sd-card/html/version.txt
  148. key: ${{ github.run_number }}
  149. - name: Copy artifacts to firmware folder and create initial_esp32_setup.zip
  150. run: |
  151. mkdir -p firmware
  152. # copy builds to firmware folder for committing in next step
  153. cp -f "./code/.pio/build/esp32cam/firmware.bin" "firmware/firmware.bin"
  154. cp -f "./code/.pio/build/esp32cam/bootloader.bin" "firmware/bootloader.bin"
  155. cp -f "./code/.pio/build/esp32cam/partitions.bin" "firmware/partitions.bin"
  156. cd sd-card
  157. rm -f ../firmware/html.zip
  158. rm -f ../firmware/README.md
  159. zip -r ../firmware/html.zip html
  160. mkdir ../dist
  161. cd ../dist
  162. - name: Upload initial_esp32_setup.zip artifact (Firmware + Bootloader + Partitions + Web UI + CNN)
  163. uses: actions/upload-artifact@v3
  164. with:
  165. name: "initial_esp32_setup__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  166. path: ./firmware
  167. # extract the version used in next step
  168. - id: get_version
  169. if: startsWith(github.ref, 'refs/tags/')
  170. uses: battila7/get-version-action@v2
  171. # the changelog [unreleased] will now be changed to the release version
  172. - name: Update changelog
  173. uses: thomaseizinger/keep-a-changelog-new-release@v1
  174. if: startsWith(github.ref, 'refs/tags/')
  175. with:
  176. changelogPath: Changelog.md
  177. version: ${{ steps.get_version.outputs.version-without-v }}
  178. # the release notes will be extracted from changelog
  179. - name: Extract release notes
  180. id: extract-release-notes
  181. if: startsWith(github.ref, 'refs/tags/')
  182. uses: ffurrer2/extract-release-notes@v1
  183. with:
  184. changelog_file: Changelog.md
  185. # Releases should only be created on master by tagging the last commit.
  186. # all artifacts in firmware folder pushed to the release
  187. - name: Release
  188. uses: softprops/action-gh-release@v1
  189. if: startsWith(github.ref, 'refs/tags/')
  190. with:
  191. name: ${{ steps.get_version.outputs.version-without-v }}
  192. body: ${{ steps.extract-release-notes.outputs.release_notes }}
  193. files: |
  194. firmware/*
  195. # Commit&Push Changelog to master branch. Must be manually merged back to rolling
  196. - name: Commit changes and push changes
  197. if: startsWith(github.ref, 'refs/tags/')
  198. run: |
  199. git config user.name github-actions
  200. git config user.email github-actions@github.com
  201. git add Changelog.md
  202. git commit Changelog.md -m "Update Changelog.md for ${{github.event.inputs.versionIncrement}} release"
  203. git push origin HEAD:master