tools.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 AUTOREMOVE config 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. - name: Make prereq
  107. shell: su buildbot -c "sh -e {0}"
  108. working-directory: openwrt
  109. run: make defconfig
  110. - name: Build tools BuildBot Container
  111. shell: su buildbot -c "sh -e {0}"
  112. working-directory: openwrt
  113. run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  114. - name: Upload logs
  115. if: always()
  116. uses: actions/upload-artifact@v2
  117. with:
  118. name: linux-buildbot-logs
  119. path: openwrt/logs
  120. - name: Upload config
  121. if: always()
  122. uses: actions/upload-artifact@v2
  123. with:
  124. name: linux-buildbot-config
  125. path: openwrt/.config
  126. - name: Archive prebuilt tools
  127. if: github.event_name == 'push'
  128. shell: su buildbot -c "sh -e {0}"
  129. working-directory: openwrt
  130. run: tar --mtime=now -cf tools.tar staging_dir/host build_dir/host dl
  131. - name: Upload prebuilt tools
  132. if: github.event_name == 'push'
  133. uses: actions/upload-artifact@v2
  134. with:
  135. name: linux-buildbot-prebuilt-tools
  136. path: openwrt/tools.tar
  137. retention-days: 1
  138. push-tools-container:
  139. needs: build-linux-buildbot
  140. runs-on: ubuntu-latest
  141. if: github.event_name == 'push'
  142. permissions:
  143. contents: read
  144. packages: write
  145. steps:
  146. - name: Checkout
  147. uses: actions/checkout@v2
  148. with:
  149. path: 'openwrt'
  150. - name: Download prebuilt tools from build job
  151. uses: actions/download-artifact@v2
  152. with:
  153. name: linux-buildbot-prebuilt-tools
  154. path: openwrt
  155. - name: Login to GitHub Container Registry
  156. uses: docker/login-action@v2
  157. with:
  158. registry: ghcr.io
  159. username: ${{ github.actor }}
  160. password: ${{ secrets.GITHUB_TOKEN }}
  161. - name: Build and push
  162. uses: docker/build-push-action@v3
  163. with:
  164. context: openwrt
  165. push: true
  166. tags: ghcr.io/${{ github.repository_owner }}/tools:latest
  167. file: openwrt/.github/workflows/Dockerfile.tools