Skip to content

Commit b23a8f4

Browse files
authored
Merge pull request #1139 from a-gave/ci/multi_branch_build
ci: add multi branch build; add support for apk; fix #1090 and #1135
2 parents 2cc9df1 + c528b2e commit b23a8f4

77 files changed

Lines changed: 447 additions & 1166 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 105 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,131 @@ on:
99
- v*
1010
- '!v2020*'
1111
paths:
12-
- ".github/workflows/*"
12+
- ".github/workflows/build.yml"
1313
- "libremesh.mk"
1414
- "packages/**"
15+
workflow_dispatch:
16+
inputs:
17+
packages:
18+
description: "Packages to build (empty for all)"
19+
required: false
1520

1621
jobs:
17-
build:
18-
name: Build ${{ github.ref }}
22+
# Build all packages for x86_64 using the openwrt sdk
23+
# for the branches 'main', 'stable', 'oldstable' of openwrt
24+
generate_matrix:
25+
name: 'Generate matrix'
1926
runs-on: ubuntu-latest
27+
outputs:
28+
matrix_builds: ${{ steps.define_matrix.outputs.matrix_builds }}
29+
dest_dir: ${{ steps.set_package_destination.outputs.dest_dir }}
30+
steps:
31+
- name: Set package destination
32+
id: set_package_destination
33+
run: |
34+
export TAG=$(echo "${{ github.ref }}" | cut -d '/' -f 3- | perl -pe 's/v([0-9])/$1/')
35+
echo "$TAG"
36+
echo "DEST_DIR=$TAG" >> $GITHUB_OUTPUT
37+
38+
- name: Define matrix of branches and archs
39+
id: define_matrix
40+
run: |
41+
JSON='['
42+
FIRST_BUILD=1
43+
versions=$(curl https://downloads.openwrt.org/.versions.json)
44+
stable=$(echo $versions | jq | grep \"stable_ | sed 's|.*\"stable_version\": \"\(.*\)\",|\1|')
45+
oldstable=$(echo $versions | jq | grep oldstable_ | sed 's|.*\"oldstable_version\": \"\(.*\)\",|\1|')
2046
47+
for version in "main" "${stable:0:5}" "${oldstable:0:5}"; do
48+
49+
VERSION=$([ "$version" == "main" ] \
50+
&& echo "main" || echo "openwrt-$version")
51+
echo $VERSION
52+
53+
OPENWRT_BRANCH_PATH="openwrt-$version"
54+
echo $OPENWRT_BRANCH_PATH
55+
56+
[[ $FIRST_BUILD -ne 1 ]] && JSON="$JSON"','
57+
FIRST_BUILD=0
58+
59+
JSON="$JSON"'{"version": "'"$VERSION"'", "openwrt_branch_path": "'"$OPENWRT_BRANCH_PATH"'" }'
60+
done
61+
62+
echo $JSON
63+
64+
matrix_include='{"include": '"$JSON"']}'
65+
echo "matrix_builds=${matrix_include}" >> "$GITHUB_OUTPUT"
66+
67+
build:
68+
name: Build ${{ matrix.openwrt_branch_path }} x86_64
69+
runs-on: ubuntu-latest
70+
needs: generate_matrix
71+
strategy:
72+
fail-fast: false
73+
matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix_builds) }}
2174
steps:
22-
- uses: actions/checkout@v2
75+
- uses: actions/checkout@v4
2376

2477
- name: Build packages
25-
uses: openwrt/gh-action-sdk@v7
78+
uses: openwrt/gh-action-sdk@v9
2679
env:
27-
ARCH: "x86_64-openwrt-23.05"
80+
ARCH: x86_64-${{ matrix.version }}
2881
FEEDNAME: "libremesh"
2982
IGNORE_ERRORS: "n m y"
3083
KEY_BUILD: "${{ secrets.KEY_BUILD }}"
84+
PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}"
85+
INDEX: 1
86+
NO_DEFAULT_FEEDS: 1
87+
NO_REFRESH_CHECK: 1
88+
NO_SHFMT_CHECK: 1
89+
PACKAGES: ${{ github.event.inputs.packages }}
90+
# V: sc
3191

