Recreate Matrix (push) #422
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This action recreate action for building stable images | |
# | |
name: Recreate Matrix (push) | |
on: | |
schedule: | |
- cron: '00 5 * * *' | |
push: | |
branches: | |
- 'main' | |
paths: | |
- "userpatches/*.template" | |
- "userpatches/*.map" | |
- "userpatches/*.blacklist" | |
- "userpatches/gha/**" | |
- "userpatches/gha/chunks/**" | |
- ".github/workflows/recreate-matrix.yml" | |
workflow_dispatch: | |
repository_dispatch: | |
types: [Recreate Matrix] | |
concurrency: | |
group: matrix-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Recreate action | |
if: ${{ github.repository_owner == 'Armbian' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Armbian Framework | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: armbian/build | |
ref: main | |
fetch-depth: 0 | |
clean: false | |
path: build | |
- name: Checkout Armbian OS Config | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: armbian/os | |
ref: main | |
clean: false | |
fetch-depth: 0 | |
path: os | |
- name: "Rsync userpatches" | |
run: | | |
rsync -av os/userpatches/. build/userpatches/ | |
rm -f build/userpatches/targets.yaml | |
- name: "Generate builds lists" | |
run: | | |
cat <<- EOF > os/.github/workflows/complete-artifact-one-by-one.yml | |
name: "Build One by One (anyone)" | |
on: | |
workflow_dispatch: | |
inputs: | |
armbian_target: | |
type: choice | |
description: 'Build' | |
required: false | |
options: | |
- kernel | |
- build | |
default: build | |
armbian_kernel_branch: | |
type: choice | |
description: 'Kernel branch' | |
options: | |
- legacy | |
- current | |
- edge | |
default: 'current' | |
armbian_release: | |
type: choice | |
description: 'Userspace' | |
options: | |
- jammy | |
- mantic | |
- bookworm | |
- trixie | |
- sid | |
default: 'jammy' | |
armbian_ui: | |
type: choice | |
description: 'User interface (not all works)' | |
options: | |
- minimal | |
- server | |
- xfce | |
- gnome | |
- cinnamon | |
- i3-wm | |
- kde-plasma | |
default: 'minimal' | |
armbian_version: | |
description: 'Version' | |
required: false | |
default: '' | |
armbian_board: | |
type: choice | |
description: 'Board' | |
options: | |
EOF | |
# generate lists to include them | |
ls -1 build/config/boards/*.{conf,wip,csc} | cut -d"/" -f4 | cut -d"." -f1 | uniq | sed 's/.*/ - &/' >> os/.github/workflows/complete-artifact-one-by-one.yml | |
cat <<- EOF >> os/.github/workflows/complete-artifact-one-by-one.yml | |
jobs: | |
build: | |
name: "Build Armbian" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: armbian/[email protected] | |
with: | |
armbian_token: "${{ '\${{secrets.GITHUB_TOKEN}}' }}" | |
armbian_target: "${{ '\${{inputs.armbian_target}}' }}" | |
armbian_release: "${{ '\${{inputs.armbian_release}}' }}" | |
armbian_kernel_branch: "${{ '\${{inputs.armbian_kernel_branch}}' }}" | |
armbian_ui: "${{ '\${{inputs.armbian_ui}}' }}" | |
armbian_board: "${{ '\${{inputs.armbian_board}}' }}" | |
armbian_release_tittle: "Armbian SDK" | |
armbian_release_body: "Virtual images for x86 and arm64" | |
armbian_pgp_key: "${{ '\${{secrets.GPG_KEY1}}' }}" | |
armbian_pgp_password: "${{ '\${{secrets.GPG_PASSPHRASE1}}' }}" | |
EOF | |
- name: "Generate builds lists" | |
run: | | |
# generate lists to include them | |
find build/config/boards/*.{conf,wip,tvb,csc} ! '(' -name '*.eos' ')' | cut -d"/" -f4 | cut -d"." -f1 | uniq | sort | sed 's/.*/ - &/' > /tmp/standard-support.txt | |
cp /tmp/standard-support.txt /tmp/staging.txt | |
cp /tmp/standard-support.txt /tmp/community-maintained.txt | |
#ls -1 build/config/boards/*.{conf,wip} | cut -d"/" -f4 | cut -d"." -f1 | uniq | sed 's/.*/ - &/' > /tmp/staging.txt | |
#ls -1 build/config/boards/*.{tvb,csc} | cut -d"/" -f4 | cut -d"." -f1 | uniq | sed 's/.*/ - &/' > /tmp/community-maintained.txt | |
grep BOARD_MAINTAINER build/config/boards/*.{conf,eos,wip,csc} | cut -d":" -f2 | cut -d"=" -f2 | sed 's/"/ /g' | tr -d '\n' | tr -s ' ' | xargs -n1 | sort | uniq | sed 's/.*/ - &/' > /tmp/maintainers.txt | |
git ls-remote --heads https://github.com/armbian/build | grep "v2" | cut -d"/" -f3 | sort | tail -1 | sed '1s/^/main\ntest\n/' | sed 's/.*/ - &/' > /tmp/branches.txt | |
function enable_extension() | |
{ | |
: | |
} | |
function display_alert() | |
{ | |
: | |
} | |
function make-targets() | |
{ | |
# cycle all board configs but .eos (end of support, which we swithc to when it breaks) | |
# We are replacing in target yaml. copy from template | |
cp $2.template $2.yaml | |
for SECTION in $1; do | |
# debug | |
echo "Adding: $SECTION to $2" >> $GITHUB_STEP_SUMMARY | |
OUTPUT=$(for board in $(ls -1 build/config/boards/*.{conf,csc,wip,tvb}); do | |
# read board family and determine ARCH | |
unset KERNEL_TEST_TARGET | |
SRC=$(pwd)/build | |
source $board | |
source build/config/sources/families/${BOARDFAMILY}.conf 2>/dev/null || true | |
# board status defines where it goes | |
if [[ $board == *.conf* ]]; then SUPPORT="standard-support"; | |
elif [[ $board == *.wip* ]]; then SUPPORT="staging"; | |
else SUPPORT="community-maintained"; fi | |
# ... and board ARCH defines where it goes | |
TARGET_SECTION="${SUPPORT}-slow-hdmi" | |
if [[ $ARCH == riscv64 ]]; then TARGET_SECTION="${SUPPORT}-riscv64"; | |
elif grep -q 'HAS_VIDEO_OUTPUT="no"' $board; then TARGET_SECTION="${SUPPORT}-headless"; | |
elif [[ $ARCH == arm64 || $ARCH == amd64 ]]; then TARGET_SECTION="${SUPPORT}-fast-hdmi" | |
fi | |
# exception. Lets not deal with this special target anymore, but leave it in configs | |
KERNEL_TARGET=${KERNEL_TARGET/,collabora/} | |
# if kernel test target is defined, override with it | |
[[ -n $KERNEL_TEST_TARGET ]] && KERNEL_TARGET=${KERNEL_TEST_TARGET} | |
# read kernel target | |
if [[ $(echo $KERNEL_TARGET | cut -d '"' -f 2 | sed "s/,/ /g" | wc -w) -gt 2 ]]; then | |
KERNEL_TARGET=$(echo $KERNEL_TARGET | cut -d '"' -f 2 | awk -F, '{ print $2,$3 }') | |
else | |
KERNEL_TARGET=$(echo $KERNEL_TARGET | cut -d '"' -f 2 | sed "s/,/ /g") | |
fi | |
# extract board name from config | |
board=$(echo $board | cut -d"/" -f4 | cut -d"." -f1) | |
# skip boards listed in this file | |
if grep -qw "^${board}" os/userpatches/targets-automation.blacklist; then continue; fi | |
if [[ $2 == *nightly* ]] && grep -qw "^${board}" os/userpatches/targets-automation-nightly.blacklist; then continue; fi | |
# our default is current build target. Use it or search further | |
if [[ $TARGET_SECTION == $SECTION ]]; then | |
VARIANTS=0 | |
for targets in ${KERNEL_TARGET}; do | |
if [[ "${targets}" == current && $VARIANTS -lt $3 ]]; then | |
# check if we have extension mapping defined | |
EXTENSION=$(grep -P '^(?=.*'$board',)(?=.*current:)' os/userpatches/targets-extensions.map | cut -d"=" -f2) | |
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi | |
echo " - { BOARD: $board, BRANCH: current${EXTENSION} }" | |
VARIANTS=$((VARIANTS+1)) | |
fi | |
if [[ "${targets}" == edge && $VARIANTS -lt $3 ]]; then | |
# check if we have extension mapping defined | |
EXTENSION=$(grep -P '^(?=.*'$board',)(?=.*edge:)' os/userpatches/targets-extensions.map | cut -d"=" -f2) | |
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi | |
echo " - { BOARD: $board, BRANCH: edge${EXTENSION} }" | |
VARIANTS=$((VARIANTS+1)) | |
fi | |
if [[ "${targets}" == legacy && $VARIANTS -lt $3 ]]; then | |
# check if we have extension mapping defined | |
EXTENSION=$(grep -P '^(?=.*'$board',)(?=.*legacy:)' os/userpatches/targets-extensions.map | cut -d"=" -f2) | |
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi | |
echo " - { BOARD: $board, BRANCH: legacy${EXTENSION} }" | |
VARIANTS=$((VARIANTS+1)) | |
fi | |
if [[ "${targets}" == vendor && $VARIANTS -lt $3 ]]; then | |
# check if we have extension mapping defined | |
EXTENSION=$(grep -P '^(?=.*'$board',)(?=.*vendor:)' os/userpatches/targets-extensions.map | cut -d"=" -f2) | |
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi | |
echo " - { BOARD: $board, BRANCH: vendor${EXTENSION} }" | |
VARIANTS=$((VARIANTS+1)) | |
fi | |
if [[ ! "$targets" =~ ^(legacy|vendor|current|edge)$ && $targets != collabora ]]; then | |
# otherwise it must be custom kernel target | |
EXTENSION=$(grep -P '^(?=.*'${board}',)(?=.*'${targets}':)' os/userpatches/targets-extensions.map | cut -d"=" -f2) | |
if [[ -n $EXTENSION ]]; then EXTENSION=", ENABLE_EXTENSIONS: $EXTENSION"; fi | |
echo " - { BOARD: $board, BRANCH: ${targets}${EXTENSION}}" | |
fi | |
done | |
fi | |
done) | |
if [[ -n $OUTPUT ]]; then | |
TEMPFILE=$(mktemp) | |
( | |
echo " $SECTION: &$SECTION" | |
echo " # auto generated section" | |
while IFS= read -r line | |
do | |
echo "$line" | |
done <<< $OUTPUT | |
# mark end of the section | |
echo -e " # end of auto generated section\n" | |
) > $TEMPFILE | |
# since its not empty, add to the yaml file | |
sed -i "/ # automated lists start/r $TEMPFILE" ${2}.yaml | |
# add also to section | |
sed -i -e '/ automated-section/,/items/{/items/a \ \ \ \ \ \ - *'$SECTION'' -e '}' ${2}.yaml | |
else | |
# remove tags from manually made sections or it will exit with error | |
sed -i '/'$SECTION'/d' ${2}.yaml | |
echo "Removing $SECTION from $2" | |
fi | |
done | |
} | |
# define which sections goes into which list | |
BUILD_SECTIONS_STANDARD_SUPPORT=" | |
standard-support-slow-hdmi | |
standard-support-fast-hdmi | |
standard-support-headless | |
standard-support-riscv64 | |
" | |
BUILD_SECTIONS_COMMUNITY_MAINTAINED=" | |
community-maintained-slow-hdmi | |
community-maintained-fast-hdmi | |
community-maintained-headless | |
community-maintained-riscv64 | |
" | |
BUILD_SECTIONS_NIGHTLY=" | |
standard-support-slow-hdmi | |
staging-slow-hdmi | |
standard-support-fast-hdmi | |
staging-fast-hdmi | |
standard-support-headless | |
staging-headless | |
standard-support-riscv64 | |
staging-riscv64 | |
" | |
# $1 = parts to add | |
# $2 = filename that copy from .template to .yaml | |
# $3 = how many to build 1 or 2 (current,edge,legacy; current,legacy) | |
make-targets "${BUILD_SECTIONS_STANDARD_SUPPORT}" "os/userpatches/targets-release-standard-support" "2" | |
make-targets "${BUILD_SECTIONS_STANDARD_SUPPORT}" "os/userpatches/targets-release-apps" "1" | |
make-targets "${BUILD_SECTIONS_COMMUNITY_MAINTAINED}" "os/userpatches/targets-release-community-maintained" "1" | |
make-targets "${BUILD_SECTIONS_NIGHTLY}" "os/userpatches/targets-release-nightly" "1" | |
- name: "Generate Action Script" | |
run: | | |
cd build | |
# Last stable branch | |
#LAST=$(git branch -r | grep "v2" | tail -1 | cut -d"/" -f2) | |
# generate targets-release-community-maintained.yaml | |
#cp userpatches/targets-release-community-maintained.template userpatches/targets-release-community-maintained.yaml | |
#sed -i '/ # unsupported/r /tmp/unsupported.txt' userpatches/targets-release-community-maintained.yaml | |
#sed -i '/ # unsupported-headless/r /tmp/unsupported-headless.txt' userpatches/targets-release-community-maintained.yaml | |
#git add userpatches/targets-release-community-maintained.yaml | |
#git add userpatches/targets-release-community-maintained.yaml | |
#git add -f userpatches/targets-release-community-maintained.yaml | |
# | |
# copy nightly templates | |
# | |
cp userpatches/gha/gha_config_nightly.yaml userpatches/gha/gha_config.yaml | |
cp userpatches/targets-release-nightly.yaml userpatches/targets.yaml | |
bash ./compile.sh gha-template | |
# add boards, maintainers and branches | |
sed -i '/# boards/r /tmp/staging.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml | |
# we need unique concurency id | |
sed -i "s/pipeline-/pipeline-nightly/" output/info/artifact-image-complete-matrix.yml | |
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-nightly.yml | |
# | |
# copy old stable templates | |
# | |
#cp userpatches/gha/gha_config_old_stable.yaml userpatches/gha/gha_config.yaml | |
#cp userpatches/targets-release.yaml userpatches/targets.yaml | |
#sed -i 's/build_ref: .*/build_ref: "'$LAST'"/' userpatches/gha/gha_config.yaml | |
#bash ./compile.sh gha-template | |
# add boards and maintainers | |
#sed -i '/# boards/r /tmp/boards.txt' output/info/artifact-image-complete-matrix.yml | |
#sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml | |
# we need unique concurency id | |
#sed -i "s/pipeline-/pipeline-old-stable/" output/info/artifact-image-complete-matrix.yml | |
#cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-old-stable.yml | |
# | |
# copy standard support release templates | |
# | |
cp userpatches/gha/gha_config_release_standard_support.yaml userpatches/gha/gha_config.yaml | |
cp userpatches/targets-release-standard-support.yaml userpatches/targets.yaml | |
bash ./compile.sh gha-template | |
# add boards and maintainers | |
sed -i '/# boards/r /tmp/standard-support.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml | |
# we need unique concurency id | |
sed -i "s/pipeline-/standard-support/" output/info/artifact-image-complete-matrix.yml | |
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-standard-support.yml | |
# | |
# copy apps release templates | |
# | |
cp userpatches/gha/gha_config_release_apps.yaml userpatches/gha/gha_config.yaml | |
cp userpatches/targets-release-apps.yaml userpatches/targets.yaml | |
bash ./compile.sh gha-template | |
# add boards and maintainers | |
sed -i '/# boards/r /tmp/standard-support.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml | |
# we need unique concurency id | |
sed -i "s/pipeline-/apps/" output/info/artifact-image-complete-matrix.yml | |
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-apps.yml | |
# | |
# copy unsupported release templates | |
# | |
cp userpatches/gha/gha_config_release_community_maintained.yaml userpatches/gha/gha_config.yaml | |
cp userpatches/targets-release-community-maintained.yaml userpatches/targets.yaml | |
bash ./compile.sh gha-template | |
# add boards and maintainers | |
sed -i '/# boards/r /tmp/community-maintained.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml | |
# we need unique concurency id | |
sed -i "s/pipeline-/unsupported/" output/info/artifact-image-complete-matrix.yml | |
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-community-maintained.yml | |
# | |
# copy all templates | |
# | |
cp userpatches/gha/gha_config_all.yaml userpatches/gha/gha_config.yaml | |
cp userpatches/targets-all-not-eos.yaml userpatches/targets.yaml | |
bash ./compile.sh gha-template | |
# add boards and maintainers | |
sed -i '/# boards/r /tmp/boards.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml | |
# we need unique concurency id | |
sed -i "s/pipeline-/pipeline-all/" output/info/artifact-image-complete-matrix.yml | |
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-all.yml | |
# | |
# copy all stable templates | |
# | |
cp userpatches/gha/gha_config_all_stable.yaml userpatches/gha/gha_config.yaml | |
cp userpatches/targets-all-not-eos.yaml userpatches/targets.yaml | |
bash ./compile.sh gha-template | |
# add boards and maintainers | |
sed -i '/# boards/r /tmp/boards.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# maintainers/r /tmp/maintainers.txt' output/info/artifact-image-complete-matrix.yml | |
sed -i '/# branches/r /tmp/branches.txt' output/info/artifact-image-complete-matrix.yml | |
# we need unique concurency id | |
sed -i "s/pipeline-/pipeline-all/" output/info/artifact-image-complete-matrix.yml | |
cp output/info/artifact-image-complete-matrix.yml ../os/.github/workflows/complete-artifact-matrix-all-stable.yml | |
cd ../os | |
git config --local user.email "[email protected]" | |
git config --local user.name "Armbianworker" | |
# Update build list | |
git add userpatches/targets-release-standard-support.yaml | |
git add userpatches/targets-release-community-maintained.yaml | |
git add userpatches/targets-release-apps.yaml | |
git add userpatches/targets-release-nightly.yaml | |
# Add Action Scritps | |
git add .github/workflows/complete-artifact-matrix-nightly.yml | |
#git add .github/workflows/complete-artifact-matrix-old-stable.yml | |
git add .github/workflows/complete-artifact-matrix-standard-support.yml | |
git add .github/workflows/complete-artifact-matrix-community-maintained.yml | |
git add .github/workflows/complete-artifact-matrix-apps.yml | |
git add .github/workflows/complete-artifact-matrix-all.yml | |
git add .github/workflows/complete-artifact-matrix-all-stable.yml | |
git add .github/workflows/complete-artifact-one-by-one.yml | |
git commit --allow-empty -m "Update generated GHA chunk workflow artifact-image-complete-matrix.yml" -a | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.ACCESS_TOKEN_ARMBIANWORKER }} | |
repository: armbian/os | |
branch: ${{ github.ref }} | |
directory: os |