mirror of
https://github.com/armbian/scripts.git
synced 2026-01-06 10:32:48 -08:00
259 lines
9.9 KiB
YAML
259 lines
9.9 KiB
YAML
name: Build Kernels
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
inputs:
|
|
runner:
|
|
required: true
|
|
type: string
|
|
uploading:
|
|
type: string
|
|
reference:
|
|
type: string
|
|
secrets:
|
|
GPG_KEY1:
|
|
required: true
|
|
GPG_PASSPHRASE1:
|
|
required: true
|
|
GPG_KEY2:
|
|
required: true
|
|
GPG_PASSPHRASE2:
|
|
required: true
|
|
SCRIPTS_ACCESS_TOKEN:
|
|
required: true
|
|
KEY_TORRENTS:
|
|
required: true
|
|
KNOWN_HOSTS_UPLOAD:
|
|
required: true
|
|
jobs:
|
|
|
|
Prepare:
|
|
|
|
name: Build
|
|
if: ${{ github.repository_owner == 'Armbian' }}
|
|
runs-on: ${{ inputs.runner }}
|
|
outputs:
|
|
matrix: ${{steps.list_dirs.outputs.matrix}}
|
|
steps:
|
|
|
|
- uses: igorpecovnik/freespace@main
|
|
|
|
- name: Clean temporally folders
|
|
run: |
|
|
sudo rm -rf build/.tmp 2>/dev/null || true
|
|
sudo mountpoint -q build/output/debs && sudo fusermount -u build/output/debs || true
|
|
sudo mountpoint -q build/output/debs-beta && sudo fusermount -u build/output/debs-beta || true
|
|
sudo mountpoint -q build/cache/rootfs && sudo fusermount -u build/cache/rootfs || true
|
|
sudo mountpoint -q build/cache/toolchain && sudo fusermount -u build/cache/toolchain || true
|
|
sudo chown -R $USER:$USER build || true
|
|
|
|
- name: Checkout Armbian build script
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: armbian/build
|
|
path: build
|
|
ref: ${{ inputs.reference }}
|
|
fetch-depth: 0
|
|
clean: false
|
|
|
|
- name: Checkout support scripts
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
repository: armbian/scripts
|
|
path: scripts
|
|
clean: false
|
|
|
|
- name: Remove previous artefacts if any
|
|
run: |
|
|
|
|
sudo rm -rf changes 2>/dev/null || true
|
|
|
|
- name: Download changes
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
name: changes
|
|
|
|
- name: Determine changed kernels
|
|
id: list_dirs
|
|
run: |
|
|
|
|
echo ::set-output name=matrix::$(for x in $(cat changes 2>/dev/null); do echo $x; done|jq -cnR '[inputs | select(length>0)]' | jq)
|
|
gcc:
|
|
|
|
needs: [ Prepare ]
|
|
runs-on: ${{ inputs.runner }}
|
|
if: ${{ needs.Prepare.outputs.matrix != '[]' && needs.Prepare.outputs.matrix != '' }}
|
|
timeout-minutes: 480
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
node: ${{fromJson(needs.Prepare.outputs.matrix)}}
|
|
|
|
steps:
|
|
|
|
- uses: igorpecovnik/freespace@main
|
|
|
|
- name: Clean temporally folders
|
|
run: |
|
|
sudo rm -rf build/.tmp 2>/dev/null || true
|
|
sudo mountpoint -q build/output/debs && sudo fusermount -u build/output/debs || true
|
|
sudo mountpoint -q build/output/debs-beta && sudo fusermount -u build/output/debs-beta || true
|
|
sudo mountpoint -q build/cache/rootfs && sudo fusermount -u build/cache/rootfs || true
|
|
sudo mountpoint -q build/cache/toolchain && sudo fusermount -u build/cache/toolchain || true
|
|
sudo chown -R $USER:$USER build || true
|
|
|
|
- name: Checkout Armbian build script
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: armbian/build
|
|
path: build
|
|
fetch-depth: 0
|
|
ref: ${{ inputs.reference }}
|
|
clean: false
|
|
|
|
- name: Checkout support scripts
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
repository: armbian/scripts
|
|
path: scripts
|
|
clean: false
|
|
|
|
- name: Install SSH key for storage
|
|
if: ${{ inputs.uploading == 'true' }}
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.KEY_TORRENTS }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS_UPLOAD }}
|
|
if_key_exists: replace
|
|
|
|
- name: Fix permissions
|
|
run: |
|
|
|
|
# make sure no temporally dirs are mounted from previous runs
|
|
while :
|
|
do
|
|
sudo pkill compile.sh || true
|
|
sudo pkill arm-binfmt-P || true
|
|
sudo pkill aarch64-binfmt-P || true
|
|
sudo pkill pixz || true
|
|
sudo mountpoint -q build/output/images && sudo fusermount -u build/output/images || true
|
|
sudo mountpoint -q build/output/debs && sudo fusermount -u build/output/debs || true
|
|
sudo mountpoint -q build/output/debs-beta && sudo fusermount -u build/output/debs-beta || true
|
|
[[ "$(df | grep "/.tmp" | wc -l)" -eq 0 && $(sudo mountpoint -q build/output/images; echo $?) -eq 1 ]] && sudo rm -rf build/.tmp && break
|
|
echo "Mounted temp directories. Trying to unmount."
|
|
df | grep ".tmp" | awk '{print $6}' | xargs sudo umount 2>/dev/null || true
|
|
sudo rm -f build/cache/hash/*
|
|
sudo rm -f build/cache/hash-beta/*
|
|
sleep 10
|
|
done
|
|
[[ -d build/.git ]] && sudo chown -R $USER:$USER build/.git || true
|
|
[[ -d build/output/images ]] && sudo rm -rf build/output/images/* || true
|
|
|
|
- name: Mount upload folders
|
|
if: ${{ inputs.uploading == 'true' }}
|
|
run: |
|
|
|
|
# use this only on our runners
|
|
if [[ ${{ inputs.runner }} != "ubuntu-latest" ]]; then
|
|
# mount deploy target
|
|
sudo apt-get -y -qq install sshfs
|
|
sudo mkdir -p /root/.ssh/
|
|
sudo cp ~/.ssh/known_hosts /root/.ssh/
|
|
sudo mkdir -p build/output/debs || true
|
|
sudo mkdir -p build/output/debs-beta || true
|
|
sudo sshfs upload@users.armbian.com:/debs build/output/debs -o IdentityFile=~/.ssh/id_rsa -o reconnect,nonempty -o allow_other
|
|
sudo sshfs upload@users.armbian.com:/debs-beta build/output/debs-beta -o IdentityFile=~/.ssh/id_rsa -o reconnect,nonempty -o allow_other
|
|
fi
|
|
|
|
- name: Sync
|
|
run: |
|
|
|
|
sudo mkdir -p build/userpatches build/cache/hash build/cache/hash-beta
|
|
sudo rm -f build/userpatches/targets.conf
|
|
sudo cp scripts/configs/* build/userpatches/
|
|
sudo rm -r build/cache/hash/* build/cache/hash-beta/* 2> /dev/null || true
|
|
|
|
- name: Pull Docker image
|
|
run: |
|
|
|
|
[[ -z $(command -v docker) ]] && sudo apt-get -yy install docker containerd docker.io
|
|
sudo docker kill $(sudo docker ps -q) 2>/dev/null || true
|
|
sudo docker image rm $(sudo docker images | grep -v $(cat build/VERSION | cut -d"." -f1-2)"-$(dpkg --print-architecture)" | awk 'NR>1 {print $3}') 2> /dev/null || true
|
|
sudo docker pull ghcr.io/armbian/build:$(cat build/VERSION | cut -d"." -f1-2)"-$(dpkg --print-architecture)"
|
|
|
|
- name: Build
|
|
run: |
|
|
|
|
cd build
|
|
|
|
if [[ $(curl -s http://ifconfig.me) == "93.103.15.56" ]]; then
|
|
sudo mkdir -p cache/toolchain cache/rootfs || true
|
|
! sudo mountpoint -q cache/toolchain && sudo mount nas:/tank/armbian/toolchain.armbian.com cache/toolchain -o rsize=32768,wsize=32768,timeo=5,retrans=2,actimeo=60,retry=15 || true
|
|
fi
|
|
|
|
|
|
if [[ $(curl -s http://ifconfig.me) == "188.227.12.36" ]]; then
|
|
sudo mkdir -p cache/toolchain build/cache/rootfs || true
|
|
! sudo mountpoint -q cache/toolchain && sudo mount --bind /mnt/armbian/cache/toolchain/ cache/toolchain -o rsize=32768,wsize=32768,timeo=5,retrans=2,actimeo=60,retry=15 || true
|
|
fi
|
|
|
|
CHUNK="${{ matrix.node }}"
|
|
BOARD=$(echo $CHUNK | cut -d":" -f4)
|
|
BRANCH=$(echo $CHUNK | cut -d":" -f3)
|
|
FAMILY=$(echo $CHUNK | cut -d":" -f2)
|
|
export TERM=dumb
|
|
|
|
sudo sed -i "s/-it --rm/-i --rm/" userpatches/config-docker.conf
|
|
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
|
|
./compile.sh docker \
|
|
ARMBIAN_MIRROR="https://github.com/armbian/mirror/releases/download/" \
|
|
REPOSITORY_INSTALL="u-boot,armbian-bsp-cli,armbian-bsp-desktop,armbian-desktop,armbian-config,armbian-firmware" \
|
|
BOARD="$BOARD" \
|
|
CLEAN_LEVEL="make,oldcache" \
|
|
PRIVATE_CCACHE="yes" \
|
|
BETA="yes" \
|
|
KERNEL_ONLY="yes" \
|
|
BRANCH="$BRANCH" \
|
|
USE_MAINLINE_GOOGLE_MIRROR="yes" \
|
|
KERNEL_CONFIGURE="no" \
|
|
EXPERT="yes"
|
|
|
|
if [[ $? -eq 0 ]]; then
|
|
mkdir -p ../build-kernel
|
|
cp cache/hash-beta/*.git* ../build-kernel/ 2> /dev/null || true
|
|
echo "FILE_HASH=$(ls -1 cache/hash-beta/*.githash | head -1)" >> $GITHUB_ENV
|
|
echo "FILE_NAME=${BRANCH}-${FAMILY}" >> $GITHUB_ENV
|
|
echo "UPLOAD=true" >> $GITHUB_ENV
|
|
# Cleanup
|
|
# sudo find output/debs-beta/. -type f -not \( -name 'linux*' -or -name 'armbian*' -or -name '.*' \) -print0 | sudo xargs -0 -I {} rm {}
|
|
# copy edge brach to stable repo
|
|
# sudo cp output/debs-beta/linux-{dtb,image,source,headers}-edge-* output/debs/ || true
|
|
fi
|
|
|
|
- name: Upload hash
|
|
if: ${{ env.UPLOAD == 'true' && inputs.uploading == 'true' && env.FILE_HASH != '' }}
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: hash
|
|
if-no-files-found: ignore
|
|
path: build/${{ env.FILE_HASH }}
|
|
|
|
- name: Upload build artifacts
|
|
if: ${{ env.UPLOAD == 'true' && inputs.uploading == 'true' && env.FILE_HASH != '' && github.event_name == 'pull_request' }}
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ env.FILE_NAME }}
|
|
path: build/output/debs-beta/linux-*${{ env.FILE_NAME }}*
|
|
if-no-files-found: ignore
|
|
retention-days: 30
|
|
|
|
- name: Unmount folders
|
|
|
|
run: |
|
|
|
|
sudo mountpoint -q build/output/debs && sudo fusermount -u build/output/debs || true
|
|
sudo mountpoint -q build/output/debs-beta && sudo fusermount -u build/output/debs-beta || true
|
|
sudo mountpoint -q build/cache/toolchain && sudo fusermount -u build/cache/toolchain || true
|