32-
- name: Set package destination
92+
- name: Prepare artifacts paths
3393
run: |
34-
export TAG=$(echo "${{ github.ref }}" | cut -d '/' -f 3- | perl -pe 's/v([0-9])/$1/')
35-
echo "$TAG"
36-
echo "DEST_DIR=$TAG" >> $GITHUB_ENV
94+
bin_path="bin_dir/${{ matrix.openwrt_branch_path }}/x86_64"
95+
mkdir -p "$bin_path"
96+
mv bin/packages/x86_64/libremesh/* "$bin_path"
97+
98+
- name: Upload artifact
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: ${{ matrix.openwrt_branch_path }}
102+
path: bin_dir/
103+
104+
publish:
105+
name: Publish
106+
runs-on: ubuntu-latest
107+
if: ${{ always() }}
108+
needs: [generate_matrix, build]
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
- name: Checkout lime-feed
113+
uses: actions/checkout@v4
114+
with:
115+
repository: libremesh/lime-feed
116+
path: lime-feed
117+
118+
- uses: actions/download-artifact@v4
119+
with:
120+
merge-multiple: true
121+
path: artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/
122+
123+
- name: Replace packages
124+
run: |
125+
for branch in $(ls artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/); do
126+
rm -rf lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/$branch/x86_64
127+
done;
128+
cp -r artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/* lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/
37129
38130
- name: Upload packages to GitHub Pages
39-
uses: peaceiris/actions-gh-pages@v3
131+
uses: peaceiris/actions-gh-pages@v4
40132
with:
41133
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
42134
external_repository: libremesh/lime-feed
43-
publish_dir: bin/packages/x86_64/libremesh/
44-
destination_dir: ${{ env.DEST_DIR }}
135+
publish_dir: ./lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/
136+
destination_dir: "${{ needs.generate_matrix.outputs.dest_dir }}"
45137

46138
# - name: Upload packages to S3
47139
# uses: jakejarvis/s3-sync-action@master
@@ -54,4 +146,3 @@ jobs:
54146
# AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
55147
# SOURCE_DIR: bin/packages/x86_64/libremesh/
56148
# DEST_DIR: ${{ env.DEST_DIR }}
57-

.github/workflows/multi-arch-build.yml

Lines changed: 166 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,79 +9,197 @@ on:
99
- v*
1010
- '!v2020*'
1111
paths:
12+
- ".github/workflows/multi-arch-build.yml"
1213
- 'packages/shared-state-async/**'
1314

1415
# Allows you to run this workflow manually from the Actions tab
1516
workflow_dispatch:
17+
inputs:
18+
arch:
19+
description: "Architecture to build (empty for all)"
20+
required: false
21+
branches:
22+
description: "Branches to build (empty for main stable oldstable)"
23+
required: false
24+
25+
# Build packages using the openwrt sdk
26+
# for each architecture supported
27+
# in openwrt branches 'main', 'stable', 'oldstable'
1628

1729
jobs:
30+
generate_matrix:
31+
name: 'Generate matrix'
32+
runs-on: ubuntu-latest
33+
outputs:
34+
matrix_builds: ${{ steps.define_matrix.outputs.matrix_builds }}
35+
versions_list: ${{ steps.define_matrix.outputs.versions_list }}
36+
dest_dir: ${{ steps.set_package_destination.outputs.dest_dir }}
37+
packages: ${{ steps.define_packages_list.outputs.packages }}
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Define list of packages without PKGARCH:=all
42+
id: define_packages_list
43+
run: |
44+
packages_list=$(grep -L PKGARCH:=all packages/*/Makefile | sed 's|\(.*\)/\(.*\)/Makefile|\2|g')
45+
echo $packages_list
46+
echo "packages=$packages_list" >> $GITHUB_OUTPUT
47+
48+
- name: Set package destination
49+
id: set_package_destination
50+
run: |
51+
export TAG=$(echo "${{ github.ref }}" | cut -d '/' -f 3- | perl -pe 's/v([0-9])/$1/')
52+
echo "$TAG"
53+
echo "DEST_DIR=$TAG" >> $GITHUB_OUTPUT
54+
55+
- name: Define matrix of branches and archs
56+
id: define_matrix
57+
run: |
58+
JSON='['
59+
VERSIONS='['
60+
FIRST_BUILD=1
61+
FIRST_VERSION=1
62+
versions=$(curl https://downloads.openwrt.org/.versions.json)
63+
stable=$(echo $versions | jq | grep \"stable_ | sed 's|.*\"stable_version\": \"\(.*\)\",|\1|')
64+
oldstable=$(echo $versions | jq | grep oldstable_ | sed 's|.*\"oldstable_version\": \"\(.*\)\",|\1|')
65+
arch_filter="${{ github.event.inputs.arch }}"
66+
branches_filter="${{ github.event.inputs.branches }}"
67+
branches_list=$([ $branches_filter != "" ] && echo "$branches_filter" \
68+
|| echo "main" "${stable:0:5}" "${oldstable:0:5}")
69+
70+
# branches_list=main
71+
# arch_filter=mips_24kc
72+
73+
for version in $branches_list; do
74+
75+
VERSION=$([ "$version" == "main" ] \
76+
&& echo "main" || echo "openwrt-$version")
77+
echo $VERSION
78+
79+
VERSION_PATH=$([ "$version" == "main" ] \
80+
&& echo "snapshots/packages" || echo "releases/packages-$version")
81+
echo $VERSION_PATH
82+
83+
OPENWRT_BRANCH_PATH="openwrt-$version"
84+
echo $OPENWRT_BRANCH_PATH
85+
86+
wget -r -nH --no-parent --level 1 --accept html -P. \
87+
--directory-prefix=. https://downloads.openwrt.org/$VERSION_PATH/
88+
89+
if [ $arch_filter != "" ]; then
90+
JSON="$JSON"'{"version": "'"$VERSION"'", "arch": "'"$arch_filter"'", "openwrt_branch_path": "'"$OPENWRT_BRANCH_PATH"'" }'
91+
else
92+
for arch in $(ls ./$VERSION_PATH/ | grep -v html | grep -v x86_64); do
93+
[[ $FIRST_BUILD -ne 1 ]] && JSON="$JSON"','
94+
FIRST_BUILD=0
95+
96+
JSON="$JSON"'{"version": "'"$VERSION"'", "arch": "'"$arch"'", "openwrt_branch_path": "'"$OPENWRT_BRANCH_PATH"'" }'
97+
done
98+
fi
99+
100+
[[ $FIRST_VERSION -ne 1 ]] && VERSIONS="$VERSIONS"','
101+
FIRST_VERSION=0
102+
VERSIONS="$VERSIONS"'{"version": "'"$VERSION"'", "openwrt_branch_path": "'"$OPENWRT_BRANCH_PATH"'" }'
103+
done
104+
105+
echo $JSON
106+
echo $VERSIONS
107+
108+
matrix_include='{"include": '"$JSON"']}'
109+
echo "matrix_builds=${matrix_include}" >> "$GITHUB_OUTPUT"
110+
versions_list_include='{"include": '"$VERSIONS"']}'
111+
echo "versions_list=${versions_list_include}" >> "$GITHUB_OUTPUT"
112+
18113
build:
19-
name: build ${{ matrix.arch }} ${{ github.ref }}
114+
name: Build ${{ matrix.openwrt_branch_path }} ${{ matrix.arch }}
20115
runs-on: ubuntu-latest
116+
needs: generate_matrix
21117
strategy:
22118
fail-fast: false
23-
max-parallel: 1
24-
matrix:
25-
arch:
26-
- aarch64_cortex-a53
27-
- aarch64_cortex-a72
28-
- aarch64_generic
29-
- arm_arm1176jzf-s_vfp
30-
- arm_arm926ej-s
31-
- arm_cortex-a15_neon-vfpv4
32-
- arm_cortex-a5_vfpv4
33-
- arm_cortex-a7
34-
- arm_cortex-a7_neon-vfpv4
35-
- arm_cortex-a7_vfpv4
36-
- arm_cortex-a8_vfpv3
37-
- arm_cortex-a9
38-
- arm_cortex-a9_neon
39-
- arm_cortex-a9_vfpv3-d16
40-
- arm_fa526
41-
- arm_mpcore
42-
- arm_xscale
43-
- i386_pentium-mmx
44-
- i386_pentium4
45-
- mips64_octeonplus
46-
- mips_24kc
47-
- mips_4kec
48-
- mips_mips32
49-
- mipsel_24kc
50-
- mipsel_24kc_24kf
51-
- mipsel_74kc
52-
- mipsel_mips32
53-
- powerpc_464fp
54-
- powerpc_8548
55-
- riscv64_riscv64
56-
- x86_64
57-
119+
max-parallel: 10
120+
matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix_builds) }}
121+
# matrix:
122+
# include:
123+
# - { version: main, arch: x86_64, openwrt_branch_path: 'openwrt-main'}
124+
# - { version: main, arch: mips_24kc, openwrt_branch_path: 'openwrt-main'}
58125
steps:
59126
- uses: actions/checkout@v4
60127

