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="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
72 elif [ ${{ github.ref_type }} == "tag" ]; then
73 if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
74 CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
77 echo "Tools container to use tools:$CONTAINER_TAG"
78 echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
81 name: Build with external toolchain
83 runs-on: ubuntu-latest
85 container: ghcr.io/${{ needs.setup_build.outputs.owner_lc }}/tools:${{ needs.setup_build.outputs.container_tag }}
92 - name: Checkout master directory
93 uses: actions/checkout@v3
97 - name: Checkout packages feed
98 if: inputs.include_feeds == true
99 uses: actions/checkout@v3
101 repository: openwrt/packages
102 path: openwrt/feeds/packages
104 - name: Checkout luci feed
105 if: inputs.include_feeds == true
106 uses: actions/checkout@v3
108 repository: openwrt/luci
109 path: openwrt/feeds/luci
111 - name: Checkout routing feed
112 if: inputs.include_feeds == true
113 uses: actions/checkout@v3
115 repository: openwrt/routing
116 path: openwrt/feeds/routing
118 - name: Checkout telephony feed
119 if: inputs.include_feeds == true
120 uses: actions/checkout@v3
122 repository: openwrt/telephony
123 path: openwrt/feeds/telephony
125 - name: Fix permission
127 chown -R buildbot:buildbot openwrt
129 - name: Initialization environment
131 TARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 1)
132 SUBTARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 2)
133 echo "TARGET=$TARGET" >> "$GITHUB_ENV"
134 echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
136 - name: Update & Install feeds
137 if: inputs.include_feeds == true
138 shell: su buildbot -c "sh -e {0}"
139 working-directory: openwrt
141 ./scripts/feeds update -a
142 ./scripts/feeds install -a
144 - name: Parse toolchain file
145 if: inputs.build_toolchain == false
147 working-directory: openwrt
149 TOOLCHAIN_PATH=snapshots
151 if [ -n "${{ github.base_ref }}" ]; then
152 if echo "${{ github.base_ref }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
153 major_ver="$(echo ${{ github.base_ref }} | sed 's/openwrt-/v/')"
155 elif [ "${{ github.ref_type }}" = "branch" ]; then
156 if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
157 major_ver="$(echo ${{ github.ref_name }} | sed 's/openwrt-\([0-9][0-9]\.[0-9][0-9]\)-.*/v\1/')"
159 elif [ "${{ github.ref_type }}" = "tag" ]; then
160 if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
161 major_ver="$(sed 's/\(v[0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
165 if [ -n "$major_ver" ]; then
167 latest_tag="$(git tag --sort=-creatordate -l $major_ver* | head -n1)"
168 if [ -n "$latest_tag" ]; then
169 TOOLCHAIN_PATH=releases/$(echo $latest_tag | sed 's/^v//')
173 SUMS_FILE="https://downloads.cdn.openwrt.org/$TOOLCHAIN_PATH/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums"
174 if curl $SUMS_FILE | grep -q ".*openwrt-toolchain.*tar.xz"; then
175 TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-toolchain.*tar.xz")"
176 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
177 TOOLCHAIN_SHA256=$(echo "$TOOLCHAIN_STRING" | cut -d ' ' -f 1)
179 echo "toolchain-type=external_toolchain" >> $GITHUB_OUTPUT
180 elif curl $SUMS_FILE | grep -q ".*openwrt-sdk.*tar.xz"; then
181 TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-sdk.*tar.xz")"
182 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-sdk.*\).tar.xz/\1/p')
183 TOOLCHAIN_SHA256=$(echo "$TOOLCHAIN_STRING" | cut -d ' ' -f 1)
185 echo "toolchain-type=external_sdk" >> $GITHUB_OUTPUT
188 echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
189 echo "TOOLCHAIN_SHA256=$TOOLCHAIN_SHA256" >> "$GITHUB_ENV"
190 echo "TOOLCHAIN_PATH=$TOOLCHAIN_PATH" >> "$GITHUB_ENV"
192 - name: Cache external toolchain/sdk
193 if: inputs.build_toolchain == false
194 id: cache-external-toolchain
195 uses: actions/cache@v3
197 path: openwrt/${{ env.TOOLCHAIN_FILE }}
198 key: ${{ env.TOOLCHAIN_FILE }}-${{ steps.parse-toolchain.outputs.toolchain-type }}-${{ env.TOOLCHAIN_SHA256 }}
201 uses: actions/cache@v3
203 path: openwrt/.ccache
204 key: ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-${{ needs.setup_build.outputs.ccache_hash }}
206 ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-
208 - name: Download external toolchain/sdk
209 if: inputs.build_toolchain == false && steps.cache-external-toolchain.outputs.cache-hit != 'true'
210 shell: su buildbot -c "sh -e {0}"
211 working-directory: openwrt
213 wget -O - https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${{ env.TOOLCHAIN_FILE }}.tar.xz \
216 - name: Extract prebuilt tools
217 shell: su buildbot -c "sh -e {0}"
218 working-directory: openwrt
219 run: ./scripts/ext-tools.sh --tools /tools.tar
221 - name: Configure testing kernel
222 if: inputs.testing == true
223 shell: su buildbot -c "sh -e {0}"
224 working-directory: openwrt
226 echo CONFIG_TESTING_KERNEL=y >> .config
228 - name: Configure all kernel modules
229 if: inputs.build_all_kmods == true
230 shell: su buildbot -c "sh -e {0}"
231 working-directory: openwrt
233 echo CONFIG_ALL_KMODS=y >> .config
235 - name: Configure all modules
236 if: inputs.build_all_modules == true
237 shell: su buildbot -c "sh -e {0}"
238 working-directory: openwrt
240 echo CONFIG_ALL=y >> .config
242 - name: Configure all boards
243 if: inputs.build_all_boards == true
244 shell: su buildbot -c "sh -e {0}"
245 working-directory: openwrt
247 echo CONFIG_TARGET_MULTI_PROFILE=y >> .config
248 echo CONFIG_TARGET_PER_DEVICE_ROOTFS=y >> .config
249 echo CONFIG_TARGET_ALL_PROFILES=y >> .config
251 - name: Configure external toolchain
252 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_toolchain'
253 shell: su buildbot -c "sh -e {0}"
254 working-directory: openwrt
256 echo CONFIG_DEVEL=y >> .config
257 echo CONFIG_AUTOREMOVE=y >> .config
258 echo CONFIG_CCACHE=y >> .config
260 ./scripts/ext-toolchain.sh \
261 --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
263 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
265 - name: Configure external toolchain with sdk
266 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk'
267 shell: su buildbot -c "sh -e {0}"
268 working-directory: openwrt
270 echo CONFIG_DEVEL=y >> .config
271 echo CONFIG_AUTOREMOVE=y >> .config
272 echo CONFIG_CCACHE=y >> .config
274 ./scripts/ext-toolchain.sh \
275 --toolchain ${{ env.TOOLCHAIN_FILE }}/staging_dir/toolchain-* \
277 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
279 - name: Configure internal toolchain
280 if: inputs.build_toolchain == true
281 shell: su buildbot -c "sh -e {0}"
282 working-directory: openwrt
284 echo CONFIG_DEVEL=y >> .config
285 echo CONFIG_AUTOREMOVE=y >> .config
286 echo CONFIG_CCACHE=y >> .config
288 echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config
289 echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config
293 - name: Show configuration
294 shell: su buildbot -c "sh -e {0}"
295 working-directory: openwrt
296 run: ./scripts/diffconfig.sh
299 shell: su buildbot -c "sh -e {0}"
300 working-directory: openwrt
301 run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
303 - name: Build toolchain
304 shell: su buildbot -c "sh -e {0}"
305 working-directory: openwrt
306 run: make toolchain/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
309 shell: su buildbot -c "sh -e {0}"
310 working-directory: openwrt
311 run: make target/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
313 - name: Build Kernel Kmods
314 shell: su buildbot -c "sh -e {0}"
315 working-directory: openwrt
316 run: make package/linux/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
318 - name: Build everything
319 if: inputs.build_full == true
320 shell: su buildbot -c "sh -e {0}"
321 working-directory: openwrt
322 run: make -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
326 uses: actions/upload-artifact@v3
328 name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs