ci.yml 6.0 KB

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