build.yaml 6.3 KB

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