CrossBuild.yml 6.8 KB

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