Files
scripts/.github/workflows/build-desktop.yml
2022-11-16 07:26:16 +01:00

239 lines
7.7 KiB
YAML

name: Build desktops
on:
workflow_dispatch:
workflow_call:
inputs:
uploading:
type: string
runner:
required: true
type: string
reference:
required: false
type: string
packagesrepo:
required: false
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
- run: |
REFERENCE=${{ inputs.reference }}
echo "REFERENCE=${REFERENCE:-"nightly"}" >> $GITHUB_ENV
PACKAGESREPO=${{ inputs.packagesrepo }}
echo "BETA=${PACKAGESREPO:-yes}" >> $GITHUB_ENV
- name: Checkout Armbian build script
uses: actions/checkout@v3.1.0
with:
repository: armbian/build
path: build
ref: ${{ env.REFERENCE }}
fetch-depth: '100'
clean: false
- name: Checkout support scripts
uses: actions/checkout@v3.1.0
with:
fetch-depth: '100'
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@v3.0.1
with:
name: changes
- name: Build desktops
id: list_dirs
run: |
MATRIX=$(
set +e
releases=($(find build/config/distributions -mindepth 1 -maxdepth 1 -type d | sed 's/.*\///' ))
for i in ${releases[@]}
do
environments=($([[ -d build/config/desktop/$i/environments ]] && ls -1 build/config/desktop/$i/environments))
for j in ${environments[@]}
do
echo "$i:$j"
done
done)
# don't build if there are no changes in kernels
[ -s changes ] || unset MATRIX
echo "matrix=$(for x in $(echo "${MATRIX}"); do echo $x; done|jq -cnR '[inputs | select(length>0)]' | jq -c)" >> $GITHUB_OUTPUT
Desktop:
needs: [ Prepare ]
runs-on: ${{ inputs.runner }}
if: ${{ needs.Prepare.outputs.matrix != '[]' && needs.Prepare.outputs.matrix != '' }}
timeout-minutes: 480
strategy:
max-parallel: 16
fail-fast: false
matrix:
node: ${{fromJson(needs.Prepare.outputs.matrix)}}
steps:
- uses: igorpecovnik/freespace@main
- run: |
REFERENCE=${{ inputs.reference }}
echo "REFERENCE=${REFERENCE:-"nightly"}" >> $GITHUB_ENV
PACKAGESREPO=${{ inputs.packagesrepo }}
echo "BETA=${PACKAGESREPO:-yes}" >> $GITHUB_ENV
- name: Checkout Armbian build script
uses: actions/checkout@v3.1.0
with:
repository: armbian/build
path: build
fetch-depth: '100'
ref: ${{ env.REFERENCE }}
clean: false
- name: Checkout support scripts
uses: actions/checkout@v3.1.0
with:
fetch-depth: '100'
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: 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 update
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 -o allow_other || true
sudo sshfs upload@users.armbian.com:/debs build/output/debs -o IdentityFile=~/.ssh/id_rsa -o reconnect -o nonempty,allow_other || true
sudo sshfs upload@users.armbian.com:/debs-beta build/output/debs-beta -o IdentityFile=~/.ssh/id_rsa -o reconnect -o allow_other || true
sudo sshfs upload@users.armbian.com:/debs-beta build/output/debs-beta -o IdentityFile=~/.ssh/id_rsa -o reconnect -o nonempty,allow_other || true
####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.io
sudo docker kill $(sudo docker ps -q) 2>/dev/null || true
sudo docker image rm $(sudo docker images | grep -v latest"-$(dpkg --print-architecture)" | awk 'NR>1 {print $3}') 2> /dev/null || true
sudo docker pull ghcr.io/armbian/build:latest"-$(dpkg --print-architecture)"
- name: Build
run: |
sudo mkdir -p build/userpatches
sudo cp scripts/configs/* build/userpatches/
cd build
CHUNK="${{ matrix.node }}"
RELEASE=$(echo $CHUNK | cut -d":" -f1)
DE=$(echo $CHUNK | cut -d":" -f2)
echo "RELEASE=${RELEASE}" >> $GITHUB_ENV
echo "DE=${DE}" >> $GITHUB_ENV
sudo sed -i "s/-it --rm/-i --rm/" userpatches/config-docker.conf
./compile.sh docker \
BSP_BUILD="yes" \
BETA="${{ env.BETA }}" \
RELEASE="${RELEASE}" \
DESKTOP_ENVIRONMENT_CONFIG_NAME="config_base" \
BUILD_DESKTOP="yes" \
CLEAN_LEVEL="make,oldcache" \
DESKTOP_ENVIRONMENT="${DE}" \
KERNEL_ONLY="yes" \
KERNEL_CONFIGURE="no" \
COMPRESS_OUTPUTIMAGE="no" \
BOARD="uefi-x86" \
USE_MAINLINE_GOOGLE_MIRROR="yes" \
BRANCH="current" \
SKIP_EXTERNAL_TOOLCHAINS="yes" \
OFFLINE_WORK="yes" \
REPOSITORY_INSTALL="u-boot,kernel,armbian-config,armbian-firmware" \
DESKTOP_APPGROUPS_SELECTED="" \
EXPERT="yes"
if [[ $? -eq 0 ]]; then
echo "UPLOAD=true" >> $GITHUB_ENV
sudo find output/debs-beta/${RELEASE}/. -type f -name 'armbian-bsp*' -print0 | sudo xargs -0 -I {} rm {} || true
fi
- name: Upload build artifacts
if: ${{ inputs.uploading == true }}
uses: actions/upload-artifact@v3
with:
name: armbian-${{ env.RELEASE }}-desktop-${{ env.DE }}
path: build/output/debs-beta/${{ env.RELEASE }}/armbian-${{ env.RELEASE }}-desktop-${{ env.DE }}_*.deb
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