ci.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  115. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  116. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  117. - name: Upload firmware
  118. uses: burnett01/rsync-deployments@4.1
  119. with:
  120. switches: -avzp --delete
  121. path: firmware
  122. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  123. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  124. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  125. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  126. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  127. fullfirmware:
  128. name: Create latest full firmware
  129. needs: upload
  130. if: github.ref == 'refs/heads/master'
  131. runs-on: ubuntu-latest
  132. steps:
  133. - name: Get bootloader
  134. uses: actions/download-artifact@v2
  135. with:
  136. name: bootloader_f3
  137. path: bootloader
  138. - name: Get firmware
  139. uses: actions/download-artifact@v2
  140. with:
  141. name: firmware_f3
  142. path: firmware
  143. - name: cp
  144. run: cp ./bootloader/bootloader.bin full_firmware_latest.bin
  145. - name: truncate
  146. run: truncate -s 32768 full_firmware_latest.bin
  147. - name: cat
  148. run: cat ./firmware/firmware.bin >> full_firmware_latest.bin
  149. - name: ls
  150. run: ls -R
  151. - name: Upload fullfirmware
  152. uses: burnett01/rsync-deployments@4.1
  153. with:
  154. switches: -avzp --delete
  155. path: full_firmware_latest.bin
  156. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  157. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  158. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  159. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  160. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  161. genpic:
  162. name: Generate pic
  163. needs: fullfirmware
  164. if: github.ref == 'refs/heads/master'
  165. runs-on: ubuntu-latest
  166. steps:
  167. - name: Checkout code
  168. uses: actions/checkout@v2
  169. with:
  170. fetch-depth: 0
  171. ref: master
  172. submodules: true
  173. - name: Set test env
  174. run: echo "NUMBER_OF_COMMITS=$(git rev-list --count HEAD)" >> $GITHUB_ENV
  175. - name: Test output NUMBER_OF_COMMITS
  176. run: echo $NUMBER_OF_COMMITS
  177. - name: Test output date
  178. run: |
  179. GET_DATE=$(date +"%b %d")
  180. PREP_DATE=$(echo "${GET_DATE^^}")
  181. echo "PREP_DATE=$PREP_DATE" >> $GITHUB_ENV
  182. - name: Test output PREP_DATE
  183. run: echo $PREP_DATE
  184. - name: Gen pic
  185. 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
  186. - name: Upload pic
  187. uses: burnett01/rsync-deployments@4.1
  188. with:
  189. switches: -avzp --delete
  190. path: latest-firmware-banner.png
  191. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  192. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  193. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  194. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  195. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}