ci.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. name: 'CI'
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'wiki/**'
  6. - 'wiki_static/**'
  7. jobs:
  8. build:
  9. runs-on: [self-hosted]
  10. steps:
  11. - name: Cleanup workspace
  12. uses: AutoModality/action-clean@v1
  13. - name: Checkout code
  14. uses: actions/checkout@v2
  15. with:
  16. fetch-depth: 0
  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 F4 bootloader in docker
  31. uses: ./.github/actions/docker
  32. with:
  33. run: make -C bootloader TARGET=f4
  34. - name: Generate dfu file for bootloader
  35. uses: ./.github/actions/docker
  36. with:
  37. run: hex2dfu -i bootloader/.obj/f4/bootloader.hex -o bootloader/.obj/f4/bootloader.dfu
  38. - name: Publish F4 bootloader artifacts
  39. uses: actions/upload-artifact@v2
  40. with:
  41. name: bootloader_f4
  42. path: |
  43. bootloader/.obj/f4/bootloader.elf
  44. bootloader/.obj/f4/bootloader.bin
  45. bootloader/.obj/f4/bootloader.hex
  46. bootloader/.obj/f4/bootloader.dfu
  47. if-no-files-found: error
  48. retention-days: 7
  49. - name: Build F4 firmware in docker
  50. uses: ./.github/actions/docker
  51. with:
  52. run: make -C firmware TARGET=f4 APP_RELEASE=1
  53. - name: Generate dfu file for firmware
  54. uses: ./.github/actions/docker
  55. with:
  56. run: hex2dfu -i firmware/.obj/f4/firmware.hex -o firmware/.obj/f4/firmware.dfu
  57. - name: Publish F4 firmware artifacts
  58. uses: actions/upload-artifact@v2
  59. with:
  60. name: firmware_f4
  61. path: |
  62. firmware/.obj/f4/firmware.elf
  63. firmware/.obj/f4/firmware.bin
  64. firmware/.obj/f4/firmware.hex
  65. firmware/.obj/f4/firmware.dfu
  66. if-no-files-found: error
  67. retention-days: 7
  68. upload:
  69. name: Upload artifacts to external storage
  70. needs: build
  71. runs-on: [self-hosted]
  72. steps:
  73. - name: Force remove artifacts dir
  74. run: rm -rf artifacts
  75. - name: Create directory for artifacts
  76. run: mkdir artifacts
  77. - name: Get bootloader
  78. uses: actions/download-artifact@v2
  79. with:
  80. name: bootloader_f4
  81. path: artifacts/bootloader
  82. - name: Get firmware
  83. uses: actions/download-artifact@v2
  84. with:
  85. name: firmware_f4
  86. path: artifacts/firmware
  87. - name: Upload bootloader
  88. uses: burnett01/rsync-deployments@4.1
  89. with:
  90. switches: -avzp --delete
  91. path: artifacts/bootloader
  92. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  93. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  94. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  95. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  96. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  97. - name: Upload firmware
  98. uses: burnett01/rsync-deployments@4.1
  99. with:
  100. switches: -avzp --delete
  101. path: artifacts/firmware
  102. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  103. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  104. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  105. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  106. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  107. fullfirmware:
  108. name: Create latest full firmware
  109. needs: upload
  110. if: github.ref == 'refs/heads/master'
  111. runs-on: [self-hosted]
  112. steps:
  113. - name: Get bootloader
  114. uses: actions/download-artifact@v2
  115. with:
  116. name: bootloader_f4
  117. path: bootloader
  118. - name: Get firmware
  119. uses: actions/download-artifact@v2
  120. with:
  121. name: firmware_f4
  122. path: firmware
  123. - name: cp
  124. run: cp ./bootloader/bootloader.bin full_firmware_latest.bin
  125. - name: truncate
  126. run: truncate -s 32768 full_firmware_latest.bin
  127. - name: cat
  128. run: cat ./firmware/firmware.bin >> full_firmware_latest.bin
  129. - name: ls
  130. run: ls -R
  131. - name: Upload fullfirmware
  132. uses: burnett01/rsync-deployments@4.1
  133. with:
  134. switches: -avzp --delete
  135. path: full_firmware_latest.bin
  136. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  137. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  138. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  139. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  140. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  141. genpic:
  142. name: Generate pic
  143. needs: fullfirmware
  144. if: github.ref == 'refs/heads/master'
  145. runs-on: [self-hosted]
  146. steps:
  147. - name: Checkout code
  148. uses: actions/checkout@v2
  149. with:
  150. fetch-depth: 0
  151. ref: master
  152. submodules: true
  153. - name: Set test env
  154. run: echo "NUMBER_OF_COMMITS=$(git rev-list --count HEAD)" >> $GITHUB_ENV
  155. - name: Test output NUMBER_OF_COMMITS
  156. run: echo $NUMBER_OF_COMMITS
  157. - name: Test output date
  158. run: |
  159. GET_DATE=$(date +"%b %d")
  160. PREP_DATE=$(echo "${GET_DATE^^}")
  161. echo "PREP_DATE=$PREP_DATE" >> $GITHUB_ENV
  162. - name: Test output PREP_DATE
  163. run: echo $PREP_DATE
  164. - name: Gen pic
  165. 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
  166. - name: Upload pic
  167. uses: burnett01/rsync-deployments@4.1
  168. with:
  169. switches: -avzp --delete
  170. path: latest-firmware-banner.png
  171. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  172. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  173. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  174. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  175. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}