blob: 3cc08dbef88150724814911ea69768aeb7765943 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
name: Build and Push prebuilt tools container
on:
push:
paths:
- 'include/version.mk'
- 'include/cmake.mk'
- 'tools/**'
- '.github/workflows/build-tools.yml'
- '.github/workflows/push-containers.yml'
- '.github/workflows/Dockerfile.tools'
- 'toolchain/**'
- '.github/workflows/build.yml'
- '.github/workflows/toolchain.yml'
- '.github/workflows/Dockerfile.toolchain'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
determine-container-info:
name: Determine needed info to push containers
if: ${{ github.repository_owner == 'openwrt' }}
runs-on: ubuntu-latest
outputs:
owner-lc: ${{ steps.generate-owner-lc.outputs.owner-lc }}
container-tag: ${{ steps.determine-container-tag.outputs.container-tag }}
steps:
- name: Set lower case owner name
id: generate-owner-lc
env:
OWNER: ${{ github.repository_owner }}
run: |
echo "owner-lc=${OWNER,,}" >> "$GITHUB_OUTPUT"
# Per branch tools container tag
# By default stick to latest
# For official test targetting openwrt stable branch
# Get the branch or parse the tag and push dedicated tools containers
# Any branch that will match this pattern openwrt-[0-9][0-9].[0-9][0-9]
# will refresh the tools container with the matching tag.
# (example branch openwrt-22.03 -> tools:openwrt-22.03)
# (example branch openwrt-22.03-test -> tools:openwrt-22.03)
- name: Determine tools container tag
id: determine-container-tag
run: |
CONTAINER_TAG=latest
if [ ${{ github.ref_type }} == "branch" ]; then
if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\).*/\1/')"
fi
elif [ ${{ github.ref_type }} == "tag" ]; then
if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
fi
fi
echo "Container tag to push for tools and toolchain is $CONTAINER_TAG"
echo "container-tag=$CONTAINER_TAG" >> "$GITHUB_OUTPUT"
build-linux-buildbot:
name: Build tools with buildbot container
if: ${{ github.repository_owner == 'openwrt' }}
uses: ./.github/workflows/build-tools.yml
with:
generate_prebuilt_artifacts: true
push-tools-container:
needs: [ determine-container-info, build-linux-buildbot ]
if: ${{ github.repository_owner == 'openwrt' }}
name: Push prebuilt tools container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: 'openwrt'
- name: Download prebuilt tools from build job
uses: actions/download-artifact@v3
with:
name: linux-buildbot-prebuilt-tools
path: openwrt
- name: Extract prebuild tools
working-directory: openwrt
run: tar -xf tools.tar
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: openwrt
push: true
tags: ghcr.io/${{ needs.determine-container-info.outputs.owner-lc }}/tools:${{ needs.determine-container-info.outputs.container-tag }}
file: openwrt/.github/workflows/Dockerfile.tools
determine-targets:
name: Set targets
if: ${{ github.repository_owner == 'openwrt' }}
runs-on: ubuntu-latest
outputs:
target: ${{ steps.find_targets.outputs.target }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set targets
id: find_targets
run: |
export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \
| awk '{ print $1 }')"
JSON='['
FIRST=1
for TARGET in $TARGETS; do
TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
[[ $FIRST -ne 1 ]] && JSON="$JSON"','
JSON="$JSON""$TUPLE"
FIRST=0
done
JSON="$JSON"']'
echo -e "\n---- targets ----\n"
echo "$JSON"
echo -e "\n---- targets ----\n"
echo "target=$JSON" >> $GITHUB_OUTPUT
build:
name: Build Target Toolchain
if: ${{ github.repository_owner == 'openwrt' }}
needs: [ determine-targets, push-tools-container ]
permissions:
contents: read
packages: read
strategy:
fail-fast: False
matrix:
include: ${{fromJson(needs.determine-targets.outputs.target)}}
uses: ./.github/workflows/build.yml
with:
target: ${{ matrix.target }}
subtarget: ${{ matrix.subtarget }}
build_toolchain: true
build_external_toolchain: true
upload_external_toolchain: true
push-toolchain-container:
name: Push Target Toolchain container
if: ${{ github.repository_owner == 'openwrt' }}
needs: [ determine-container-info, determine-targets, build ]
runs-on: ubuntu-latest
strategy:
fail-fast: False
matrix:
include: ${{fromJson(needs.determine-targets.outputs.target)}}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: 'openwrt'
- name: Download external toolchain from build job
uses: actions/download-artifact@v3
with:
name: ${{ matrix.target }}-${{ matrix.subtarget }}-external-toolchain
path: openwrt
- name: Find external toolchain name
id: get-toolchain-name
working-directory: openwrt
run: |
TOOLCHAIN_NAME=$(ls | grep toolchain-${{ matrix.target }}-${{ matrix.subtarget }})
echo "toolchain-name=$TOOLCHAIN_NAME" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: openwrt
push: true
tags: ghcr.io/${{ needs.determine-container-info.outputs.owner-lc }}/toolchain:${{ matrix.target }}-${{ matrix.subtarget }}-${{ needs.determine-container-info.outputs.container-tag }}
file: openwrt/.github/workflows/Dockerfile.toolchain
build-args: |
OWNER_LC=${{ needs.determine-container-info.outputs.owner-lc }}
CONTAINER_TAG=${{ needs.determine-container-info.outputs.container-tag }}
TOOLCHAIN_NAME=${{ steps.get-toolchain-name.outputs.toolchain-name }}
|