ci.yml 6.8 KB

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