BuildTest.yml 12 KB

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