ci.yml 6.8 KB

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