CI: rework build workflow to have split target and subtarget directly
[openwrt/openwrt.git] / .github / workflows / toolchain.yml
1 name: Build Toolchains
2
3 on:
4 pull_request:
5 paths:
6 - '.github/workflows/build.yml'
7 - '.github/workflows/toolchain.yml'
8 - 'toolchain/**'
9 push:
10 paths:
11 - '.github/workflows/build.yml'
12 - '.github/workflows/toolchain.yml'
13 - 'toolchain/**'
14
15 permissions:
16 contents: read
17
18 concurrency:
19 group: ${{ github.workflow }}-${{ github.ref }}
20 cancel-in-progress: ${{ github.event_name == 'pull_request' }}
21
22 jobs:
23 determine_targets:
24 name: Set targets
25 runs-on: ubuntu-latest
26 outputs:
27 target: ${{ steps.find_targets.outputs.target }}
28
29 steps:
30 - name: Checkout
31 uses: actions/checkout@v3
32
33 - name: Set targets
34 id: find_targets
35 run: |
36 export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \
37 | sort -u -t '/' -k1,1 \
38 | awk '{ print $1 }')"
39
40 JSON='['
41 FIRST=1
42 for TARGET in $TARGETS; do
43 TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
44 [[ $FIRST -ne 1 ]] && JSON="$JSON"','
45 JSON="$JSON""$TUPLE"
46 FIRST=0
47 done
48 JSON="$JSON"']'
49
50 echo -e "\n---- targets ----\n"
51 echo "$JSON"
52 echo -e "\n---- targets ----\n"
53
54 echo "target=$JSON" >> $GITHUB_OUTPUT
55
56 build:
57 name: Build Target Toolchain
58 needs: determine_targets
59 permissions:
60 contents: read
61 packages: read
62 strategy:
63 fail-fast: False
64 matrix:
65 include: ${{fromJson(needs.determine_targets.outputs.target)}}
66 uses: ./.github/workflows/build.yml
67 with:
68 target: ${{ matrix.target }}
69 subtarget: ${{ matrix.subtarget }}
70 build_toolchain: true