CrossBuild.yml 6.3 KB

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