Platform_build.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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-idfv43
  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_ENV
  44. echo "release_build_option=$release_build_option" >> $GITHUB_ENV
  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@v3
  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-idfv43
  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-idfv43
  131. - uses: actions/download-artifact@master
  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. chmod +x ./components/spotify/cspot/bell/nanopb/generator/protoc
  140. chmod +x ./components/spotify/cspot/bell/nanopb/generator/protoc-gen-nanopb
  141. chmod +x ./components/spotify/cspot/bell/nanopb/generator/*.py
  142. chmod +x ./components/spotify/cspot/bell/nanopb/generator/*.py2
  143. chmod +x ./components/spotify/cspot/bell/nanopb/generator/proto/*.py
  144. echo "Copying target sdkconfig"
  145. cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig
  146. echo "Building project"
  147. idf.py build -DDEPTH=${DEPTH} -DBUILD_NUMBER=${BUILD_NUMBER}-${DEPTH}
  148. - name: Build Mock firmware
  149. if: ${{ needs.bootstrap.outputs.mock == 1 }}
  150. run: |
  151. mkdir -p build
  152. cd build
  153. mkdir -p partition_table
  154. mkdir -p bootloader
  155. echo \\"mock content\\"> ./squeezelite.bin
  156. echo \"mock content\"> ./recovery.bin
  157. echo \"mock content\"> ./bootloader/bootloader.bin
  158. echo \"mock content\"> ./partition_table/partition-table.bin
  159. echo \"mock content\"> ./ota_data_initial.bin
  160. echo \"mock content\"> ./flash_project_args
  161. echo \"mock content\"> ./size_comp1.txt
  162. echo \"mock content\"> ./size_comp2.txt
  163. echo \"mock content\"> ./partitions.csv
  164. 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
  165. - name: Create Release Artifact Zip
  166. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  167. run: |
  168. if [ -z "${artifact_file_name}" ]
  169. then
  170. echo "No artifact file name set. Will not generate zip file."
  171. else
  172. echo "Generating build artifact zip file"
  173. zip -r build_output.zip build
  174. 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
  175. fi
  176. - name: Upload Build Artifacts
  177. uses: actions/upload-artifact@v3
  178. if: ${{ needs.bootstrap.outputs.mock == 0 }}
  179. with:
  180. name: ${{ env.artifact_prefix }}
  181. path: |
  182. build/flash_project_args
  183. build/size_comp1.txt
  184. build/size_comp2.txt
  185. partitions.csv
  186. sdkconfig
  187. server_certs/github.pem
  188. build/*.bin
  189. build/bootloader/bootloader.bin
  190. build/partition_table/partition-table.bin
  191. build_output.zip
  192. - name: Create Release
  193. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  194. id: create_release
  195. uses: actions/create-release@v1
  196. env:
  197. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
  198. with:
  199. tag_name: ${{ env.tag }}
  200. release_name: ${{ env.name }}
  201. body: ${{ env.description }}
  202. draft: false
  203. prerelease: true
  204. - name: Upload Release Asset - Squeezelite binary file
  205. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  206. id: upload-release-asset
  207. uses: actions/upload-release-asset@v1
  208. env:
  209. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  210. with:
  211. 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
  212. asset_path: build/squeezelite.bin
  213. asset_name: ${{ env.artifact_bin_file_name }}
  214. asset_content_type: application/octet-stream
  215. - name: Upload Release Asset - Zip file
  216. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  217. id: upload-release-asset-zip
  218. uses: actions/upload-release-asset@v1
  219. env:
  220. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  221. with:
  222. 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
  223. asset_path: build/${{ env.artifact_file_name }}
  224. asset_name: ${{ env.artifact_file_name }}
  225. asset_content_type: application/octet-stream
  226. update_web_installer:
  227. name: Update Web Installer After Release
  228. needs: [ bootstrap, build ]
  229. if: ${{( always() && !cancelled() ) && needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  230. uses: ./.github/workflows/web_deploy.yml