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'
22 group: ${{ github.workflow }}
23 cancel-in-progress: true
26 determine-container-info:
27 name: Determine needed info to push containers
28 if: ${{ github.repository_owner == 'openwrt' }}
29 runs-on: ubuntu-latest
31 owner-lc: ${{ steps.generate-owner-lc.outputs.owner-lc }}
32 container-tag: ${{ steps.determine-container-tag.outputs.container-tag }}
35 - name: Set lower case owner name
38 OWNER: ${{ github.repository_owner }}
40 echo "owner-lc=${OWNER,,}" >> "$GITHUB_OUTPUT"
42 # Per branch tools container tag
43 # By default stick to latest
44 # For official test targetting openwrt stable branch
45 # Get the branch or parse the tag and push dedicated tools containers
46 # Any branch that will match this pattern openwrt-[0-9][0-9].[0-9][0-9]
47 # will refresh the tools container with the matching tag.
48 # (example branch openwrt-22.03 -> tools:openwrt-22.03)
49 # (example branch openwrt-22.03-test -> tools:openwrt-22.03)
50 - name: Determine tools container tag
51 id: determine-container-tag
55 if [ ${{ github.ref_type }} == "branch" ]; then
56 if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
57 CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\).*/\1/')"
59 elif [ ${{ github.ref_type }} == "tag" ]; then
60 if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
61 CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
65 echo "Container tag to push for tools and toolchain is $CONTAINER_TAG"
66 echo "container-tag=$CONTAINER_TAG" >> "$GITHUB_OUTPUT"
69 name: Build tools with buildbot container
70 if: ${{ github.repository_owner == 'openwrt' }}
71 uses: ./.github/workflows/build-tools.yml
73 generate_prebuilt_artifacts: true
76 needs: [ determine-container-info, build-linux-buildbot ]
77 if: ${{ github.repository_owner == 'openwrt' }}
78 name: Push prebuilt tools container
79 runs-on: ubuntu-latest
87 uses: actions/checkout@v3
91 - name: Download prebuilt tools from build job
92 uses: actions/download-artifact@v3
94 name: linux-buildbot-prebuilt-tools
97 - name: Extract prebuild tools
98 working-directory: openwrt
99 run: tar -xf tools.tar
101 - name: Login to GitHub Container Registry
102 uses: docker/login-action@v2
105 username: ${{ github.actor }}
106 password: ${{ secrets.GITHUB_TOKEN }}
108 - name: Build and push
109 uses: docker/build-push-action@v3
113 tags: ghcr.io/${{ needs.determine-container-info.outputs.owner-lc }}/tools:${{ needs.determine-container-info.outputs.container-tag }}
114 file: openwrt/.github/workflows/Dockerfile.tools
118 if: ${{ github.repository_owner == 'openwrt' }}
119 runs-on: ubuntu-latest
121 target: ${{ steps.find_targets.outputs.target }}
125 uses: actions/checkout@v3
130 export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \
131 | awk '{ print $1 }')"
135 for TARGET in $TARGETS; do
136 TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
137 [[ $FIRST -ne 1 ]] && JSON="$JSON"','
143 echo -e "\n---- targets ----\n"
145 echo -e "\n---- targets ----\n"
147 echo "target=$JSON" >> $GITHUB_OUTPUT
150 name: Build Target Toolchain
151 if: ${{ github.repository_owner == 'openwrt' }}
152 needs: [ determine-targets, push-tools-container ]
160 include: ${{fromJson(needs.determine-targets.outputs.target)}}
161 uses: ./.github/workflows/build.yml
163 target: ${{ matrix.target }}
164 subtarget: ${{ matrix.subtarget }}
165 build_toolchain: true
166 build_external_toolchain: true
167 upload_external_toolchain: true
169 push-toolchain-container:
170 name: Push Target Toolchain container
171 if: ${{ github.repository_owner == 'openwrt' }}
172 needs: [ determine-container-info, determine-targets, build ]
173 runs-on: ubuntu-latest
178 include: ${{fromJson(needs.determine-targets.outputs.target)}}
186 uses: actions/checkout@v3
190 - name: Download external toolchain from build job
191 uses: actions/download-artifact@v3
193 name: ${{ matrix.target }}-${{ matrix.subtarget }}-external-toolchain
196 - name: Find external toolchain name
197 id: get-toolchain-name
198 working-directory: openwrt
200 TOOLCHAIN_NAME=$(ls | grep toolchain-${{ matrix.target }}-${{ matrix.subtarget }})
201 echo "toolchain-name=$TOOLCHAIN_NAME" >> $GITHUB_OUTPUT
203 - name: Login to GitHub Container Registry
204 uses: docker/login-action@v2
207 username: ${{ github.actor }}
208 password: ${{ secrets.GITHUB_TOKEN }}
210 - name: Build and push
211 uses: docker/build-push-action@v3
215 tags: ghcr.io/${{ needs.determine-container-info.outputs.owner-lc }}/toolchain:${{ matrix.target }}-${{ matrix.subtarget }}-${{ needs.determine-container-info.outputs.container-tag }}
216 file: openwrt/.github/workflows/Dockerfile.toolchain
218 OWNER_LC=${{ needs.determine-container-info.outputs.owner-lc }}
219 CONTAINER_TAG=${{ needs.determine-container-info.outputs.container-tag }}
220 TOOLCHAIN_NAME=${{ steps.get-toolchain-name.outputs.toolchain-name }}