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

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