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

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