61-
- name: Build packages ${{ matrix.arch }}
62-
uses: openwrt/gh-action-sdk@v7
128+
- name: Build packages ${{ matrix.arch }}-${{ matrix.version }}
129+
uses: openwrt/gh-action-sdk@v9
63130
env:
64-
ARCH: "${{ matrix.arch }}-openwrt-23.05"
131+
ARCH: "${{ matrix.arch }}-${{ matrix.version }}"
65132
FEEDNAME: "libremesh"
66133
IGNORE_ERRORS: "n m y"
67134
KEY_BUILD: "${{ secrets.KEY_BUILD }}"
68-
PACKAGES: "shared-state-bat_hosts"
135+
PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}"
136+
PACKAGES: "${{ needs.generate_matrix.outputs.packages }}"
69137
INDEX: 1
70138
NO_DEFAULT_FEEDS: 1
71139
NO_REFRESH_CHECK: 1
72140
NO_SHFMT_CHECK: 1
141+
# V: sc
142+
143+
- name: Reorder binaries by arch
144+
run: |
145+
mkdir -p bin_dir/${{ matrix.arch }}
146+
mv bin/packages/${{ matrix.arch }}/libremesh/* bin_dir/${{ matrix.arch }}
73147
74-
- name: Set package destination
148+
- name: Upload artifact
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: ${{ matrix.openwrt_branch_path }}-${{ matrix.arch }}
152+
path: bin_dir/
153+
154+
merge_artifacts:
155+
name: Merge artifacts ${{ matrix.openwrt_branch_path }}
156+
runs-on: ubuntu-latest
157+
if: ${{ always() }}
158+
needs: [generate_matrix, build]
159+
strategy:
160+
fail-fast: false
161+
matrix: ${{ fromJson(needs.generate_matrix.outputs.versions_list) }}
162+
steps:
163+
- uses: actions/checkout@v4
164+
165+
- name: Merge Artifacts
166+
uses: actions/upload-artifact/merge@v4
167+
with:
168+
name: ${{ matrix.openwrt_branch_path }}
169+
pattern: ${{ matrix.openwrt_branch_path }}-*
170+
delete-merged: true
171+
172+
publish:
173+
name: Publish
174+
runs-on: ubuntu-latest
175+
if: ${{ always() }}
176+
needs: [generate_matrix, merge_artifacts]
177+
steps:
178+
- uses: actions/checkout@v4
179+
180+
- name: Checkout lime-feed
181+
uses: actions/checkout@v4
182+
with:
183+
repository: libremesh/lime-feed
184+
path: lime-feed
185+
186+
- uses: actions/download-artifact@v4
187+
with:
188+
path: artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/
189+
190+
- name: Replace packages
75191
run: |
76-
export TAG=$(echo "${{ github.ref }}" | cut -d '/' -f 3- | perl -pe 's/v([0-9])/$1/')
77-
echo "$TAG"
78-
echo "DEST_DIR=$TAG" >> $GITHUB_ENV
192+
for branch in $(ls artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/); do
193+
for arch in $(ls artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/$branch/); do
194+
rm -rf lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/$branch/$arch
195+
done;
196+
done;
197+
cp -r artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/* lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/
79198
80199
- name: Upload packages to GitHub Pages
81-
uses: peaceiris/actions-gh-pages@v3
200+
uses: peaceiris/actions-gh-pages@v4
82201
with:
83202
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
84203
external_repository: libremesh/lime-feed
85-
publish_dir: bin/packages/${{ matrix.arch }}/libremesh/
86-
destination_dir: arch_packages/${{ env.DEST_DIR }}/${{ matrix.arch }}
87-
204+
publish_dir: ./lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/
205+
destination_dir: ${{ needs.generate_matrix.outputs.dest_dir }}/

0 commit comments

Comments
 (0)