BuildTest.yml 12 KB

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