CrossBuild.yml 6.9 KB

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