armbian-build/.github/workflows/build.yml
2021-06-14 21:26:08 +02:00

559 lines
17 KiB
YAML

name: Build beta & edge
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
jobs:
merge:
name: Merge nightly
runs-on: [self-hosted, Linux, x64]
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: nightly
clean: false
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_KEY2 }}
passphrase: ${{ secrets.GPG_PASSPHRASE2 }}
workdir: build
git-user-signingkey: true
git-commit-gpgsign: true
- name: Merge master into nightly
run: |
cd build
git config --global user.email "info@armbian.com"
git config --global user.name "Armbianworker"
git checkout master
git fetch
git merge origin/master
git checkout nightly
git merge master nightly
git push
cache:
name: Create rootfs cache
needs: merge
runs-on: [self-hosted, Linux, x64, cache]
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
[[ "$(df | grep "/.tmp" | wc -l)" -eq 0 ]] && 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
sudo chown -R $USER:$USER .
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: nightly
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: Build rootfs cache
run: |
echo "BLTPATH=\"$(pwd)/build/\"" | tee scripts/cacherebuild.conf scripts/betarepository.conf >/dev/null
cd build
rm -rf output/images/*
sudo mkdir -p userpatches
sudo cp ../scripts/configs/* userpatches/
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
./compile.sh KERNEL_ONLY="yes" BOARD="bananapi" BRANCH="current" KERNEL_CONFIGURE="no" \
USE_TORRENT="yes" REPOSITORY_INSTALL="kernel" 'prepare_host'
sudo rm -f userpatches/targets.conf
cd ../scripts
run-one ./cacherebuild.sh
- name: Import GPG key
if: ${{ success() }}
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_KEY1 }}
passphrase: ${{ secrets.GPG_PASSPHRASE1 }}
- name: Sign commit and push changes
if: ${{ success() }}
env:
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE1 }}
run: |
sudo apt-get -y -qq install parallel
cd build/cache/rootfs
sudo chown -R $USER:$USER .
(for file in $(ls | cut -d. -f1-4 | sort -u); do
if [ $(ls $file* | wc -l) -lt 3 ]; then
echo "$file"
fi
done) | parallel --jobs 32 'echo '${PASSPHRASE}' | gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes {}'
# - 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: Upload artefacts
# if: ${{ success() }}
# run: |
# sudo apt-get -y -qq install lftp
# sudo chown -R $USER:$USER $(pwd)/build/cache/rootfs/
# lftp -u upload, -e "set net:timeout 4;set net:max-retries 6;mirror -R --delete --no-empty-dirs --parallel=8 --no-perms $(pwd)/build/cache/rootfs/ rootfs/ ;bye" sftp://users.armbian.com
docker:
name: Docker image on x86
#runs-on: [self-hosted, Linux, x64]
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- name: Fix permissions
run: |
sudo chown -R $USER:$USER .
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: nightly
clean: false
- name: Build Docker image
run: |
cd build
sed -i "s/-it --rm/-i --rm/" config/templates/config-docker.conf
touch .ignore_changes
./compile.sh dockerpurge KERNEL_ONLY="yes" BOARD="bananapi" BRANCH="current" KERNEL_CONFIGURE="no" \
USE_TORRENT="yes" REPOSITORY_INSTALL="kernel" 'prepare_host'
sed -i "s/-it --rm/-i --rm/" userpatches/config-docker.conf
docker-arm64:
name: Docker image on arm64
runs-on: [self-hosted, Linux, ARM64]
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- name: Fix permissions
run: |
sudo chown -R $USER:$USER .
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: nightly
clean: false
- name: Build Docker image
run: |
cd build
sed -i "s/-it --rm/-i --rm/" config/templates/config-docker.conf
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
./compile.sh dockerpurge KERNEL_ONLY="yes" BOARD="bananapi" BRANCH="current" KERNEL_CONFIGURE="no" \
USE_TORRENT="yes" REPOSITORY_INSTALL="kernel" 'prepare_host'
sed -i "s/-it --rm/-i --rm/" userpatches/config-docker.conf
beta-kernels:
#
# Whenever kernel sources, patches or config are changed, we rebuild kernels + BSP and push
# them to https://beta.armbian.com repository.
#
name: Changed beta kernels
needs: merge
runs-on: [self-hosted, Linux, x64, 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
[[ "$(df | grep "/.tmp" | wc -l)" -eq 0 ]] && 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
sudo chown -R $USER:$USER .
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: nightly
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_KEY2 }}
passphrase: ${{ secrets.GPG_PASSPHRASE2 }}
workdir: scripts
git-user-signingkey: true
git-commit-gpgsign: true
- name: Build all changed kernels for beta repository
run: |
cd build
rm -rf output/debs-beta/*
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
./compile.sh KERNEL_ONLY="yes" BOARD="bananapi" BRANCH="current" KERNEL_CONFIGURE="no" \
REPOSITORY_INSTALL="u-boot,kernel" 'prepare_host'
mkdir -p cache/hash-beta
sudo rsync -ar --delete ../scripts/hash-beta/. cache/hash-beta/ 2> /dev/null
sudo cp ../scripts/configs/* userpatches/
sudo rm -f userpatches/targets.conf
./compile.sh all-new-beta-kernels
cd ../scripts
sudo git clean -ffdx && git reset --hard HEAD
git config pull.rebase false
cd ../build
sudo rsync -ar --delete cache/hash-beta/. ../scripts/hash-beta/
if [[ $(cat .tmp/n 2> /dev/null) -ne 0 ]]; then
cd ../scripts/
sudo chown -R $USER:$USER .
if git status --porcelain | grep .; then
git pull
git add .
git commit -m "Update hashes for beta repository"
git push
fi
fi
- name: Make BSP packages
if: ${{ success() }}
run: |
cd build
sudo rm -f .tmp/bump
if [[ $(cat .tmp/n 2> /dev/null) -ne 0 ]]; then
./compile.sh all-new-beta-bsp
sudo touch .tmp/bump
fi
- name: Bump version
if: ${{ success() }}
run: |
cd build
if [[ "$(git symbolic-ref --short -q HEAD)" == nightly && -f .tmp/bump ]]; then
sudo rm -f .tmp/bump
CURRENT_VERSION=$(cat VERSION)
NEW_VERSION="${CURRENT_VERSION%%-trunk}"
if [[ $CURRENT_VERSION == *trunk* ]]; then
NEW_VERSION=$(echo "${CURRENT_VERSION}" | cut -d. -f1-3)"."$((${NEW_VERSION##*.} + 1))
else
NEW_VERSION=$(echo "${CURRENT_VERSION}" | cut -d. -f1-2)"."$((${NEW_VERSION##*.} + 1))
fi
sudo git checkout -f
sudo chown -R $USER:$USER .
git pull
echo "${NEW_VERSION}" > VERSION
git config --global user.email "info@armbian.com"
git config --global user.name "Armbianworker"
git add VERSION
git commit -m "Bumping to new version" -m "" -m "Adding following kernels:" -m "$(find output/debs-beta/ -type f -name "linux-image*${CURRENT_VERSION}*.deb" -printf "%f\n" | sort)"
git push
fi
- name: Install SSH key for repository
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.KEY_TORRENTS }}
known_hosts: ${{ secrets.KNOWN_HOSTS_UPLOAD }}
if_key_exists: replace
- name: Deploy to server
if: ${{ success() }}
run: |
sudo apt-get -y -qq install lftp
sudo chown -R $USER:$USER $(pwd)/build/output/debs-beta/
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-beta/ debs-beta/ ;bye" sftp://users.armbian.com
edge-stable:
#
# Whenever edge kernel sources, patches or config are changed, we rebuild kernels + BSP and push
# them to https://beta.armbian.com repository.
#
# EDGE kernel sources are most recent mainline based
#
name: Changed stable edge kernels
needs: merge
runs-on: [self-hosted, Linux, x64, 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
[[ "$(df | grep "/.tmp" | wc -l)" -eq 0 ]] && 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
sudo chown -R $USER:$USER .
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: nightly
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_KEY2 }}
passphrase: ${{ secrets.GPG_PASSPHRASE2 }}
workdir: scripts
git-user-signingkey: true
git-commit-gpgsign: true
- name: Build all edge changed kernels for stable repository
run: |
cd build
rm -rf output/debs/*
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
./compile.sh KERNEL_ONLY="yes" BOARD="bananapi" BRANCH="current" KERNEL_CONFIGURE="no" \
REPOSITORY_INSTALL="u-boot,kernel" 'prepare_host'
mkdir -p cache/hash/
sudo rsync -ar --delete ../scripts/hash/. cache/hash/ 2> /dev/null
sudo cp ../scripts/configs/* userpatches/
cat config/targets.conf | grep edge | grep cli | grep hirsute | sudo tee userpatches/targets.conf 1>/dev/null
./compile.sh all-new-stable-kernels
# upgrade only kernel packages
rm -f output/debs/armbian-* 2> /dev/null
rm -f output/debs/linux-libc-* 2> /dev/null
find output/debs -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 sudo rm -R 2> /dev/null
cd ../scripts
sudo git clean -ffdx && git reset --hard HEAD
git config pull.rebase false
cd ../build
sudo rsync -ar --delete cache/hash/. ../scripts/hash/
if [[ $(cat .tmp/n 2> /dev/null) -ne 0 ]]; then
cd ../scripts
if git status --porcelain | grep .; then
git pull
git add .
git commit -m "Update hashes for stable repository"
git push
fi
fi
- 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 to server
if: ${{ success() }}
run: |
sudo apt-get -y -qq install lftp
sudo chown -R $USER:$USER $(pwd)/build/output/debs-beta/
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:
#
# Rebuild package repository
#
name: Update package repository
needs: [beta-kernels, edge-stable]
runs-on: [self-hosted, Linux, local]
if: ${{ github.repository_owner == 'Armbian' }}
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 }}
torrents:
#
# Rebuilt torrent files for rootfs cache
#
name: Update download infrastructure
needs: [cache]
runs-on: [self-hosted, Linux, local]
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- name: Install SSH key for torrent
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.KEY_TORRENTS }}
name: id_torrent # optional
known_hosts: ${{ secrets.KNOWN_HOSTS_TORRENTS }}
if_key_exists: replace
- name: Create torrents
run: ssh -T -i ~/.ssh/id_torrent ${{ secrets.USER_TORRENTS }}@${{ secrets.HOST_TORRENTS }}
finish:
name: Finish
needs: [repository, edge-stable, torrents]
runs-on: [self-hosted, Linux]
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- name: Run script
run: |
echo "Finish"