ci.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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: Create directory for artifacts
  74. run: mkdir artifacts
  75. - name: Get bootloader
  76. uses: actions/download-artifact@v2
  77. with:
  78. name: bootloader_f4
  79. path: artifacts/bootloader
  80. - name: Get firmware
  81. uses: actions/download-artifact@v2
  82. with:
  83. name: firmware_f4
  84. path: artifacts/firmware
  85. - name: Upload bootloader
  86. uses: burnett01/rsync-deployments@4.1
  87. with:
  88. switches: -avzp --delete
  89. path: artifacts/bootloader
  90. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  91. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  92. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  93. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  94. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  95. - name: Upload firmware
  96. uses: burnett01/rsync-deployments@4.1
  97. with:
  98. switches: -avzp --delete
  99. path: artifacts/firmware
  100. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  101. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  102. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  103. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  104. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  105. fullfirmware:
  106. name: Create latest full firmware
  107. needs: upload
  108. if: github.ref == 'refs/heads/master'
  109. runs-on: [self-hosted]
  110. steps:
  111. - name: Get bootloader
  112. uses: actions/download-artifact@v2
  113. with:
  114. name: bootloader_f4
  115. path: bootloader
  116. - name: Get firmware
  117. uses: actions/download-artifact@v2
  118. with:
  119. name: firmware_f4
  120. path: firmware
  121. - name: cp
  122. run: cp ./bootloader/bootloader.bin full_firmware_latest.bin
  123. - name: truncate
  124. run: truncate -s 32768 full_firmware_latest.bin
  125. - name: cat
  126. run: cat ./firmware/firmware.bin >> full_firmware_latest.bin
  127. - name: ls
  128. run: ls -R
  129. - name: Upload fullfirmware
  130. uses: burnett01/rsync-deployments@4.1
  131. with:
  132. switches: -avzp --delete
  133. path: full_firmware_latest.bin
  134. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  135. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  136. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  137. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  138. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  139. genpic:
  140. name: Generate pic
  141. needs: fullfirmware
  142. if: github.ref == 'refs/heads/master'
  143. runs-on: [self-hosted]
  144. steps:
  145. - name: Checkout code
  146. uses: actions/checkout@v2
  147. with:
  148. fetch-depth: 0
  149. ref: master
  150. submodules: true
  151. - name: Set test env
  152. run: echo "NUMBER_OF_COMMITS=$(git rev-list --count HEAD)" >> $GITHUB_ENV
  153. - name: Test output NUMBER_OF_COMMITS
  154. run: echo $NUMBER_OF_COMMITS
  155. - name: Test output date
  156. run: |
  157. GET_DATE=$(date +"%b %d")
  158. PREP_DATE=$(echo "${GET_DATE^^}")
  159. echo "PREP_DATE=$PREP_DATE" >> $GITHUB_ENV
  160. - name: Test output PREP_DATE
  161. run: echo $PREP_DATE
  162. - name: Gen pic
  163. 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
  164. - name: Upload pic
  165. uses: burnett01/rsync-deployments@4.1
  166. with:
  167. switches: -avzp --delete
  168. path: latest-firmware-banner.png
  169. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  170. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  171. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  172. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  173. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}