CrossBuild.yml 6.6 KB

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