BuildTest.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. name: Manually executable test for ESP-IDF v4.3.1
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. ui_build:
  6. 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'
  7. required: true
  8. type: boolean
  9. release_build:
  10. description: 'Force a Release build. When not forced, the system will check for release word in the last commit message to trigger a release'
  11. required: true
  12. type: boolean
  13. update_installer:
  14. description: 'Skip the build and only update the web installer'
  15. required: true
  16. type: boolean
  17. # push:
  18. # branches:
  19. # - '**4.3'
  20. jobs:
  21. bootstrap:
  22. if: ${{ inputs.update_installer != true }}
  23. name: Global setup
  24. runs-on: ubuntu-latest
  25. container:
  26. image: sle118/squeezelite-esp32-idfv43
  27. outputs:
  28. build_number: ${{ steps.buildnumber.outputs.build_number }}
  29. ui_build: ${{ steps.build_flags.outputs.ui_build }}
  30. release_flag: ${{ steps.build_flags.outputs.release_flag }}
  31. mock: ${{ steps.build_flags.outputs.mock }}
  32. steps:
  33. - uses: actions/checkout@v2
  34. with:
  35. fetch-depth: 0
  36. submodules: true
  37. - name: Generate common build number
  38. id: buildnumber
  39. uses: einaregilsson/build-number@v3
  40. with:
  41. token: ${{secrets.github_token}}
  42. - name: Set build flags
  43. id: build_flags
  44. run: |
  45. git config --global --add safe.directory /__w/squeezelite-esp32/squeezelite-esp32
  46. [ ${{github.event.inputs.ui_build}} ] && ui_build_option="--ui_build" || ui_build_option=""
  47. [ ${{github.event.inputs.release_build}} ] && release_build_option="--force" || release_build_option=""
  48. echo "ui_build_option=$ui_build_option" >> $GITHUB_ENV
  49. echo "release_build_option=$release_build_option" >> $GITHUB_ENV
  50. echo "Dumping environment"
  51. env
  52. . /opt/esp/python_env/idf4.3_py3.8_env/bin/activate
  53. # build_flags support the following options
  54. # --mock - to mock the compilation part - this is to be used for testing only
  55. # --force - to force a release build even if the last commit message doesn't contain the word "release"
  56. # --ui_build - to force a ui_build even if the last commit message doesn't contain "[ui-build]"
  57. build_tools.py build_flags $ui_build_option $release_build_option
  58. - name: Show Build Flags
  59. run: |
  60. echo "Running with the following options"
  61. echo "Web Build Flag=${{steps.build_flags.outputs.ui_build}}"
  62. echo "Mock flag=${{steps.build_flags.outputs.mock}}"
  63. echo "Release Flag=${{steps.build_flags.outputs.release_flag}}"
  64. - name: Refresh certificates
  65. if: ${{ steps.build_flags.outputs.release_flag }}
  66. run: |
  67. git update-index --chmod=+x ./server_certs/getcert.sh
  68. cd server_certs;./getcert.sh;cat github.pem;cd ..
  69. - name: Setup Node.js dependencies
  70. if: ${{ !env.ACT }}
  71. uses: actions/setup-node@v3
  72. with:
  73. node-version: 16
  74. cache: 'npm'
  75. cache-dependency-path: components/wifi-manager/webapp/package.json
  76. - name: Build Web Application
  77. if: ${{ steps.build_flags.outputs.ui_build == 1 }}
  78. run: |
  79. cd components/wifi-manager/webapp/
  80. npm install
  81. npm run-script build
  82. - name: Update repository with prebuilt items
  83. if: ${{ steps.build_flags.outputs.ui_build == 1 || steps.build_flags.outputs.release_flag == 1 }}
  84. run: |
  85. git config user.name github-actions
  86. git config user.email github-actions@github.com
  87. git add server_certs
  88. git add components/wifi-manager/webapp/*.h
  89. git add components/wifi-manager/webapp/*.c
  90. git add components/wifi-manager/webapp/*.cmake
  91. git add components/wifi-manager/webapp/dist/*
  92. git commit -m "Update prebuilt objects [skip actions]"
  93. git push https://${{secrets.github_token}}@github.com/sle118/squeezelite-esp32.git
  94. - name: Locally store commonly built objects
  95. uses: actions/upload-artifact@v3
  96. with:
  97. name: prebuilt_objects
  98. path: |
  99. server_certs
  100. components/wifi-manager/webapp/*.h
  101. components/wifi-manager/webapp/*.c
  102. components/wifi-manager/webapp/dist/*
  103. components/wifi-manager/webapp/*.cmake
  104. build:
  105. if: ${{ inputs.update_installer != true }}
  106. runs-on: ubuntu-latest
  107. container:
  108. image: sle118/squeezelite-esp32-idfv43
  109. needs: [bootstrap]
  110. strategy:
  111. matrix:
  112. node: [I2S-4MFlash, SqueezeAmp, Muse]
  113. depth: [16, 32]
  114. exclude:
  115. - node: Muse
  116. depth: 32
  117. - node: bootstrap
  118. depth: 32
  119. steps:
  120. - uses: actions/checkout@v2
  121. with:
  122. fetch-depth: 0
  123. submodules: true
  124. - name: Show Build Flags
  125. run: |
  126. echo "Running with the following options"
  127. echo "Web Build Flag=${{needs.bootstrap.outputs.ui_build}}"
  128. echo "Mock flag=${{needs.bootstrap.outputs.mock}}"
  129. echo "Release Flag=${{needs.bootstrap.outputs.release_flag}}"
  130. echo Environment File name: $GITHUB_ENV
  131. - name: Set build parameters
  132. run: |
  133. . /opt/esp/python_env/idf4.3_py3.8_env/bin/activate
  134. git config --global --add safe.directory /__w/squeezelite-esp32/squeezelite-esp32
  135. git status
  136. 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
  137. - uses: actions/download-artifact@master
  138. name: Restore common objects
  139. with:
  140. name: prebuilt_objects
  141. - name: Build the firmware
  142. if: ${{ needs.bootstrap.outputs.mock == 0 }}
  143. run: |
  144. . ${IDF_PYTHON_ENV_PATH}/bin/activate
  145. chmod +x ./components/spotify/cspot/bell/nanopb/generator/protoc
  146. chmod +x ./components/spotify/cspot/bell/nanopb/generator/protoc-gen-nanopb
  147. chmod +x ./components/spotify/cspot/bell/nanopb/generator/*.py
  148. chmod +x ./components/spotify/cspot/bell/nanopb/generator/*.py2
  149. chmod +x ./components/spotify/cspot/bell/nanopb/generator/proto/*.py
  150. echo "Copying target sdkconfig"
  151. cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig
  152. echo "Building project"
  153. idf.py build -DDEPTH=${DEPTH} -DBUILD_NUMBER=${BUILD_NUMBER}-${DEPTH}
  154. - name: Build Mock firmware
  155. if: ${{ needs.bootstrap.outputs.mock == 1 }}
  156. run: |
  157. mkdir -p build
  158. cd build
  159. mkdir -p partition_table
  160. mkdir -p bootloader
  161. echo \\"mock content\\"> ./squeezelite.bin
  162. echo \"mock content\"> ./recovery.bin
  163. echo \"mock content\"> ./bootloader/bootloader.bin
  164. echo \"mock content\"> ./partition_table/partition-table.bin
  165. echo \"mock content\"> ./ota_data_initial.bin
  166. echo \"mock content\"> ./flash_project_args
  167. echo \"mock content\"> ./size_comp1.txt
  168. echo \"mock content\"> ./size_comp2.txt
  169. echo \"mock content\"> ./partitions.csv
  170. 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
  171. - name: Create Release Artifact Zip
  172. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  173. run: |
  174. if [ -z "${artifact_file_name}" ]
  175. then
  176. echo "No artifact file name set. Will not generate zip file."
  177. else
  178. echo "Generating build artifact zip file"
  179. zip -r build_output.zip build
  180. 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
  181. fi
  182. - name: Upload Build Artifacts
  183. uses: actions/upload-artifact@v3
  184. if: ${{ needs.bootstrap.outputs.mock == 0 }}
  185. with:
  186. name: ${{ env.artifact_prefix }}
  187. path: |
  188. build/flash_project_args
  189. build/size_comp1.txt
  190. build/size_comp2.txt
  191. partitions.csv
  192. sdkconfig
  193. server_certs/github.pem
  194. build/*.bin
  195. build/bootloader/bootloader.bin
  196. build/partition_table/partition-table.bin
  197. build_output.zip
  198. - name: Create Release
  199. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  200. id: create_release
  201. uses: actions/create-release@v1
  202. env:
  203. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
  204. with:
  205. tag_name: ${{ env.tag }}
  206. release_name: ${{ env.name }}
  207. body: ${{ env.description }}
  208. draft: false
  209. prerelease: true
  210. - name: Upload Release Asset - Squeezelite binary file
  211. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  212. id: upload-release-asset
  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/squeezelite.bin
  219. asset_name: ${{ env.artifact_bin_file_name }}
  220. asset_content_type: application/octet-stream
  221. - name: Upload Release Asset - Zip file
  222. if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  223. id: upload-release-asset-zip
  224. uses: actions/upload-release-asset@v1
  225. env:
  226. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  227. with:
  228. 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
  229. asset_path: build/${{ env.artifact_file_name }}
  230. asset_name: ${{ env.artifact_file_name }}
  231. asset_content_type: application/octet-stream
  232. update_web_installer:
  233. name: Update Web Installer After Release
  234. if: ${{ ( always() && !cancelled() ) }}
  235. env:
  236. WEB_INSTALLER: ${{ secrets.WEB_INSTALLER }}
  237. runs-on: ubuntu-latest
  238. container:
  239. image: sle118/squeezelite-esp32-idfv43
  240. steps:
  241. - uses: actions/checkout@v2
  242. if: ${{ ( inputs.update_installer == true ) || (outputs.release_flag == true) || needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  243. with:
  244. fetch-depth: 0
  245. submodules: true
  246. - name: Update Web Installer Project
  247. if: ${{ ( inputs.update_installer == true ) || (outputs.release_flag == true) || needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
  248. run: |
  249. . /opt/esp/python_env/idf4.3_py3.8_env/bin/activate
  250. git config --global --add safe.directory /__w/squeezelite-esp32/squeezelite-esp32
  251. build_tools.py manifest --flash_file "/build/flash_project_args" --outdir "./bin_files" --manif_name "manifest" --max_count 3
  252. build_tools.py pushinstaller --source "./bin_files" --manif_name "manifest" --target "web-installer" --url "https://github.com/sle118/squeezelite-esp32-installer.git" --artifacts "artifacts" --web_installer_branch "main" --token "${{env.WEB_INSTALLER}}"