30 runs-on: ubuntu-latest
32 owner_lc: ${{ steps.lower_owner.outputs.owner_lc }}
33 ccache_hash: ${{ steps.ccache_hash.outputs.ccache_hash }}
34 container_tag: ${{ steps.determine_tools_container.outputs.container_tag }}
38 uses: actions/checkout@v3
40 - name: Set lower case owner name
43 OWNER_LC=$(echo "${{ github.repository_owner }}" \
44 | tr '[:upper:]' '[:lower:]')
45 echo "owner_lc=$OWNER_LC" >> $GITHUB_OUTPUT
47 - name: Generate ccache hash
50 CCACHE_HASH=$(md5sum include/kernel-* | awk '{ print $1 }' \
51 | md5sum | awk '{ print $1 }')
52 echo "ccache_hash=$CCACHE_HASH" >> $GITHUB_OUTPUT
54 # Per branch tools container tag
55 # By default stick to latest
56 # For official test targetting openwrt stable branch
57 # Get the branch or parse the tag and push dedicated tools containers
58 # For local test to use the correct container for stable release testing
59 # you need to use for the branch name a prefix of openwrt-[0-9][0-9].[0-9][0-9]-
60 - name: Determine tools container tag
61 id: determine_tools_container
64 if [ -n "${{ github.base_ref }}" ]; then
65 if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
66 CONTAINER_TAG="${{ github.base_ref }}"
68 elif [ ${{ github.ref_type }} == "branch" ]; then
69 if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
70 CONTAINER_TAG=${{ github.ref_name }}
71 elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
72 CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
74 elif [ ${{ github.ref_type }} == "tag" ]; then
75 if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
76 CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
79 echo "Tools container to use tools:$CONTAINER_TAG"
80 echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
83 name: Build with external toolchain
85 runs-on: ubuntu-latest
87 container: ghcr.io/${{ needs.setup_build.outputs.owner_lc }}/tools:${{ needs.setup_build.outputs.container_tag }}
94 - name: Checkout master directory
95 uses: actions/checkout@v3
99 - name: Checkout packages feed
100 if: inputs.include_feeds == true
101 uses: actions/checkout@v3
103 repository: openwrt/packages
104 path: openwrt/feeds/packages
106 - name: Checkout luci feed
107 if: inputs.include_feeds == true
108 uses: actions/checkout@v3
110 repository: openwrt/luci
111 path: openwrt/feeds/luci
113 - name: Checkout routing feed
114 if: inputs.include_feeds == true
115 uses: actions/checkout@v3
117 repository: openwrt/routing
118 path: openwrt/feeds/routing
120 - name: Checkout telephony feed
121 if: inputs.include_feeds == true
122 uses: actions/checkout@v3
124 repository: openwrt/telephony
125 path: openwrt/feeds/telephony
127 - name: Fix permission
129 chown -R buildbot:buildbot openwrt
131 - name: Initialization environment
133 TARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 1)
134 SUBTARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 2)
135 echo "TARGET=$TARGET" >> "$GITHUB_ENV"
136 echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
138 - name: Update & Install feeds
139 if: inputs.include_feeds == true
140 shell: su buildbot -c "sh -e {0}"
141 working-directory: openwrt
143 ./scripts/feeds update -a
144 ./scripts/feeds install -a
146 - name: Parse toolchain file
147 if: inputs.build_toolchain == false
149 working-directory: openwrt
151 TOOLCHAIN_PATH=snapshots
153 if [ -n "${{ github.base_ref }}" ]; then
154 if echo "${{ github.base_ref }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
155 major_ver="$(echo ${{ github.base_ref }} | sed 's/openwrt-/v/')"
157 elif [ "${{ github.ref_type }}" = "branch" ]; then
158 if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
159 major_ver="$(echo ${{ github.ref_name }} | sed 's/openwrt-\([0-9][0-9]\.[0-9][0-9]\)-.*/v\1/')"
161 elif [ "${{ github.ref_type }}" = "tag" ]; then
162 if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
163 major_ver="$(sed 's/\(v[0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
167 if [ -n "$major_ver" ]; then
169 latest_tag="$(git tag --sort=-creatordate -l $major_ver* | head -n1)"
170 if [ -n "$latest_tag" ]; then
171 TOOLCHAIN_PATH=releases/$(echo $latest_tag | sed 's/^v//')
175 SUMS_FILE="https://downloads.cdn.openwrt.org/$TOOLCHAIN_PATH/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums"
176 if curl $SUMS_FILE | grep -q ".*openwrt-toolchain.*tar.xz"; then
177 TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-toolchain.*tar.xz")"
178 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
179 TOOLCHAIN_SHA256=$(echo "$TOOLCHAIN_STRING" | cut -d ' ' -f 1)
181 echo "toolchain-type=external_toolchain" >> $GITHUB_OUTPUT
182 elif curl $SUMS_FILE | grep -q ".*openwrt-sdk.*tar.xz"; then
183 TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-sdk.*tar.xz")"
184 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-sdk.*\).tar.xz/\1/p')
185 TOOLCHAIN_SHA256=$(echo "$TOOLCHAIN_STRING" | cut -d ' ' -f 1)
187 echo "toolchain-type=external_sdk" >> $GITHUB_OUTPUT
190 echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
191 echo "TOOLCHAIN_SHA256=$TOOLCHAIN_SHA256" >> "$GITHUB_ENV"
192 echo "TOOLCHAIN_PATH=$TOOLCHAIN_PATH" >> "$GITHUB_ENV"
194 - name: Cache external toolchain/sdk
195 if: inputs.build_toolchain == false
196 id: cache-external-toolchain
197 uses: actions/cache@v3
199 path: openwrt/${{ env.TOOLCHAIN_FILE }}
200 key: ${{ env.TOOLCHAIN_FILE }}-${{ steps.parse-toolchain.outputs.toolchain-type }}-${{ env.TOOLCHAIN_SHA256 }}
203 uses: actions/cache@v3
205 path: openwrt/.ccache
206 key: ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-${{ needs.setup_build.outputs.ccache_hash }}
208 ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-
210 - name: Download external toolchain/sdk
211 if: inputs.build_toolchain == false && steps.cache-external-toolchain.outputs.cache-hit != 'true'
212 shell: su buildbot -c "sh -e {0}"
213 working-directory: openwrt
215 wget -O - https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${{ env.TOOLCHAIN_FILE }}.tar.xz \
218 - name: Extract prebuilt tools
219 shell: su buildbot -c "sh -e {0}"
220 working-directory: openwrt
221 run: ./scripts/ext-tools.sh --tools /tools.tar
223 - name: Configure testing kernel
224 if: inputs.testing == true
225 shell: su buildbot -c "sh -e {0}"
226 working-directory: openwrt
228 echo CONFIG_TESTING_KERNEL=y >> .config
230 - name: Configure all kernel modules
231 if: inputs.build_all_kmods == true
232 shell: su buildbot -c "sh -e {0}"
233 working-directory: openwrt
235 echo CONFIG_ALL_KMODS=y >> .config
237 - name: Configure all modules
238 if: inputs.build_all_modules == true
239 shell: su buildbot -c "sh -e {0}"
240 working-directory: openwrt
242 echo CONFIG_ALL=y >> .config
244 - name: Configure all boards
245 if: inputs.build_all_boards == true
246 shell: su buildbot -c "sh -e {0}"
247 working-directory: openwrt
249 echo CONFIG_TARGET_MULTI_PROFILE=y >> .config
250 echo CONFIG_TARGET_PER_DEVICE_ROOTFS=y >> .config
251 echo CONFIG_TARGET_ALL_PROFILES=y >> .config
253 - name: Configure external toolchain
254 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_toolchain'
255 shell: su buildbot -c "sh -e {0}"
256 working-directory: openwrt
258 echo CONFIG_DEVEL=y >> .config
259 echo CONFIG_AUTOREMOVE=y >> .config
260 echo CONFIG_CCACHE=y >> .config
262 ./scripts/ext-toolchain.sh \
263 --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
265 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
267 - name: Configure external toolchain with sdk
268 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk'
269 shell: su buildbot -c "sh -e {0}"
270 working-directory: openwrt
272 echo CONFIG_DEVEL=y >> .config
273 echo CONFIG_AUTOREMOVE=y >> .config
274 echo CONFIG_CCACHE=y >> .config
276 ./scripts/ext-toolchain.sh \
277 --toolchain ${{ env.TOOLCHAIN_FILE }}/staging_dir/toolchain-* \
279 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
281 - name: Configure internal toolchain
282 if: inputs.build_toolchain == true
283 shell: su buildbot -c "sh -e {0}"
284 working-directory: openwrt
286 echo CONFIG_DEVEL=y >> .config
287 echo CONFIG_AUTOREMOVE=y >> .config
288 echo CONFIG_CCACHE=y >> .config
290 echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config
291 echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config
295 - name: Show configuration
296 shell: su buildbot -c "sh -e {0}"
297 working-directory: openwrt
298 run: ./scripts/diffconfig.sh
301 shell: su buildbot -c "sh -e {0}"
302 working-directory: openwrt
303 run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
305 - name: Build toolchain
306 shell: su buildbot -c "sh -e {0}"
307 working-directory: openwrt
308 run: make toolchain/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
311 shell: su buildbot -c "sh -e {0}"
312 working-directory: openwrt
313 run: make target/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
315 - name: Build Kernel Kmods
316 shell: su buildbot -c "sh -e {0}"
317 working-directory: openwrt
318 run: make package/linux/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
320 - name: Build everything
321 if: inputs.build_full == true
322 shell: su buildbot -c "sh -e {0}"
323 working-directory: openwrt
324 run: make -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
328 uses: actions/upload-artifact@v3
330 name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs