|
9 | 9 | - v* |
10 | 10 | - '!v2020*' |
11 | 11 | paths: |
| 12 | + - ".github/workflows/multi-arch-build.yml" |
12 | 13 | - 'packages/shared-state-async/**' |
13 | 14 |
|
14 | 15 | # Allows you to run this workflow manually from the Actions tab |
15 | 16 | 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' |
16 | 28 |
|
17 | 29 | 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 | + |
18 | 113 | build: |
19 | | - name: build ${{ matrix.arch }} ${{ github.ref }} |
| 114 | + name: Build ${{ matrix.openwrt_branch_path }} ${{ matrix.arch }} |
20 | 115 | runs-on: ubuntu-latest |
| 116 | + needs: generate_matrix |
21 | 117 | strategy: |
22 | 118 | 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'} |
58 | 125 | steps: |
59 | 126 | - uses: actions/checkout@v4 |
60 | 127 |
|
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 |
63 | 130 | env: |
64 | | - ARCH: "${{ matrix.arch }}-openwrt-23.05" |
| 131 | + ARCH: "${{ matrix.arch }}-${{ matrix.version }}" |
65 | 132 | FEEDNAME: "libremesh" |
66 | 133 | IGNORE_ERRORS: "n m y" |
67 | 134 | KEY_BUILD: "${{ secrets.KEY_BUILD }}" |
68 | | - PACKAGES: "shared-state-bat_hosts" |
| 135 | + PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}" |
| 136 | + PACKAGES: "${{ needs.generate_matrix.outputs.packages }}" |
69 | 137 | INDEX: 1 |
70 | 138 | NO_DEFAULT_FEEDS: 1 |
71 | 139 | NO_REFRESH_CHECK: 1 |
72 | 140 | 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 }} |
73 | 147 |
|
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 |
75 | 191 | 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 }}/ |
79 | 198 |
|
80 | 199 | - name: Upload packages to GitHub Pages |
81 | | - uses: peaceiris/actions-gh-pages@v3 |
| 200 | + uses: peaceiris/actions-gh-pages@v4 |
82 | 201 | with: |
83 | 202 | deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} |
84 | 203 | 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