ci: build: verify downloaded toolchain tarball
[openwrt/staging/hauke.git] / .github / workflows / build.yml
1 name: Build sub target
2
3 on:
4 workflow_call:
5 secrets:
6 coverity_api_token:
7 inputs:
8 container_name:
9 type: string
10 default: tools
11 target:
12 required: true
13 type: string
14 subtarget:
15 required: true
16 type: string
17 testing:
18 type: boolean
19 build_toolchain:
20 type: boolean
21 include_feeds:
22 type: boolean
23 build_full:
24 type: boolean
25 build_kernel:
26 type: boolean
27 build_all_modules:
28 type: boolean
29 build_all_kmods:
30 type: boolean
31 build_all_boards:
32 type: boolean
33 use_openwrt_container:
34 type: boolean
35 default: true
36 coverity_project_name:
37 type: string
38 default: OpenWrt
39 coverity_check_packages:
40 type: string
41 coverity_compiler_template_list:
42 type: string
43 default: >-
44 arm-openwrt-linux-gcc
45 coverity_force_compile_packages:
46 type: string
47 default: >-
48 curl
49 libnl
50 mbedtls
51 wolfssl
52 openssl
53 build_external_toolchain:
54 type: boolean
55 upload_external_toolchain:
56 type: boolean
57 use_ccache_cache:
58 type: boolean
59 default: true
60 ccache_type:
61 type: string
62 default: kernel
63 upload_ccache_cache:
64 type: boolean
65
66 permissions:
67 contents: read
68
69 jobs:
70 setup_build:
71 name: Setup build ${{ inputs.target }}/${{ inputs.subtarget }}
72 runs-on: ubuntu-latest
73 outputs:
74 owner_lc: ${{ steps.lower_owner.outputs.owner_lc }}
75 container_tag: ${{ steps.determine_tools_container.outputs.container_tag }}
76 container_name: ${{ steps.determine_tools_container.outputs.container_name }}
77
78 steps:
79 - name: Checkout
80 uses: actions/checkout@v3
81
82 - name: Set lower case owner name
83 id: lower_owner
84 run: |
85 OWNER_LC=$(echo "${{ github.repository_owner }}" \
86 | tr '[:upper:]' '[:lower:]')
87
88 if [ ${{ inputs.use_openwrt_container }} == "true" ]; then
89 OWNER_LC=openwrt
90 fi
91
92 echo "owner_lc=$OWNER_LC" >> $GITHUB_OUTPUT
93
94 # Per branch tools container tag
95 # By default stick to latest
96 # For official test targetting openwrt stable branch
97 # Get the branch or parse the tag and push dedicated tools containers
98 # For local test to use the correct container for stable release testing
99 # you need to use for the branch name a prefix of openwrt-[0-9][0-9].[0-9][0-9]-
100 - name: Determine tools container tag
101 id: determine_tools_container
102 run: |
103 CONTAINER_NAME=${{ inputs.container_name }}
104 CONTAINER_TAG=latest
105 if [ -n "${{ github.base_ref }}" ]; then
106 if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
107 CONTAINER_TAG="${{ github.base_ref }}"
108 fi
109 elif [ ${{ github.ref_type }} == "branch" ]; then
110 if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
111 CONTAINER_TAG=${{ github.ref_name }}
112 elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
113 CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
114 fi
115 elif [ ${{ github.ref_type }} == "tag" ]; then
116 if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
117 CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
118 fi
119 fi
120
121 if [ "$CONTAINER_NAME" = "toolchain" ]; then
122 GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
123 GHCR_HEADER="Authorization: Bearer ${GHCR_TOKEN}"
124 GHCR_MANIFEST_LINK=https://ghcr.io/v2/${{ steps.lower_owner.outputs.owner_lc }}/${{ inputs.container_name }}/manifests/${{ inputs.target }}-${{ inputs.subtarget }}-"$CONTAINER_TAG"
125 # Check if container exist
126 if [ $(curl -s -o /dev/null -w "%{http_code}" -H "$GHCR_HEADER" -I "$GHCR_MANIFEST_LINK") = 200 ]; then
127 CONTAINER_TAG=${{ inputs.target }}-${{ inputs.subtarget }}-"$CONTAINER_TAG"
128 else
129 CONTAINER_NAME=tools
130 fi
131 fi
132
133 echo "Tools container to use $CONTAINER_NAME:$CONTAINER_TAG"
134 echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
135 echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT
136
137 build:
138 name: Build ${{ inputs.target }}/${{ inputs.subtarget }}
139 needs: setup_build
140 runs-on: ubuntu-latest
141
142 container: ghcr.io/${{ needs.setup_build.outputs.owner_lc }}/${{ needs.setup_build.outputs.container_name }}:${{ needs.setup_build.outputs.container_tag }}
143
144 permissions:
145 contents: read
146 packages: read
147 actions: write
148
149 steps:
150 - name: Checkout master directory
151 uses: actions/checkout@v3
152 with:
153 path: openwrt
154
155 - name: Checkout packages feed
156 if: inputs.include_feeds == true
157 uses: actions/checkout@v3
158 with:
159 repository: openwrt/packages
160 path: openwrt/feeds/packages
161
162 - name: Checkout luci feed
163 if: inputs.include_feeds == true
164 uses: actions/checkout@v3
165 with:
166 repository: openwrt/luci
167 path: openwrt/feeds/luci
168
169 - name: Checkout routing feed
170 if: inputs.include_feeds == true
171 uses: actions/checkout@v3
172 with:
173 repository: openwrt/routing
174 path: openwrt/feeds/routing
175
176 - name: Checkout telephony feed
177 if: inputs.include_feeds == true
178 uses: actions/checkout@v3
179 with:
180 repository: openwrt/telephony
181 path: openwrt/feeds/telephony
182
183 - name: Parse toolchain file
184 if: inputs.build_toolchain == false
185 id: parse-toolchain
186 working-directory: openwrt
187 run: |
188 if [ -d /external-toolchain/ ]; then
189 echo "toolchain-type=external_container" >> $GITHUB_OUTPUT
190 exit 0
191 fi
192
193 TOOLCHAIN_PATH=snapshots
194
195 if [ -n "${{ github.base_ref }}" ]; then
196 if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
197 major_ver="$(echo ${{ github.base_ref }} | sed 's/^openwrt-/v/')"
198 fi
199 elif [ "${{ github.ref_type }}" = "branch" ]; then
200 if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
201 major_ver="$(echo ${{ github.ref_name }} | sed 's/^openwrt-/v/')"
202 elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
203 major_ver="$(echo ${{ github.ref_name }} | sed 's/^openwrt-\([0-9][0-9]\.[0-9][0-9]\)-.*/v\1/')"
204 fi
205 elif [ "${{ github.ref_type }}" = "tag" ]; then
206 if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
207 major_ver="$(echo ${{ github.ref_name }} | sed 's/^\(v[0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
208 fi
209 fi
210
211 if [ -n "$major_ver" ]; then
212 git fetch --tags -f
213 latest_tag="$(git tag --sort=-creatordate -l $major_ver* | head -n1)"
214 if [ -n "$latest_tag" ]; then
215 TOOLCHAIN_PATH=releases/$(echo $latest_tag | sed 's/^v//')
216 fi
217 fi
218
219 SUMS_FILE="https://downloads.cdn.openwrt.org/$TOOLCHAIN_PATH/targets/${{ inputs.target }}/${{ inputs.subtarget }}/sha256sums"
220 if curl $SUMS_FILE | grep -q ".*openwrt-toolchain.*tar.xz"; then
221 TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-toolchain.*tar.xz")"
222 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
223
224 echo "toolchain-type=external_toolchain" >> $GITHUB_OUTPUT
225 elif curl $SUMS_FILE | grep -q ".*openwrt-sdk.*tar.xz"; then
226 TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-sdk.*tar.xz")"
227 TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-sdk.*\).tar.xz/\1/p')
228
229 echo "toolchain-type=external_sdk" >> $GITHUB_OUTPUT
230 else
231 echo "toolchain-type=internal" >> $GITHUB_OUTPUT
232 fi
233
234 echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
235 echo "TOOLCHAIN_PATH=$TOOLCHAIN_PATH" >> "$GITHUB_ENV"
236
237 - name: Download and extract ccache cache from s3
238 id: restore-ccache-cache-s3
239 if: inputs.use_ccache_cache == true
240 working-directory: openwrt
241 run: |
242 ENDPOINT=https://storage.googleapis.com
243 BUCKET=openwrt-ci-cache
244 CCACHE_TAR=ccache-${{ inputs.ccache_type }}-${{ inputs.target }}-${{ inputs.subtarget }}.tar
245
246 if curl -o /dev/null -s --head --fail $ENDPOINT/$BUCKET/$CCACHE_TAR; then
247 wget -O - $ENDPOINT/$BUCKET/$CCACHE_TAR | tar -xf -
248 echo "cache-hit=true" >> $GITHUB_OUTPUT
249 fi
250
251 - name: Fix permission
252 run: |
253 chown -R buildbot:buildbot openwrt
254
255 - name: Prepare prebuilt tools
256 shell: su buildbot -c "sh -e {0}"
257 working-directory: openwrt
258 run: |
259 mkdir -p staging_dir build_dir
260 ln -s /prebuilt_tools/staging_dir/host staging_dir/host
261 ln -s /prebuilt_tools/build_dir/host build_dir/host
262
263 ./scripts/ext-tools.sh --refresh
264
265 - name: Update & Install feeds
266 if: inputs.include_feeds == true
267 shell: su buildbot -c "sh -e {0}"
268 working-directory: openwrt
269 run: |
270 ./scripts/feeds update -a
271 ./scripts/feeds install -a
272
273 - name: Restore ccache cache
274 id: restore-ccache-cache
275 if: inputs.use_ccache_cache == true && steps.restore-ccache-cache-s3.outputs.cache-hit != 'true'
276 uses: actions/cache/restore@v3
277 with:
278 path: openwrt/.ccache
279 key: ccache-${{ inputs.ccache_type }}-${{ inputs.target }}/${{ inputs.subtarget }}-${{ hashFiles('openwrt/include/kernel-**') }}
280 restore-keys: |
281 ccache-${{ inputs.ccache_type }}-${{ inputs.target }}/${{ inputs.subtarget }}-
282
283 - name: Import GPG keys
284 shell: su buildbot -c "sh -e {0}"
285 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type != 'internal' && steps.parse-toolchain.outputs.toolchain-type != 'external_container'
286 run: gpg --receive-keys 0xCD84BCED626471F1 0x1D53D1877742E911 0xCD54E82DADB3684D
287
288 - name: Download external toolchain/sdk
289 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type != 'internal' && steps.parse-toolchain.outputs.toolchain-type != 'external_container'
290 shell: su buildbot -c "sh -e {0}"
291 working-directory: openwrt
292 run: |
293 wget https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ inputs.target }}/${{ inputs.subtarget }}/${{ env.TOOLCHAIN_FILE }}.tar.xz
294 wget https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ inputs.target }}/${{ inputs.subtarget }}/sha256sums.asc
295 wget https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ inputs.target }}/${{ inputs.subtarget }}/sha256sums
296 gpg --with-fingerprint --verify sha256sums.asc
297 sha256sum --check --ignore-missing sha256sums
298 tar --xz -xf ${{ env.TOOLCHAIN_FILE }}.tar.xz
299 rm ${{ env.TOOLCHAIN_FILE }}.tar.xz sha256sums
300
301 - name: Configure testing kernel
302 if: inputs.testing == true
303 shell: su buildbot -c "sh -e {0}"
304 working-directory: openwrt
305 run: |
306 echo CONFIG_TESTING_KERNEL=y >> .config
307
308 - name: Configure all kernel modules
309 if: inputs.build_all_kmods == true
310 shell: su buildbot -c "sh -e {0}"
311 working-directory: openwrt
312 run: |
313 echo CONFIG_ALL_KMODS=y >> .config
314
315 - name: Configure all modules
316 if: inputs.build_all_modules == true
317 shell: su buildbot -c "sh -e {0}"
318 working-directory: openwrt
319 run: |
320 echo CONFIG_ALL=y >> .config
321
322 - name: Configure all boards
323 if: inputs.build_all_boards == true
324 shell: su buildbot -c "sh -e {0}"
325 working-directory: openwrt
326 run: |
327 echo CONFIG_TARGET_MULTI_PROFILE=y >> .config
328 echo CONFIG_TARGET_PER_DEVICE_ROOTFS=y >> .config
329 echo CONFIG_TARGET_ALL_PROFILES=y >> .config
330
331 # ccache for some reason have problem detecting compiler type
332 # with external toolchain. This cause the complete malfunction
333 # of ccache with the result of tons of unsupported compiler
334 # option error.
335 # To fix this force compiler type to gcc.
336 - name: Configure ccache and apply fixes
337 if: inputs.use_ccache_cache == true
338 shell: su buildbot -c "sh -e {0}"
339 working-directory: openwrt
340 env:
341 SYSTEM_CCACHE_CONF: staging_dir/host/etc/ccache.conf
342 run: |
343 touch $SYSTEM_CCACHE_CONF
344
345 echo compiler_type=gcc >> $SYSTEM_CCACHE_CONF
346
347 echo CONFIG_CCACHE=y >> .config
348
349 - name: Configure external toolchain in container
350 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_container'
351 shell: su buildbot -c "sh -e {0}"
352 working-directory: openwrt
353 run: |
354 echo CONFIG_DEVEL=y >> .config
355 echo CONFIG_AUTOREMOVE=y >> .config
356
357 ./scripts/ext-toolchain.sh \
358 --toolchain /external-toolchain/$(ls /external-toolchain/ | grep openwrt-toolchain)/toolchain-* \
359 --overwrite-config \
360 --config ${{ inputs.target }}/${{ inputs.subtarget }}
361
362 - name: Configure external toolchain
363 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_toolchain'
364 shell: su buildbot -c "sh -e {0}"
365 working-directory: openwrt
366 run: |
367 echo CONFIG_DEVEL=y >> .config
368 echo CONFIG_AUTOREMOVE=y >> .config
369
370 ./scripts/ext-toolchain.sh \
371 --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
372 --overwrite-config \
373 --config ${{ inputs.target }}/${{ inputs.subtarget }}
374
375 - name: Adapt external sdk to external toolchain format
376 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk'
377 shell: su buildbot -c "sh -e {0}"
378 working-directory: openwrt
379 run: |
380 TOOLCHAIN_DIR=${{ env.TOOLCHAIN_FILE }}/staging_dir/$(ls ${{ env.TOOLCHAIN_FILE }}/staging_dir | grep toolchain)
381 TOOLCHAIN_BIN=$TOOLCHAIN_DIR/bin
382 OPENWRT_DIR=$(pwd)
383
384 # Find target name from toolchain info.mk
385 GNU_TARGET_NAME=$(cat $TOOLCHAIN_DIR/info.mk | grep TARGET_CROSS | sed 's/^TARGET_CROSS=\(.*\)-$/\1/')
386
387 cd $TOOLCHAIN_BIN
388
389 # Revert sdk wrapper scripts applied to all the bins
390 for app in $(find . -name "*.bin"); do
391 TARGET_APP=$(echo $app | sed 's/\.\/\.\(.*\)\.bin/\1/')
392 rm $TARGET_APP
393 mv .$TARGET_APP.bin $TARGET_APP
394 done
395
396 # Setup the wrapper script in the sdk toolchain dir simulating an external toolchain build
397 cp $OPENWRT_DIR/target/toolchain/files/wrapper.sh $GNU_TARGET_NAME-wrapper.sh
398 for app in cc gcc g++ c++ cpp ld as ; do
399 [ -f $GNU_TARGET_NAME-$app ] && mv $GNU_TARGET_NAME-$app $GNU_TARGET_NAME-$app.bin
400 ln -sf $GNU_TARGET_NAME-wrapper.sh $GNU_TARGET_NAME-$app
401 done
402
403 - name: Configure external toolchain with sdk
404 if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk'
405 shell: su buildbot -c "sh -e {0}"
406 working-directory: openwrt
407 run: |
408 echo CONFIG_DEVEL=y >> .config
409 echo CONFIG_AUTOREMOVE=y >> .config
410
411 ./scripts/ext-toolchain.sh \
412 --toolchain ${{ env.TOOLCHAIN_FILE }}/staging_dir/toolchain-* \
413 --overwrite-config \
414 --config ${{ inputs.target }}/${{ inputs.subtarget }}
415
416 - name: Configure internal toolchain
417 if: inputs.build_toolchain == true || steps.parse-toolchain.outputs.toolchain-type == 'internal'
418 shell: su buildbot -c "sh -e {0}"
419 working-directory: openwrt
420 run: |
421 echo CONFIG_DEVEL=y >> .config
422 echo CONFIG_AUTOREMOVE=y >> .config
423
424 echo "CONFIG_TARGET_${{ inputs.target }}=y" >> .config
425 echo "CONFIG_TARGET_${{ inputs.target }}_${{ inputs.subtarget }}=y" >> .config
426
427 make defconfig
428
429 - name: Show configuration
430 shell: su buildbot -c "sh -e {0}"
431 working-directory: openwrt
432 run: ./scripts/diffconfig.sh
433
434 - name: Build tools
435 shell: su buildbot -c "sh -e {0}"
436 working-directory: openwrt
437 run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
438
439 - name: Build toolchain
440 shell: su buildbot -c "sh -e {0}"
441 working-directory: openwrt
442 run: make toolchain/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
443
444 - name: Build Kernel
445 if: inputs.build_kernel == true
446 shell: su buildbot -c "sh -e {0}"
447 working-directory: openwrt
448 run: make target/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
449
450 - name: Build Kernel Kmods
451 if: inputs.build_kernel == true
452 shell: su buildbot -c "sh -e {0}"
453 working-directory: openwrt
454 run: make package/linux/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
455
456 - name: Build everything
457 if: inputs.build_full == true
458 shell: su buildbot -c "sh -e {0}"
459 working-directory: openwrt
460 run: make -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
461
462 - name: Build external toolchain
463 if: inputs.build_external_toolchain == true
464 shell: su buildbot -c "sh -e {0}"
465 working-directory: openwrt
466 run: make target/toolchain/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
467
468 - name: Coverity prepare toolchain
469 if: inputs.coverity_check_packages != ''
470 shell: su buildbot -c "sh -e {0}"
471 working-directory: openwrt
472 run: |
473 wget -q https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.coverity_api_token }}&project=${{ inputs.coverity_project_name }}" -O coverity.tar.gz
474 wget -q https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.coverity_api_token }}&project=${{ inputs.coverity_project_name }}&md5=1" -O coverity.tar.gz.md5
475 echo ' coverity.tar.gz' >> coverity.tar.gz.md5
476 md5sum -c coverity.tar.gz.md5
477
478 mkdir cov-analysis-linux64
479 tar xzf coverity.tar.gz --strip 1 -C cov-analysis-linux64
480 export PATH=$(pwd)/cov-analysis-linux64/bin:$PATH
481
482 for template in ${{ inputs.coverity_compiler_template_list }}; do
483 cov-configure --template --comptype gcc --compiler "$template"
484 done
485
486 - name: Clean and recompile packages with Coverity toolchain
487 if: inputs.coverity_check_packages != ''
488 shell: su buildbot -c "bash {0}"
489 working-directory: openwrt
490 run: |
491 set -o pipefail -o errexit
492
493 coverity_check_packages=(${{ inputs.coverity_check_packages }})
494 printf -v clean_packages "package/%s/clean " "${coverity_check_packages[@]}"
495 make -j$(nproc) BUILD_LOG=1 $clean_packages || ret=$? .github/workflows/scripts/show_build_failures.sh
496
497 coverity_force_compile_packages=(${{ inputs.coverity_force_compile_packages }})
498 printf -v force_compile_packages "package/%s/compile " "${coverity_force_compile_packages[@]}"
499 make -j$(nproc) BUILD_LOG=1 $force_compile_packages || ret=$? .github/workflows/scripts/show_build_failures.sh
500
501 printf -v compile_packages "package/%s/compile " "${coverity_check_packages[@]}"
502 export PATH=$(pwd)/cov-analysis-linux64/bin:$PATH
503 cov-build --dir cov-int make -j $(nproc) BUILD_LOG=1 $compile_packages || ret=$? .github/workflows/scripts/show_build_failures.sh
504
505 - name: Upload build to Coverity for analysis
506 if: inputs.coverity_check_packages != ''
507 shell: su buildbot -c "sh -e {0}"
508 working-directory: openwrt
509 run: |
510 tar czf cov-int.tar.gz ./cov-int
511 curl \
512 --form token="${{ secrets.coverity_api_token }}" \
513 --form email="contact@openwrt.org" \
514 --form file=@cov-int.tar.gz \
515 --form version="${{ github.ref_name }}-${{ github.sha }}" \
516 --form description="OpenWrt ${{ github.ref_name }}-${{ github.sha }}" \
517 "https://scan.coverity.com/builds?project=${{ inputs.coverity_project_name }}"
518
519 - name: Upload logs
520 if: failure()
521 uses: actions/upload-artifact@v3
522 with:
523 name: ${{ inputs.target }}-${{ inputs.subtarget }}-logs
524 path: "openwrt/logs"
525
526 - name: Delete already present ccache cache
527 if: steps.restore-ccache-cache.outputs.cache-hit == 'true' && inputs.use_ccache_cache == true &&
528 github.event_name == 'push' && steps.restore-ccache-cache-s3.outputs.cache-hit != 'true'
529 uses: octokit/request-action@v2.x
530 with:
531 route: DELETE /repos/{repository}/actions/caches?key={key}
532 env:
533 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
534 INPUT_REPOSITORY: ${{ github.repository }}
535 INPUT_KEY: ${{ steps.restore-ccache-cache.outputs.cache-primary-key }}
536
537 - name: Save ccache cache
538 if: inputs.use_ccache_cache == true && github.event_name == 'push' &&
539 steps.restore-ccache-cache-s3.outputs.cache-hit != 'true'
540 uses: actions/cache/save@v3
541 with:
542 path: openwrt/.ccache
543 key: ${{ steps.restore-ccache-cache.outputs.cache-primary-key }}
544
545 - name: Archive ccache
546 if: inputs.use_ccache_cache == true && github.event_name == 'push' &&
547 inputs.upload_ccache_cache == true
548 shell: su buildbot -c "sh -e {0}"
549 working-directory: openwrt
550 run: tar -cf ccache-${{ inputs.ccache_type }}-${{ inputs.target }}-${{ inputs.subtarget }}.tar .ccache
551
552 - name: Upload ccache cache
553 if: inputs.use_ccache_cache == true && github.event_name == 'push' &&
554 inputs.upload_ccache_cache == true
555 uses: actions/upload-artifact@v3
556 with:
557 name: ${{ inputs.target }}-${{ inputs.subtarget }}-ccache-cache
558 path: openwrt/ccache-${{ inputs.ccache_type }}-${{ inputs.target }}-${{ inputs.subtarget }}.tar
559 retention-days: 1
560
561 - name: Find external toolchain name
562 id: get-toolchain-name
563 if: inputs.upload_external_toolchain == true
564 working-directory: openwrt
565 run: |
566 TOOLCHAIN_NAME=$(ls bin/targets/${{inputs.target }}/${{ inputs.subtarget }} | grep toolchain)
567 echo "toolchain-name=$TOOLCHAIN_NAME" >> $GITHUB_OUTPUT
568
569 - name: Upload prebuilt toolchain
570 if: inputs.upload_external_toolchain == true
571 uses: actions/upload-artifact@v3
572 with:
573 name: ${{ inputs.target }}-${{ inputs.subtarget }}-external-toolchain
574 path: openwrt/bin/targets/${{ inputs.target }}/${{ inputs.subtarget }}/${{ steps.get-toolchain-name.outputs.toolchain-name }}
575 retention-days: 1