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
146 working-directory: openwrt
148 TOOLCHAIN_STRING="$(curl "https://downloads.cdn.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" \
149 | grep ".*openwrt-toolchain.*tar.xz")"
150 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
151 TOOLCHAIN_SHA256=$(echo "$TOOLCHAIN_STRING" | cut -d ' ' -f 1)
153 echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
154 echo "TOOLCHAIN_SHA256=$TOOLCHAIN_SHA256" >> "$GITHUB_ENV"
156 - name: Cache external toolchain
157 if: inputs.build_toolchain == false
158 id: cache-external-toolchain
159 uses: actions/cache@v3
161 path: openwrt/${{ env.TOOLCHAIN_FILE }}
162 key: ${{ env.TOOLCHAIN_FILE }}-${{ env.TOOLCHAIN_SHA256 }}
165 uses: actions/cache@v3
167 path: openwrt/.ccache
168 key: ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-${{ needs.setup_build.outputs.ccache_hash }}
170 ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-
172 - name: Download external toolchain
173 if: inputs.build_toolchain == false && steps.cache-external-toolchain.outputs.cache-hit != 'true'
174 shell: su buildbot -c "sh -e {0}"
175 working-directory: openwrt
177 wget -O - https://downloads.cdn.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${TOOLCHAIN_FILE}.tar.xz \
180 - name: Extract prebuilt tools
181 shell: su buildbot -c "sh -e {0}"
182 working-directory: openwrt
183 run: ./scripts/ext-tools.sh --tools /tools.tar
185 - name: Configure testing kernel
186 if: inputs.testing == true
187 shell: su buildbot -c "sh -e {0}"
188 working-directory: openwrt
190 echo CONFIG_TESTING_KERNEL=y >> .config
192 - name: Configure all kernel modules
193 if: inputs.build_all_kmods == true
194 shell: su buildbot -c "sh -e {0}"
195 working-directory: openwrt
197 echo CONFIG_ALL_KMODS=y >> .config
199 - name: Configure all modules
200 if: inputs.build_all_modules == true
201 shell: su buildbot -c "sh -e {0}"
202 working-directory: openwrt
204 echo CONFIG_ALL=y >> .config
206 - name: Configure all boards
207 if: inputs.build_all_boards == true
208 shell: su buildbot -c "sh -e {0}"
209 working-directory: openwrt
211 echo CONFIG_TARGET_MULTI_PROFILE=y >> .config
212 echo CONFIG_TARGET_PER_DEVICE_ROOTFS=y >> .config
213 echo CONFIG_TARGET_ALL_PROFILES=y >> .config
215 - name: Configure external toolchain
216 if: inputs.build_toolchain == false
217 shell: su buildbot -c "sh -e {0}"
218 working-directory: openwrt
220 echo CONFIG_DEVEL=y >> .config
221 echo CONFIG_AUTOREMOVE=y >> .config
222 echo CONFIG_CCACHE=y >> .config
224 ./scripts/ext-toolchain.sh \
225 --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
227 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
229 - name: Configure internal toolchain
230 if: inputs.build_toolchain == true
231 shell: su buildbot -c "sh -e {0}"
232 working-directory: openwrt
234 echo CONFIG_DEVEL=y >> .config
235 echo CONFIG_AUTOREMOVE=y >> .config
236 echo CONFIG_CCACHE=y >> .config
238 echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config
239 echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config
243 - name: Show configuration
244 shell: su buildbot -c "sh -e {0}"
245 working-directory: openwrt
246 run: ./scripts/diffconfig.sh
249 shell: su buildbot -c "sh -e {0}"
250 working-directory: openwrt
251 run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
253 - name: Build toolchain
254 shell: su buildbot -c "sh -e {0}"
255 working-directory: openwrt
256 run: make toolchain/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
259 shell: su buildbot -c "sh -e {0}"
260 working-directory: openwrt
261 run: make target/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
263 - name: Build Kernel Kmods
264 shell: su buildbot -c "sh -e {0}"
265 working-directory: openwrt
266 run: make package/linux/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
268 - name: Build everything
269 if: inputs.build_full == true
270 shell: su buildbot -c "sh -e {0}"
271 working-directory: openwrt
272 run: make -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
276 uses: actions/upload-artifact@v3
278 name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs