1 name: Build and Push prebuilt tools container
8 - '.github/workflows/build-tools.yml'
9 - '.github/workflows/push-containers.yml'
10 - '.github/workflows/Dockerfile.tools'
12 - '.github/workflows/build.yml'
13 - '.github/workflows/toolchain.yml'
14 - '.github/workflows/Dockerfile.toolchain'
20 group: ${{ github.workflow }}
21 cancel-in-progress: true
24 determine-container-info:
25 name: Determine needed info to push containers
26 if: ${{ github.repository_owner == 'openwrt' }}
27 runs-on: ubuntu-latest
29 owner-lc: ${{ steps.generate-owner-lc.outputs.owner-lc }}
30 container-tag: ${{ steps.determine-container-tag.outputs.container-tag }}
33 - name: Set lower case owner name
36 OWNER: ${{ github.repository_owner }}
38 echo "owner-lc=${OWNER,,}" >> "$GITHUB_OUTPUT"
40 # Per branch tools container tag
41 # By default stick to latest
42 # For official test targetting openwrt stable branch
43 # Get the branch or parse the tag and push dedicated tools containers
44 # Any branch that will match this pattern openwrt-[0-9][0-9].[0-9][0-9]
45 # will refresh the tools container with the matching tag.
46 # (example branch openwrt-22.03 -> tools:openwrt-22.03)
47 # (example branch openwrt-22.03-test -> tools:openwrt-22.03)
48 - name: Determine tools container tag
49 id: determine-container-tag
53 if [ ${{ github.ref_type }} == "branch" ]; then
54 if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
55 CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\).*/\1/')"
57 elif [ ${{ github.ref_type }} == "tag" ]; then
58 if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
59 CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
63 echo "Container tag to push for tools and toolchain is $CONTAINER_TAG"
64 echo "container-tag=$CONTAINER_TAG" >> "$GITHUB_OUTPUT"
67 name: Build tools with buildbot container
68 if: ${{ github.repository_owner == 'openwrt' }}
69 uses: ./.github/workflows/build-tools.yml
71 generate_prebuilt_artifacts: true
74 needs: [ determine-container-info, build-linux-buildbot ]
75 if: ${{ github.repository_owner == 'openwrt' }}
76 name: Push prebuilt tools container
77 runs-on: ubuntu-latest
85 uses: actions/checkout@v3
89 - name: Download prebuilt tools from build job
90 uses: actions/download-artifact@v3
92 name: linux-buildbot-prebuilt-tools
95 - name: Extract prebuild tools
96 working-directory: openwrt
97 run: tar -xf tools.tar
99 - name: Login to GitHub Container Registry
100 uses: docker/login-action@v2
103 username: ${{ github.actor }}
104 password: ${{ secrets.GITHUB_TOKEN }}
106 - name: Build and push
107 uses: docker/build-push-action@v3
111 tags: ghcr.io/${{ needs.determine-container-info.outputs.owner-lc }}/tools:${{ needs.determine-container-info.outputs.container-tag }}
112 file: openwrt/.github/workflows/Dockerfile.tools
116 if: ${{ github.repository_owner == 'openwrt' }}
117 runs-on: ubuntu-latest
119 target: ${{ steps.find_targets.outputs.target }}
123 uses: actions/checkout@v3
128 export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \
129 | awk '{ print $1 }')"
133 for TARGET in $TARGETS; do
134 TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
135 [[ $FIRST -ne 1 ]] && JSON="$JSON"','
141 echo -e "\n---- targets ----\n"
143 echo -e "\n---- targets ----\n"
145 echo "target=$JSON" >> $GITHUB_OUTPUT
148 name: Build Target Toolchain
149 if: ${{ github.repository_owner == 'openwrt' }}
150 needs: [ determine-targets, push-tools-container ]
157 include: ${{fromJson(needs.determine-targets.outputs.target)}}
158 uses: ./.github/workflows/build.yml
160 target: ${{ matrix.target }}
161 subtarget: ${{ matrix.subtarget }}
162 build_toolchain: true
163 build_external_toolchain: true
164 upload_external_toolchain: true
166 push-toolchain-container:
167 name: Push Target Toolchain container
168 if: ${{ github.repository_owner == 'openwrt' }}
169 needs: [ determine-container-info, determine-targets, build ]
170 runs-on: ubuntu-latest
175 include: ${{fromJson(needs.determine-targets.outputs.target)}}
183 uses: actions/checkout@v3
187 - name: Download external toolchain from build job
188 uses: actions/download-artifact@v3
190 name: ${{ matrix.target }}-${{ matrix.subtarget }}-external-toolchain
193 - name: Find external toolchain name
194 id: get-toolchain-name
195 working-directory: openwrt
197 TOOLCHAIN_NAME=$(ls | grep toolchain-${{ matrix.target }}-${{ matrix.subtarget }})
198 echo "toolchain-name=$TOOLCHAIN_NAME" >> $GITHUB_OUTPUT
200 - name: Login to GitHub Container Registry
201 uses: docker/login-action@v2
204 username: ${{ github.actor }}
205 password: ${{ secrets.GITHUB_TOKEN }}
207 - name: Build and push
208 uses: docker/build-push-action@v3
212 tags: ghcr.io/${{ needs.determine-container-info.outputs.owner-lc }}/toolchain:${{ matrix.target }}-${{ matrix.subtarget }}-${{ needs.determine-container-info.outputs.container-tag }}
213 file: openwrt/.github/workflows/Dockerfile.toolchain
215 OWNER_LC=${{ needs.determine-container-info.outputs.owner-lc }}
216 CONTAINER_TAG=${{ needs.determine-container-info.outputs.container-tag }}
217 TOOLCHAIN_NAME=${{ steps.get-toolchain-name.outputs.toolchain-name }}