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