armbian-build/.github/workflows/build-single.yml
2021-11-20 19:47:52 +01:00

229 lines
8.6 KiB
YAML

name: Build selected image
on:
workflow_dispatch:
inputs:
boards:
description: 'Comma delimited list'
required: true
default: 'bananapi'
repository:
description: 'Packages from repository'
required: true
default: 'yes'
jobs:
prepare:
name: Build image(s) for download section
runs-on: [self-hosted, Linux, X64, cache, big]
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- 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
if [[ $(curl -s http://ifconfig.me) == "93.103.15.56" ]]; then
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
fi
sudo mountpoint -q build/output/images && sudo fusermount -u build/output/images || 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
sleep 10
done
[[ -d build/output/debug ]] && rm -rf build/output/debug/* || true
[[ -d build/.git ]] && sudo chown -R $USER:$USER build/.git || true
[[ -d build/output/images ]] && sudo rm -rf build/output/images/* || true
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: master
clean: false
- name: Checkout Armbian support scripts
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/scripts
token: ${{ secrets.SCRIPTS_ACCESS_TOKEN }}
path: scripts
clean: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_KEY1 }}
passphrase: ${{ secrets.GPG_PASSPHRASE1 }}
workdir: build
git-user-signingkey: true
git-commit-gpgsign: true
- name: Prepare
env:
GPG_PASS: ${{ secrets.GPG_PASSPHRASE1 }}
REBUILD_IMAGES: ${{ github.event.inputs.boards }}
REPOSITORY: ${{ github.event.inputs.repository }}
run: |
cd build
[[ "${REPOSITORY}" == "yes" ]] && REPOSITORY_INSTALL="u-boot,kernel,armbian-config,armbian-zsh,armbian-firmware"
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
PARALLEL_BUILDS=$(awk '{printf("%d",$1/8000)}' <<<$(($(LC_ALL=C free -w 2>/dev/null | grep "^Mem" | awk '{print $2}' || LC_ALL=C free | grep "^Mem"| awk '{print $2}')/1024)))
if [[ $(curl -s http://ifconfig.me) == "93.103.15.56" ]]; then
sudo mkdir -p cache/toolchain cache/rootfs || true
# umount
sudo umount cache/toolchain || true
# erase below
sudo mountpoint -q cache/toolchain && sudo rm -rf cache/toolchain/*
! sudo mountpoint -q cache/toolchain && sudo rm -rf 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
! sudo mountpoint -q cache/rootfs && sudo rm -rf cache/rootfs/* && sudo mount nas:/tank/armbian/dl.armbian.com/_rootfs cache/rootfs -o rsize=32768,wsize=32768,timeo=5,retrans=2,actimeo=60,retry=15 || true
else
sudo rsync --size-only --delete -avr rsync://rsync.armbian.com/dl/_rootfs/. cache/rootfs/ || true
fi
# 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 output/images || true
sudo sshfs upload@users.armbian.com:/images output/images -o IdentityFile=~/.ssh/id_rsa
# use prepared configs
sudo cp ../scripts/configs/* userpatches/
# use version from scripts
sudo cp ../scripts/VERSION .
# cleaning leftovers if any
sudo rm -rf output/debs/*
sudo rm -f userpatches/targets.conf
[[ "${REPOSITORY}" != "yes" ]] && ./compile.sh single IGNORE_HASH="yes" REPOSITORY_INSTALL="${REPOSITORY_INSTALL}" REBUILD_IMAGES="${REBUILD_IMAGES}" KERNEL_ONLY="yes" BETA="no" BUILD_ALL="yes" BSP_BUILD="yes" MAKE_ALL_BETA="yes" GPG_PASS="${GPG_PASS}"
./compile.sh single MULTITHREAD="${PARALLEL_BUILDS}" REPOSITORY_INSTALL="${REPOSITORY_INSTALL}" IGNORE_HASH="yes" IGNORE_UPDATES="yes" REBUILD_IMAGES="${REBUILD_IMAGES}" KERNEL_ONLY="no" BETA="no" BUILD_ALL="yes" GPG_PASS="${GPG_PASS}"
# umount
while mountpoint output/images -q
do
sudo umount output/images || true
echo "Trying to unmount ..."
sleep 10
done
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_KEY2 }}
passphrase: ${{ secrets.GPG_PASSPHRASE2 }}
workdir: scripts
git-user-signingkey: true
git-commit-gpgsign: true
- name: Make BSP packages if we build from sources
if: ${{ success() && github.event.inputs.repository != 'yes' }}
env:
GPG_PASS: ${{ secrets.GPG_PASSPHRASE1 }}
run: |
cd build
sudo rm -f .tmp/bump
if [[ $(cat .tmp/n 2> /dev/null) -ne 0 ]]; then
./compile.sh all-new-stable-bsp GPG_PASS="${GPG_PASS}"
sudo touch .tmp/bump
# wait until it finishes
while :
do
[[ $(sudo ps -uax | grep compile.sh | wc -l) -le 1 ]] && exit
echo "Waiting for background processes to finish."
sleep 10
done
fi
- name: Bump stable version if we build from sources
if: ${{ success() && github.event.inputs.repository != 'yes' }}
run: |
cd scripts
sudo git clean -ffdx && git reset --hard HEAD
git config pull.rebase false
VERSION=$(cat VERSION | cut -d. -f1,2)
PATCH=$(cat VERSION | cut -d. -f3,3)
echo $VERSION"."$(($PATCH + 1)) | tee VERSION
git config --global user.email "info@armbian.com"
git config --global user.name "Armbianworker"
git pull --allow-unrelated-histories
git add VERSION
git commit -m "Bump stable version" -m "" -m "Adding following kernels:" -m "$(find output/debs/ -type f -name "linux-image*.deb" -printf "%f\n" | sort)"
git push
- name: Install SSH key for storage
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.KEY_TORRENTS }}
known_hosts: ${{ secrets.KNOWN_HOSTS_UPLOAD }}
if_key_exists: replace
- name: Deploy packages to server
if: ${{ success() && github.event.inputs.repository != 'yes' }}
run: |
lftp -u upload, -e "set net:timeout 4;set net:max-retries 6;mirror --Remove-source-files -R --no-empty-dirs --parallel=8 --no-perms $(pwd)/build/output/debs/ debs/ ;bye" sftp://users.armbian.com
repository:
#
# Rebuilds package repository
#
name: Update package repository
needs: [prepare]
if: ${{ github.event.inputs.repository != 'yes' && github.repository_owner == 'Armbian' }}
runs-on: [self-hosted, Linux, local]
steps:
- name: Install SSH key for repository
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.KEY_REPOSITORY }}
name: id_repository # optional
known_hosts: ${{ secrets.KNOWN_HOSTS_REPOSITORY }}
if_key_exists: replace
- name: Update repository
run: ssh -T -i ~/.ssh/id_repository ${{ secrets.USER_REPOSITORY }}@${{ secrets.HOST_REPOSITORY }}