ci.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. name: 'CI'
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'wiki/**'
  6. - 'wiki_static/**'
  7. jobs:
  8. build:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: Checkout code
  12. uses: actions/checkout@v2
  13. with:
  14. fetch-depth: 0
  15. submodules: true
  16. - uses: satackey/action-docker-layer-caching@v0.0.8
  17. continue-on-error: true
  18. with:
  19. key: docker-cache-${{ hashFiles('docker/**') }}-{hash}
  20. restore-keys: docker-cache-${{ hashFiles('docker/**') }}-
  21. - name: Build docker image
  22. uses: ./.github/actions/docker
  23. - name: Check syntax
  24. uses: ./.github/actions/docker
  25. continue-on-error: false
  26. with:
  27. run: /syntax_check.sh
  28. - name: Build F2 bootloader in docker
  29. uses: ./.github/actions/docker
  30. with:
  31. run: make -C bootloader TARGET=f2
  32. - name: Publish F2 bootloader artifacts
  33. uses: actions/upload-artifact@v2
  34. with:
  35. name: bootloader_f2
  36. path: |
  37. bootloader/.obj/f2/bootloader.elf
  38. bootloader/.obj/f2/bootloader.bin
  39. bootloader/.obj/f2/bootloader.hex
  40. if-no-files-found: error
  41. retention-days: 7
  42. - name: Build local testing firmware in docker
  43. uses: ./.github/actions/docker
  44. with:
  45. run: make -C firmware TARGET=local
  46. - name: Run local tests
  47. uses: ./.github/actions/docker
  48. with:
  49. run: make -C firmware TARGET=local APP_TEST=1 run
  50. - name: Build F2 firmware in docker
  51. uses: ./.github/actions/docker
  52. with:
  53. run: make -C firmware TARGET=f2 APP_RELEASE=1
  54. - name: Publish F2 firmware artifacts
  55. uses: actions/upload-artifact@v2
  56. with:
  57. name: firmware_f2
  58. path: |
  59. firmware/.obj/f2/firmware.elf
  60. firmware/.obj/f2/firmware.bin
  61. firmware/.obj/f2/firmware.hex
  62. if-no-files-found: error
  63. retention-days: 7
  64. - name: Build F3 bootloader in docker
  65. uses: ./.github/actions/docker
  66. with:
  67. run: make -C bootloader TARGET=f3
  68. - name: Publish F3 bootloader artifacts
  69. uses: actions/upload-artifact@v2
  70. with:
  71. name: bootloader_f3
  72. path: |
  73. bootloader/.obj/f3/bootloader.elf
  74. bootloader/.obj/f3/bootloader.bin
  75. bootloader/.obj/f3/bootloader.hex
  76. if-no-files-found: error
  77. retention-days: 7
  78. - name: Build F3 firmware in docker
  79. uses: ./.github/actions/docker
  80. with:
  81. run: make -C firmware TARGET=f3 APP_RELEASE=1
  82. - name: Publish F3 firmware artifacts
  83. uses: actions/upload-artifact@v2
  84. with:
  85. name: firmware_f3
  86. path: |
  87. firmware/.obj/f3/firmware.elf
  88. firmware/.obj/f3/firmware.bin
  89. firmware/.obj/f3/firmware.hex
  90. if-no-files-found: error
  91. retention-days: 7
  92. upload:
  93. name: Upload artifacts to external storage
  94. needs: build
  95. runs-on: ubuntu-latest
  96. steps:
  97. - name: Get bootloader
  98. uses: actions/download-artifact@v2
  99. with:
  100. name: bootloader_f3
  101. path: bootloader
  102. - name: Get firmware
  103. uses: actions/download-artifact@v2
  104. with:
  105. name: firmware_f3
  106. path: firmware
  107. - name: Upload bootloader
  108. uses: burnett01/rsync-deployments@4.1
  109. with:
  110. switches: -avzp --delete
  111. path: bootloader
  112. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  113. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  114. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  115. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  116. - name: Upload firmware
  117. uses: burnett01/rsync-deployments@4.1
  118. with:
  119. switches: -avzp --delete
  120. path: firmware
  121. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  122. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  123. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  124. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  125. fullfirmware:
  126. name: Create latest full firmware
  127. needs: upload
  128. if: github.ref == 'refs/heads/master'
  129. runs-on: ubuntu-latest
  130. steps:
  131. - name: Get bootloader
  132. uses: actions/download-artifact@v2
  133. with:
  134. name: bootloader_f3
  135. path: bootloader
  136. - name: Get firmware
  137. uses: actions/download-artifact@v2
  138. with:
  139. name: firmware_f3
  140. path: firmware
  141. - name: cp
  142. run: cp ./bootloader/bootloader.bin full_firmware_latest.bin
  143. - name: truncate
  144. run: truncate -s 32768 full_firmware_latest.bin
  145. - name: cat
  146. run: cat ./firmware/firmware.bin >> full_firmware_latest.bin
  147. - name: ls
  148. run: ls -R
  149. - name: Upload fullfirmware
  150. uses: burnett01/rsync-deployments@4.1
  151. with:
  152. switches: -avzp --delete
  153. path: full_firmware_latest.bin
  154. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  155. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  156. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  157. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  158. genpic:
  159. name: Generate pic
  160. needs: fullfirmware
  161. if: github.ref == 'refs/heads/master'
  162. runs-on: ubuntu-latest
  163. steps:
  164. - name: Checkout code
  165. uses: actions/checkout@v2
  166. with:
  167. fetch-depth: 0
  168. ref: master
  169. submodules: true
  170. - name: Set test env
  171. run: echo "NUMBER_OF_COMMITS=$(git rev-list --count HEAD)" >> $GITHUB_ENV
  172. - name: Test output NUMBER_OF_COMMITS
  173. run: echo $NUMBER_OF_COMMITS
  174. - name: Test output date
  175. run: |
  176. GET_DATE=$(date +"%b %d")
  177. PREP_DATE=$(echo "${GET_DATE^^}")
  178. echo "PREP_DATE=$PREP_DATE" >> $GITHUB_ENV
  179. - name: Test output PREP_DATE
  180. run: echo $PREP_DATE
  181. - name: Gen pic
  182. run: convert ./.github/assets/latest-firmware-template.png -font ./.github/assets/Born2bSportyV2.ttf -weight 700 -pointsize 140 -annotate +900+330 "$NUMBER_OF_COMMITS $PREP_DATE" latest-firmware-banner.png
  183. - name: Upload pic
  184. uses: burnett01/rsync-deployments@4.1
  185. with:
  186. switches: -avzp --delete
  187. path: latest-firmware-banner.png
  188. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  189. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  190. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  191. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}