tools.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. name: Build host tools
  2. on:
  3. pull_request:
  4. paths:
  5. - 'tools/**'
  6. - '.github/workflows/tools.yml'
  7. push:
  8. paths:
  9. - 'tools/**'
  10. - '.github/workflows/tools.yml'
  11. permissions:
  12. contents: read
  13. jobs:
  14. build-macos-latest:
  15. if: github.event_name != 'push'
  16. runs-on: macos-latest
  17. steps:
  18. - name: Checkout
  19. uses: actions/checkout@v2
  20. with:
  21. path: openwrt
  22. - name: Setup MacOS
  23. run: |
  24. echo "WORKPATH=/Volumes/OpenWrt" >> "$GITHUB_ENV"
  25. hdiutil create -size 20g -type SPARSE -fs "Case-sensitive HFS+" -volname OpenWrt OpenWrt.sparseimage
  26. hdiutil attach OpenWrt.sparseimage
  27. mv "$GITHUB_WORKSPACE/openwrt" /Volumes/OpenWrt/
  28. - name: Install required prereq on MacOS
  29. working-directory: ${{ env.WORKPATH }}/openwrt
  30. run: |
  31. brew install \
  32. autoconf \
  33. automake \
  34. coreutils \
  35. diffutils \
  36. findutils \
  37. gawk \
  38. gettext \
  39. git-extras \
  40. gmp \
  41. gnu-getopt \
  42. gnu-sed \
  43. gnu-tar \
  44. grep \
  45. libidn2 \
  46. libunistring \
  47. m4 \
  48. make \
  49. mpfr \
  50. ncurses \
  51. [email protected] \
  52. pcre \
  53. pkg-config \
  54. quilt \
  55. readline \
  56. wget \
  57. zstd
  58. echo "/bin" >> "$GITHUB_PATH"
  59. echo "/sbin/Library/Apple/usr/bin" >> "$GITHUB_PATH"
  60. echo "/usr/bin" >> "$GITHUB_PATH"
  61. echo "/usr/local/bin" >> "$GITHUB_PATH"
  62. echo "/usr/local/opt/coreutils/bin" >> "$GITHUB_PATH"
  63. echo "/usr/local/opt/findutils/libexec/gnubin" >> "$GITHUB_PATH"
  64. echo "/usr/local/opt/gettext/bin" >> "$GITHUB_PATH"
  65. echo "/usr/local/opt/gnu-getopt/bin" >> "$GITHUB_PATH"
  66. echo "/usr/local/opt/make/libexec/gnubin" >> "$GITHUB_PATH"
  67. echo "/usr/local/opt/make/libexec/gnubin" >> "$GITHUB_PATH"
  68. echo "/usr/sbin" >> "$GITHUB_PATH"
  69. - name: Make prereq
  70. working-directory: ${{ env.WORKPATH }}/openwrt
  71. run: make defconfig
  72. - name: Build tools MacOS
  73. working-directory: ${{ env.WORKPATH }}/openwrt
  74. run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  75. - name: Upload logs
  76. if: always()
  77. uses: actions/upload-artifact@v2
  78. with:
  79. name: macos-latest-logs
  80. path: ${{ env.WORKPATH }}/openwrt/logs
  81. - name: Upload config
  82. if: always()
  83. uses: actions/upload-artifact@v2
  84. with:
  85. name: macos-latest-config
  86. path: ${{ env.WORKPATH }}/openwrt/.config
  87. build-linux-buildbot:
  88. runs-on: ubuntu-latest
  89. container: registry.gitlab.com/openwrt/buildbot/buildworker-3.4.1
  90. steps:
  91. - name: Checkout
  92. uses: actions/checkout@v2
  93. with:
  94. path: 'openwrt'
  95. - name: Fix permission
  96. run: |
  97. chown -R buildbot:buildbot openwrt
  98. - name: Set configs for tools container
  99. if: github.event_name == 'push'
  100. shell: su buildbot -c "sh -e {0}"
  101. working-directory: openwrt
  102. run: |
  103. touch .config
  104. echo CONFIG_DEVEL=y >> .config
  105. echo CONFIG_AUTOREMOVE=y >> .config
  106. echo CONFIG_CCACHE=y >> .config
  107. - name: Make prereq
  108. shell: su buildbot -c "sh -e {0}"
  109. working-directory: openwrt
  110. run: make defconfig
  111. - name: Build tools BuildBot Container
  112. shell: su buildbot -c "sh -e {0}"
  113. working-directory: openwrt
  114. run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  115. - name: Upload logs
  116. if: always()
  117. uses: actions/upload-artifact@v2
  118. with:
  119. name: linux-buildbot-logs
  120. path: openwrt/logs
  121. - name: Upload config
  122. if: always()
  123. uses: actions/upload-artifact@v2
  124. with:
  125. name: linux-buildbot-config
  126. path: openwrt/.config
  127. - name: Archive prebuilt tools
  128. if: github.event_name == 'push'
  129. shell: su buildbot -c "sh -e {0}"
  130. working-directory: openwrt
  131. run: tar --mtime=now -cf tools.tar staging_dir/host build_dir/host dl
  132. - name: Upload prebuilt tools
  133. if: github.event_name == 'push'
  134. uses: actions/upload-artifact@v2
  135. with:
  136. name: linux-buildbot-prebuilt-tools
  137. path: openwrt/tools.tar
  138. retention-days: 1
  139. push-tools-container:
  140. needs: build-linux-buildbot
  141. runs-on: ubuntu-latest
  142. if: github.event_name == 'push'
  143. permissions:
  144. contents: read
  145. packages: write
  146. steps:
  147. - name: Set lower case owner name
  148. env:
  149. OWNER: ${{ github.repository_owner }}
  150. run: |
  151. echo "OWNER_LC=${OWNER,,}" >> "$GITHUB_ENV"
  152. - name: Checkout
  153. uses: actions/checkout@v2
  154. with:
  155. path: 'openwrt'
  156. - name: Download prebuilt tools from build job
  157. uses: actions/download-artifact@v2
  158. with:
  159. name: linux-buildbot-prebuilt-tools
  160. path: openwrt
  161. - name: Login to GitHub Container Registry
  162. uses: docker/login-action@v2
  163. with:
  164. registry: ghcr.io
  165. username: ${{ github.actor }}
  166. password: ${{ secrets.GITHUB_TOKEN }}
  167. - name: Build and push
  168. uses: docker/build-push-action@v3
  169. with:
  170. context: openwrt
  171. push: true
  172. tags: ghcr.io/${{ env.OWNER_LC }}/tools:latest
  173. file: openwrt/.github/workflows/Dockerfile.tools