build.yaml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. name: Build and Pack
  2. on: [push]
  3. jobs:
  4. build:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - uses: actions/checkout@v2
  8. with:
  9. submodules: recursive
  10. - name: Cache PlatformIO
  11. uses: actions/cache@v2
  12. with:
  13. path: ~/.platformio
  14. key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
  15. - name: Set up Python
  16. uses: actions/setup-python@v2
  17. - name: Install PlatformIO
  18. run: |
  19. python -m pip install --upgrade pip
  20. pip install --upgrade platformio
  21. - name: Set Variables
  22. id: vars
  23. run: |
  24. echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
  25. echo "::set-output name=date_time::$(git log -1 --format="%at" | xargs -I{} date -d @{} '+%Y-%m-%d %H:%M:%S')"
  26. echo "::set-output name=date_time_filename::$(git log -1 --format="%at" | xargs -I{} date -d @{} '+%Y-%m-%d_%H-%M-%S')"
  27. #echo "::set-output name=version_string::${{ steps.vars.outputs.date_time_filename }}__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  28. #echo "Version String: ${{ steps.vars.outputs.version_string }}"
  29. - name: Set Version used in HTML Info page
  30. run: echo "${{ steps.vars.outputs.date_time }}, ${{ github.ref_name }} (${{ steps.vars.outputs.sha_short }})" > "sd-card/html/version.txt"
  31. - name: Build Firmware
  32. #run: mkdir -p ./code/.pio/build/esp32cam/; touch ./code/.pio/build/esp32cam/firmware.bin; touch ./code/.pio/build/esp32cam/bootloader.bin; touch ./code/.pio/build/esp32cam/partitions.bin # Testing
  33. run: cd code; platformio run --environment esp32cam
  34. # Old OTA concept
  35. # firmware__*.zip needs to be unpacked before attaching to the release!
  36. # The bin filename can contain versioning.
  37. - name: Rename firmware file to contain versioning (old ota)
  38. run: |
  39. mkdir -p ./dist_old_ota
  40. cp "./code/.pio/build/esp32cam/firmware.bin" "./dist_old_ota/firmware__${{ steps.vars.outputs.date_time_filename }}__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }}).bin"
  41. ls -l ./dist_old_ota
  42. - name: Upload Firmware artifact (old OTA concept)
  43. uses: actions/upload-artifact@v3
  44. with:
  45. name: "firmware__extract_before_upload__only_needed_for_migration_from_11.2.0"
  46. path: ./dist_old_ota/*
  47. - name: Upload Web interface artifact (old OTA concept)
  48. uses: actions/upload-artifact@v3
  49. with:
  50. name: "html__only_needed_for_migration_from_11.2.0__${{ steps.vars.outputs.date_time_filename }}__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  51. path: ./sd-card/html/*
  52. # New OTA concept
  53. # update__version.zip file with following content:
  54. # - /firmware.bin
  55. # - (optional) /html/*
  56. # - (optional) /config/*.tfl
  57. - name: Prepare update.zip artifact
  58. run: |
  59. mkdir -p ./dist
  60. cp "./code/.pio/build/esp32cam/firmware.bin" "dist/firmware.bin"
  61. - name: Upload update.zip Artifact (Firmware only)
  62. uses: actions/upload-artifact@v3
  63. with:
  64. name: "update_firmware_only__${{ steps.vars.outputs.date_time_filename }}__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  65. path: ./dist/*
  66. - name: Prepare update.zip artifact (Firmware + Web UI)
  67. run: cp -r ./sd-card/html ./dist/
  68. - name: Upload update.zip artifact (Firmware + Web UI)
  69. uses: actions/upload-artifact@v3
  70. with:
  71. name: "update_firmware+web_ui__${{ steps.vars.outputs.date_time_filename }}__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  72. path: ./dist/*
  73. - name: Prepare update.zip artifact (Firmware + Web UI + CNN)
  74. run: |
  75. mkdir ./dist/config/
  76. cp ./sd-card/config/*.tfl ./dist/config/ 2>/dev/null || true
  77. cp ./sd-card/config/*.tflite ./dist/config/ 2>/dev/null || true
  78. - name: Upload update.zip artifact (Firmware + Web UI + CNN)
  79. uses: actions/upload-artifact@v3
  80. with:
  81. name: "update_firmware+web_ui+cnn__${{ steps.vars.outputs.date_time_filename }}__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
  82. path: ./dist/*
  83. # creates old style binaries for fresh installation (backward compatible to wiki)
  84. - name: Copy artifacts to firmware folder
  85. run: |
  86. mkdir -p firmware
  87. # copy builds to firmware folder for committing in next step
  88. cp -f "./code/.pio/build/esp32cam/firmware.bin" "firmware/firmware.bin"
  89. cp -f "./code/.pio/build/esp32cam/bootloader.bin" "firmware/bootloader.bin"
  90. cp -f "./code/.pio/build/esp32cam/partitions.bin" "firmware/partitions.bin"
  91. cd sd-card
  92. rm -f ../firmware/html.zip
  93. zip -r ../firmware/html.zip html
  94. cd ../dist
  95. zip -r ../firmware/update.zip .
  96. # extract the version used in next step
  97. - id: get_version
  98. if: startsWith(github.ref, 'refs/tags/')
  99. uses: battila7/get-version-action@v2
  100. # the changelog [unreleased] will now be changed to the release version
  101. - name: Update changelog
  102. uses: thomaseizinger/keep-a-changelog-new-release@v1
  103. if: startsWith(github.ref, 'refs/tags/')
  104. with:
  105. changelogPath: Changelog.md
  106. version: ${{ steps.get_version.outputs.version-without-v }}
  107. # the release notes will be extracted from changelog
  108. - name: Extract release notes
  109. id: extract-release-notes
  110. if: startsWith(github.ref, 'refs/tags/')
  111. uses: ffurrer2/extract-release-notes@v1
  112. with:
  113. changelog_file: Changelog.md
  114. # Releases should only be created on master by tagging the last commit.
  115. # all artifacts in firmware folder pushed to the release
  116. - name: Release
  117. uses: softprops/action-gh-release@v1
  118. if: startsWith(github.ref, 'refs/tags/')
  119. with:
  120. name: ${{ steps.get_version.outputs.version-without-v }}
  121. body: ${{ steps.extract-release-notes.outputs.release_notes }}
  122. files: |
  123. firmware/*
  124. # Commit&Push Changelog to master branch. Must be manually merged back to rolling
  125. - name: Commit changes and push changes
  126. if: startsWith(github.ref, 'refs/tags/')
  127. run: |
  128. git config user.name github-actions
  129. git config user.email github-actions@github.com
  130. git add Changelog.md
  131. git commit Changelog.md -m "Update Changelog.md for ${{github.event.inputs.versionIncrement}} release"
  132. git push origin HEAD:master