Platform_build.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. name: Platform Build
  2. on:
  3. push:
  4. branches:
  5. - '**4.3'
  6. workflow_dispatch:
  7. inputs:
  8. ui_build:
  9. description: 'Force Rebuilding the UI. When not forced, the system will check for [ui-build] in the last commit message to trigger a ui rebuild'
  10. required: true
  11. type: boolean
  12. release_build:
  13. description: 'Force a Release build. When not forced, the system will check for release word in the last commit message to trigger a release'
  14. required: true
  15. type: boolean
  16. jobs:
  17. bootstrap:
  18. name: Global setup
  19. runs-on: ubuntu-latest
  20. container:
  21. image: sle118/squeezelite-esp32-idfv435
  22. outputs:
  23. build_number: ${{ steps.buildnumber.outputs.build_number }}
  24. ui_build: ${{ steps.build_flags.outputs.ui_build }}
  25. release_flag: ${{ steps.build_flags.outputs.release_flag }}
  26. mock: ${{ steps.build_flags.outputs.mock }}
  27. steps:
  28. - uses: actions/checkout@v2
  29. with:
  30. fetch-depth: 0
  31. submodules: true
  32. - name: Generate common build number
  33. id: buildnumber
  34. uses: einaregilsson/build-number@v3
  35. with:
  36. token: ${{secrets.github_token}}
  37. - name: Set build flags
  38. id: build_flags
  39. run: |
  40. git config --global --add safe.directory /__w/squeezelite-esp32/squeezelite-esp32
  41. [ ${{github.event.inputs.ui_build}} ] && ui_build_option="--ui_build" || ui_build_option=""
  42. [ ${{github.event.inputs.release_build}} ] && release_build_option="--force" || release_build_option=""
  43. echo "ui_build_option=$ui_build_option" >> "$GITHUB_OUTPUT"
  44. echo "release_build_option=$release_build_option" >> "$GITHUB_OUTPUT"
  45. echo "Dumping environment"
  46. env
  47. . /opt/esp/python_env/idf4.3_py3.8_env/bin/activate
  48. # build_flags support the following options
  49. # --mock - to mock the compilation part - this is to be used for testing only
  50. # --force - to force a release build even if the last commit message doesn't contain the word "release"
  51. # --ui_build - to force a ui_build even if the last commit message doesn't contain "[ui-build]"
  52. build_tools.py build_flags $ui_build_option $release_build_option
  53. - name: Show Build Flags
  54. run: |
  55. echo "Running with the following options"
  56. echo "Web Build Flag=${{steps.build_flags.outputs.ui_build}}"
  57. echo "Mock flag=${{steps.build_flags.outputs.mock}}"
  58. echo "Release Flag=${{steps.build_flags.outputs.release_flag}}"
  59. - name: Refresh certificates
  60. if: ${{ steps.build_flags.outputs.release_flag }}
  61. run: |
  62. git update-index --chmod=+x ./server_certs/getcert.sh
  63. cd server_certs;./getcert.sh;cat github.pem;cd ..
  64. - name: Setup Node.js dependencies
  65. if: ${{ !env.ACT }}
  66. uses: actions/setup-node@v3
  67. with:
  68. node-version: 16
  69. cache: 'npm'
  70. cache-dependency-path: components/wifi-manager/webapp/package.json
  71. - name: Build Web Application
  72. if: ${{ steps.build_flags.outputs.ui_build == 1 }}
  73. run: |
  74. cd components/wifi-manager/webapp/
  75. npm install
  76. npm run-script build
  77. - name: Update repository with prebuilt items
  78. if: ${{ steps.build_flags.outputs.ui_build == 1 || steps.build_flags.outputs.release_flag == 1 }}
  79. run: |
  80. git config user.name github-actions
  81. git config user.email github-actions@github.com
  82. git add server_certs
  83. git add components/wifi-manager/webapp/*.h
  84. git add components/wifi-manager/webapp/*.c
  85. git add components/wifi-manager/webapp/*.cmake
  86. git add components/wifi-manager/webapp/dist/*
  87. git commit -m "Update prebuilt objects [skip actions]"
  88. git push https://${{secrets.github_token}}@github.com/sle118/squeezelite-esp32.git
  89. - name: Locally store commonly built objects
  90. uses: actions/upload-artifact@v4
  91. with:
  92. name: prebuilt_objects
  93. path: |
  94. server_certs
  95. components/wifi-manager/webapp/*.h
  96. components/wifi-manager/webapp/*.c
  97. components/wifi-manager/webapp/dist/*
  98. components/wifi-manager/webapp/*.cmake
  99. build:
  100. runs-on: ubuntu-latest
  101. container:
  102. image: sle118/squeezelite-esp32-idfv435
  103. needs: [bootstrap]
  104. strategy:
  105. matrix:
  106. node: [I2S-4MFlash, SqueezeAmp, Muse]
  107. depth: [16, 32]
  108. exclude:
  109. - node: Muse
  110. depth: 32
  111. - node: bootstrap
  112. depth: 32
  113. steps:
  114. - uses: actions/checkout@v2
  115. with:
  116. fetch-depth: 0
  117. submodules: true
  118. - name: Show Build Flags
  119. run: |
  120. echo "Running with the following options"
  121. echo "Web Build Flag=${{needs.bootstrap.outputs.ui_build}}"
  122. echo "Mock flag=${{needs.bootstrap.outputs.mock}}"
  123. echo "Release Flag=${{needs.bootstrap.outputs.release_flag}}"
  124. echo Environment File name: $GITHUB_ENV
  125. - name: Set build parameters
  126. run: |
  127. . /opt/esp/python_env/idf4.3_py3.8_env/bin/activate
  128. git config --global --add safe.directory /__w/squeezelite-esp32/squeezelite-esp32
  129. git status
  130. build_tools.py environment --build ${{ needs.bootstrap.outputs.build_number }} --env_file "$GITHUB_ENV" --node "${{matrix.node}}" --depth ${{matrix.depth}} --major 2 --docker sle118/squeezelite-esp32-idfv435
  131. - uses: actions/download-artifact@v4
  132. name: Restore common objects
  133. with:
  134. name: prebuilt_objects
  135. - name: Build the firmware
  136. if: ${{ needs.bootstrap.outputs.mock == 0 }}
  137. run: |
  138. . ${IDF_PYTHON_ENV_PATH}/bin/activate
  139. echo "Copying target sdkconfig"
  140. cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig
  141. echo "Building project"
  142. idf.py build -DDEPTH=${DEPTH} -DBUILD_NUMBER=${BUILD_NUMBER}-${DEPTH}
  143. - name: Build Mock firmware
  144. if: ${{ needs.bootstrap.outputs.mock == 1 }}
  145. run: |
  146. mkdir -p build
  147. cd build
  148. mkdir -p partition_table
  149. mkdir -p bootloader
  150. echo \\"mock content\\"> ./squeezelite.bin
  151. echo \"mock content\"> ./recovery.bin
  152. echo \"mock content\"> ./bootloader/bootloader.bin
  153. echo \"mock content\"> ./partition_table/partition-table.bin
  154. echo \"mock content\"> ./ota_data_initial.bin
  155. echo \"mock content\"> ./flash_project_args
  156. echo \"mock content\"> ./size_comp1.txt
  157. echo \"mock content\"> ./size_comp2.txt
  158. echo \"mock content\"> ./partitions.csv
  159. echo { \"write_flash_args\" : [ \"--flash_mode\", \"dio\", \"--flash_size\", \"detect\", \"--flash_freq\", \"80m\" ], \"flash_settings\" : { \"flash_mode\": \"dio\", \"flash_size\": \"detect\", \"flash_freq\": \"80m\" }, \"flash_files\" : { \"0x8000\" : \"partition_table/partition-table.bin\", \"0xd000\" : \"ota_data_initial.bin\", \"0x1000\" : \"bootloader/bootloader.bin\", \"0x10000\" : \"recovery.bin\", \"0x150000\" : \"squeezelite.bin\" }, \"partition_table\" : { \"offset\" : \"0x8000\", \"file\" : \"partition_table/partition-table.bin\" }, \"otadata\" : { \"offset\" : \"0xd000\", \"file\" : \"ota_data_initial.bin\" }, \"bootloader\" : { \"offset\" : \"0x1000\", \"file\" : \"bootloader/bootloader.bin\" }, \"app\" : { \"offset\" : \"0x10000\", \"file\" : \"recovery.bin\" }, \"squeezelite\" : { \"offset\" : \"0x150000\", \"file\" : \"squeezelite.bin\" }, \"extra_esptool_args\" : { \"after\" : \"hard_reset\", \"before\" : \"default_reset\" } } > ./flasher_args.json
  160. - name: Create Release Artifact Zip
  161. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  162. run: |
  163. if [ -z "${artifact_file_name}" ]
  164. then
  165. echo "No artifact file name set. Will not generate zip file."
  166. else
  167. echo "Generating build artifact zip file"
  168. zip -r build_output.zip build
  169. zip build/${artifact_file_name} partitions*.csv components/ build/*.bin build/bootloader/bootloader.bin build/partition_table/partition-table.bin build/flash_project_args build/size_*.txt
  170. fi
  171. - name: Upload Build Artifacts
  172. uses: actions/upload-artifact@v3
  173. if: ${{ needs.bootstrap.outputs.mock == 0 }}
  174. with:
  175. name: ${{ env.artifact_prefix }}
  176. path: |
  177. build/flash_project_args
  178. build/size_comp1.txt
  179. build/size_comp2.txt
  180. partitions.csv
  181. sdkconfig
  182. server_certs/github.pem
  183. build/*.bin
  184. build/bootloader/bootloader.bin
  185. build/partition_table/partition-table.bin
  186. build_output.zip
  187. - name: Create Release
  188. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  189. id: create_release
  190. uses: actions/create-release@v1
  191. env:
  192. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
  193. with:
  194. tag_name: ${{ env.tag }}
  195. release_name: ${{ env.name }}
  196. body: ${{ env.description }}
  197. draft: false
  198. prerelease: false
  199. - name: Upload Release Asset - Squeezelite binary file
  200. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  201. id: upload-release-asset
  202. uses: actions/upload-release-asset@v1
  203. env:
  204. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  205. with:
  206. upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
  207. asset_path: build/squeezelite.bin
  208. asset_name: ${{ env.artifact_bin_file_name }}
  209. asset_content_type: application/octet-stream
  210. - name: Upload Release Asset - Zip file
  211. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  212. id: upload-release-asset-zip
  213. uses: actions/upload-release-asset@v1
  214. env:
  215. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  216. with:
  217. upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
  218. asset_path: build/${{ env.artifact_file_name }}
  219. asset_name: ${{ env.artifact_file_name }}
  220. asset_content_type: application/octet-stream
  221. update_web_installer:
  222. name: Update Web Installer After Release
  223. needs: [ bootstrap, build ]
  224. if: ${{ always() && !cancelled() && needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  225. uses: ./.github/workflows/web_deploy.yml
  226. secrets:
  227. WEB_INSTALLER: ${{ secrets.WEB_INSTALLER }}