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

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