tools.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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@v3
  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@v3
  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@v3
  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@v3
  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@v3
  118. with:
  119. name: linux-buildbot-logs
  120. path: openwrt/logs
  121. - name: Upload config
  122. if: always()
  123. uses: actions/upload-artifact@v3
  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@v3
  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. # Per branch tools container tag
  153. # By default stick to latest
  154. # For official test targetting openwrt stable branch
  155. # Get the branch or parse the tag and push dedicated tools containers
  156. # Any branch that will match this pattern openwrt-[0-9][0-9].[0-9][0-9]
  157. # will refresh the tools container with the matching tag.
  158. # (example branch openwrt-22.03 -> tools:openwrt-22.03)
  159. # (example branch openwrt-22.03-test -> tools:openwrt-22.03)
  160. - name: Determine tools container tag
  161. run: |
  162. CONTAINER_TAG=latest
  163. if [ ${{ github.ref_type }} == "branch" ]; then
  164. if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
  165. CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\).*/\1/')"
  166. fi
  167. elif [ ${{ github.ref_type }} == "tag" ]; then
  168. if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
  169. CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
  170. fi
  171. fi
  172. echo "Tools container to push tools:$CONTAINER_TAG"
  173. echo "CONTAINER_TAG=$CONTAINER_TAG" >> "$GITHUB_ENV"
  174. - name: Checkout
  175. uses: actions/checkout@v3
  176. with:
  177. path: 'openwrt'
  178. - name: Download prebuilt tools from build job
  179. uses: actions/download-artifact@v3
  180. with:
  181. name: linux-buildbot-prebuilt-tools
  182. path: openwrt
  183. - name: Login to GitHub Container Registry
  184. uses: docker/login-action@v2
  185. with:
  186. registry: ghcr.io
  187. username: ${{ github.actor }}
  188. password: ${{ secrets.GITHUB_TOKEN }}
  189. - name: Build and push
  190. uses: docker/build-push-action@v3
  191. with:
  192. context: openwrt
  193. push: true
  194. tags: ghcr.io/${{ env.OWNER_LC }}/tools:${{ env.CONTAINER_TAG }}
  195. file: openwrt/.github/workflows/Dockerfile.tools