esp-idf-v4.3-build.yml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. pull_request:
  8. branches:
  9. - '**4.3'
  10. jobs:
  11. job1:
  12. name: Build Number
  13. runs-on: ubuntu-latest
  14. outputs:
  15. build_number: ${{ steps.buildnumber.outputs.build_number }}
  16. steps:
  17. - name: Generate common build number
  18. id: buildnumber
  19. uses: einaregilsson/build-number@v3
  20. with:
  21. token: ${{secrets.github_token}}
  22. build:
  23. runs-on: ubuntu-latest
  24. needs: job1
  25. strategy:
  26. max-parallel: 1
  27. matrix:
  28. node: [I2S-4MFlash, SqueezeAmp]
  29. depth: [16, 32]
  30. steps:
  31. - name: Set target name
  32. run: |
  33. echo "TARGET_BUILD_NAME=${{ matrix.node }}" >> $GITHUB_ENV
  34. echo "build_version_prefix=1." >> $GITHUB_ENV
  35. - uses: actions/checkout@v2
  36. with:
  37. fetch-depth: 15
  38. submodules: true
  39. - name: Cache build
  40. id: cache-build
  41. uses: actions/cache@v2
  42. with:
  43. path: |
  44. ~/build
  45. ~/components/wifi-manager/webapp/node_modules
  46. /var/lib/docker
  47. key: ${{ runner.os }}-${{ matrix.node }}
  48. - name: Set build parameters
  49. run: |
  50. echo "''' '''" > ./components/spotify/cspot/bell/nanopb/generator/proto/nanopb_pb2.py
  51. git update-index --chmod=+x ./server_certs/getcert.sh
  52. git update-index --chmod=+x ./components/spotify/cspot/bell/nanopb/generator/protoc
  53. git update-index --chmod=+x ./components/spotify/cspot/bell/nanopb/generator/protoc-gen-nanopb
  54. git update-index --chmod=+x ./components/spotify/cspot/bell/nanopb/generator/*.py
  55. git update-index --chmod=+x ./components/spotify/cspot/bell/nanopb/generator/*.py2
  56. git update-index --chmod=+x ./components/spotify/cspot/bell/nanopb/generator/proto/*.py
  57. cd server_certs;./getcert.sh;cat github.pem;cd ..
  58. shopt -s nocasematch
  59. branch_name="${GITHUB_REF//refs\/heads\//}"
  60. branch_name="${branch_name//[^a-zA-Z0-9\-~!@_\.]/}"
  61. BUILD_NUMBER=${{ needs.job1.outputs.build_number }}
  62. echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
  63. echo "DOCKER_IMAGE_NAME=sle118/squeezelite-esp32-idfv4-master" >> $GITHUB_ENV
  64. tag="${TARGET_BUILD_NAME}.${{matrix.depth}}.${BUILD_NUMBER}.${branch_name}"
  65. echo "tag=${tag}" >> $GITHUB_ENV
  66. last_commit="$(git log --pretty=format:'%s' --max-count=1)"
  67. if [[ "$last_commit" =~ .*"Release".* ]]; then echo "release_flag=1" >> $GITHUB_ENV; else echo "release_flag=0" >> $GITHUB_ENV; fi
  68. name="1.${BUILD_NUMBER}-${{matrix.depth}}#v4.0#${TARGET_BUILD_NAME}#${branch_name}"
  69. artifact_prefix="squeezelite-esp32-${branch_name}-${TARGET_BUILD_NAME}-${{matrix.depth}}-${build_version_prefix}${BUILD_NUMBER}"
  70. artifact_file_name="${artifact_prefix}.zip"
  71. artifact_bin_file_name="${artifact_prefix}.bin"
  72. echo "name=${name}" >> $GITHUB_ENV
  73. echo "last_commit=${last_commit}" >> $GITHUB_ENV
  74. echo "artifact_file_name=${artifact_file_name}" >> $GITHUB_ENV
  75. echo "PROJECT_VER=${TARGET_BUILD_NAME}-${{ steps.buildnumber.outputs.build_number }} " >> $GITHUB_ENV
  76. echo "artifact_bin_file_name=${artifact_bin_file_name}" >> $GITHUB_ENV
  77. description=""
  78. description=${description}$'------------------------------\n### Revision Log\n\n'
  79. description="$description$(git log --pretty=format:'%h %s (%cI) <%an>' --abbrev-commit --max-count=15 | sed --r 's/(^[\*]+)/\\\1/g') "
  80. echo 'description<<~EOD' >> $GITHUB_ENV
  81. echo ${description}>> $GITHUB_ENV
  82. echo '~EOD' >> $GITHUB_ENV
  83. echo #######
  84. echo ####### Environment
  85. echo #######
  86. env
  87. echo #######
  88. echo ####### GITHUB ENV
  89. echo #######
  90. cat $GITHUB_ENV
  91. - name: Build the firmware
  92. run: |
  93. env | grep "artifact\|tag\|GITHUB\|version\|NUMBER\|TARGET" >${TARGET_BUILD_NAME}-env.txt
  94. echo "${tag}" >version.txt
  95. echo pulling custom docker image ${DOCKER_IMAGE_NAME}
  96. docker pull ${DOCKER_IMAGE_NAME}
  97. docker run --env-file=${TARGET_BUILD_NAME}-env.txt -v $PWD:/project -w /project ${DOCKER_IMAGE_NAME} /bin/bash -c "pushd components/wifi-manager/webapp/ && npm install && npm run-script build && popd"
  98. docker run --env-file=${TARGET_BUILD_NAME}-env.txt -v $PWD:/project -w /project ${DOCKER_IMAGE_NAME} /bin/bash -c "cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig"
  99. docker run --env-file=${TARGET_BUILD_NAME}-env.txt -v $PWD:/project -w /project ${DOCKER_IMAGE_NAME} /bin/bash -c "idf.py build -DDEPTH=${{ matrix.depth }} -DBUILD_NUMBER=${BUILD_NUMBER}-${{ matrix.depth }} "
  100. docker run --env-file=${TARGET_BUILD_NAME}-env.txt -v $PWD:/project -w /project ${DOCKER_IMAGE_NAME} /bin/bash -c "zip -r build_output.zip build && zip build/${artifact_file_name} partitions*.csv build/*.bin build/bootloader/bootloader.bin build/partition_table/partition-table.bin build/flash_project_args build/size_*.txt"
  101. # - name: Build Mock firmware
  102. # run: |
  103. # mkdir -p build
  104. # cd build
  105. # mkdir -p partition_table
  106. # mkdir -p bootloader
  107. # echo "mock content"> squeezelite.bin
  108. # echo "mock content"> recovery.bin
  109. # echo "mock content"> ./bootloader/bootloader.bin
  110. # echo "mock content"> ./partition_table/partition-table.bin
  111. # echo "mock content"> flash_project_args
  112. # echo "mock content"> size_comp1.txt
  113. # echo "mock content"> size_comp2.txt
  114. # echo "mock content"> ../partitions.csv
  115. - uses: actions/upload-artifact@v2
  116. with:
  117. name: ${{ env.artifact_file_name }}
  118. path: |
  119. build/*.bin
  120. build/bootloader/bootloader.bin
  121. build/partition_table/partition-table.bin
  122. build/flash_project_args
  123. build/size_comp1.txt
  124. build/size_comp2.txt
  125. partitions.csv
  126. sdkconfig
  127. server_certs/github.pem
  128. build_output.zip
  129. - uses: actions/upload-artifact@v2
  130. with:
  131. name: ${{ env.artifact_bin_file_name }}
  132. path: |
  133. build/squeezelite.bin
  134. - name: Create Release
  135. if: env.release_flag == 1
  136. id: create_release
  137. uses: actions/create-release@v1
  138. env:
  139. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
  140. with:
  141. tag_name: ${{ env.tag }}
  142. release_name: ${{ env.name }}
  143. body: ${{ env.description }}
  144. draft: false
  145. prerelease: true
  146. - name: Upload Release Asset - Squeezelite binary file
  147. if: env.release_flag == 1
  148. id: upload-release-asset
  149. uses: actions/upload-release-asset@v1
  150. env:
  151. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  152. with:
  153. 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
  154. asset_path: build/squeezelite.bin
  155. asset_name: ${{ env.artifact_bin_file_name }}
  156. asset_content_type: application/octet-stream
  157. - name: Upload Release Asset - Zip file
  158. if: env.release_flag == 1
  159. id: upload-release-asset-zip
  160. uses: actions/upload-release-asset@v1
  161. env:
  162. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  163. with:
  164. 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
  165. asset_path: build/${{ env.artifact_file_name }}
  166. asset_name: ${{ env.artifact_file_name }}
  167. asset_content_type: application/octet-stream