BuildTest.yml 11 KB

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