BuildTest.yml 12 KB

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