Skip to content

packages: lime-docs: reduce some verbosity #18

packages: lime-docs: reduce some verbosity

packages: lime-docs: reduce some verbosity #18

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 }}/