-
-
Notifications
You must be signed in to change notification settings - Fork 113
209 lines (179 loc) · 7.4 KB
/
Copy pathmulti-arch-build.yml
File metadata and controls
209 lines (179 loc) · 7.4 KB
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
name: Multi arch build packages
on:
release:
types: [published]
push:
branches: [master, "dev**"]
tags:
- v*
- '!v2020*'
paths:
- ".github/workflows/multi-arch-build.yml"
- 'packages/shared-state-async/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
arch:
description: "Architecture to build (empty for all)"
required: false
branches:
description: "Branches to build (empty for main stable oldstable)"
required: false
# Build packages using the openwrt sdk
# for each architecture supported
# in openwrt branches 'main', 'stable', 'oldstable'
jobs:
generate_matrix:
name: 'Generate matrix'
runs-on: ubuntu-latest
outputs:
matrix_builds: ${{ steps.define_matrix.outputs.matrix_builds }}
versions_list: ${{ steps.define_matrix.outputs.versions_list }}
dest_dir: ${{ steps.set_package_destination.outputs.dest_dir }}
packages: ${{ steps.define_packages_list.outputs.packages }}
steps:
- uses: actions/checkout@v5
- name: Define list of packages without PKGARCH:=all
id: define_packages_list
run: |
packages_list=$(grep -L PKGARCH:=all packages/*/Makefile | sed 's|\(.*\)/\(.*\)/Makefile|\2|g')
echo $packages_list
echo "packages=$packages_list" >> $GITHUB_OUTPUT
- name: Set package destination
id: set_package_destination
run: |
export TAG=$(echo "${{ github.ref }}" | cut -d '/' -f 3- | perl -pe 's/v([0-9])/$1/')
echo "$TAG"
echo "DEST_DIR=$TAG" >> $GITHUB_OUTPUT
- name: Define matrix of branches and archs
id: define_matrix
run: |
JSON='['
VERSIONS='['
FIRST_BUILD=1
FIRST_VERSION=1
versions=$(curl https://downloads.openwrt.org/.versions.json)
stable=$(echo $versions | jq | grep \"stable_ | sed 's|.*\"stable_version\": \"\(.*\)\",|\1|')
oldstable=$(echo $versions | jq | grep oldstable_ | sed 's|.*\"oldstable_version\": \"\(.*\)\",|\1|')
ARCH_FILTER="${{ github.event.inputs.arch }}"
BRANCHES_FILTER="${{ github.event.inputs.branches }}"
BRANCHES_LIST=$([ "$BRANCHES_FILTER" != "" ] && echo "$BRANCHES_FILTER" \
|| echo "main" "${stable:0:5}" "${oldstable:0:5}")
# BRANCHES_LIST=main
# ARCH_FILTER=mips_24kc
for version in $BRANCHES_LIST; do
VERSION=$([ "$version" == "main" ] \
&& echo "main" || echo "openwrt-$version")
echo $VERSION
VERSION_PATH=$([ "$version" == "main" ] \
&& echo "snapshots" || echo "releases/$version-SNAPSHOT")
echo $VERSION_PATH
OPENWRT_BRANCH_PATH="openwrt-$version"
echo $OPENWRT_BRANCH_PATH
if [ "$ARCH_FILTER" != "" ]; then
JSON="$JSON"'{"version": "'"$VERSION"'", "arch": "'"$ARCH_FILTER"'", "openwrt_branch_path": "'"$OPENWRT_BRANCH_PATH"'" }'
else
archs=$(curl https://downloads.openwrt.org/$VERSION_PATH/.targets.json | jq .[] | sort -u | sed 's|"||g')
for ARCH in $archs; do
# skip x86_64 as it should be built only by .github/workflows/build.yml
if [ "$ARCH" != "x86_64" ]; then
[[ $FIRST_BUILD -ne 1 ]] && JSON="$JSON"','
FIRST_BUILD=0
JSON="$JSON"'{"version": "'"$VERSION"'", "arch": "'"$ARCH"'", "openwrt_branch_path": "'"$OPENWRT_BRANCH_PATH"'" }'
fi
done
fi
[[ $FIRST_VERSION -ne 1 ]] && VERSIONS="$VERSIONS"','
FIRST_VERSION=0
VERSIONS="$VERSIONS"'{"version": "'"$VERSION"'", "openwrt_branch_path": "'"$OPENWRT_BRANCH_PATH"'" }'
done
echo $JSON
echo $VERSIONS
matrix_include='{"include": '"$JSON"']}'
echo "matrix_builds=${matrix_include}" >> "$GITHUB_OUTPUT"
versions_list_include='{"include": '"$VERSIONS"']}'
echo "versions_list=${versions_list_include}" >> "$GITHUB_OUTPUT"
build:
name: Build ${{ matrix.openwrt_branch_path }} ${{ matrix.arch }}
runs-on: ubuntu-latest
needs: generate_matrix
strategy:
fail-fast: false
max-parallel: 10
matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix_builds) }}
# matrix:
# include:
# - { version: main, arch: x86_64, openwrt_branch_path: 'openwrt-main'}
# - { version: main, arch: mips_24kc, openwrt_branch_path: 'openwrt-main'}
steps:
- uses: actions/checkout@v5
- name: Build packages ${{ matrix.arch }}-${{ matrix.version }}
uses: openwrt/gh-action-sdk@v9
env:
ARCH: "${{ matrix.arch }}-${{ matrix.version }}"
FEEDNAME: "libremesh"
IGNORE_ERRORS: "n m y"
KEY_BUILD: "${{ secrets.KEY_BUILD }}"
PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}"
PACKAGES: "${{ needs.generate_matrix.outputs.packages }}"
INDEX: 1
NO_DEFAULT_FEEDS: 1
NO_REFRESH_CHECK: 1
NO_SHFMT_CHECK: 1
# V: sc
- name: Reorder binaries by arch
run: |
mkdir -p bin_dir/${{ matrix.arch }}
mv bin/packages/${{ matrix.arch }}/libremesh/* bin_dir/${{ matrix.arch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.openwrt_branch_path }}-${{ matrix.arch }}
path: bin_dir/
merge_artifacts:
name: Merge artifacts ${{ matrix.openwrt_branch_path }}
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [generate_matrix, build]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate_matrix.outputs.versions_list) }}
steps:
- uses: actions/checkout@v5
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: ${{ matrix.openwrt_branch_path }}
pattern: ${{ matrix.openwrt_branch_path }}-*
delete-merged: true
publish:
name: Publish
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [generate_matrix, merge_artifacts]
steps:
- uses: actions/checkout@v5
- name: Checkout lime-feed
uses: actions/checkout@v5
with:
repository: libremesh/lime-feed
path: lime-feed
- uses: actions/download-artifact@v5
with:
path: artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/
- name: Replace packages
run: |
mkdir -p lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}
for branch in $(ls artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/); do
for arch in $(ls artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/$branch/); do
rm -rf lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/$branch/$arch
done;
done;
cp -r artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/* lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/
- name: Upload packages to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: libremesh/lime-feed
publish_dir: ./lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/
destination_dir: ${{ needs.generate_matrix.outputs.dest_dir }}/