Skip to content

Build AGL

Build AGL #106

Workflow file for this run

name: Build AGL
on:
release:
types:
- created
workflow_dispatch:
inputs:
hash:
description: 'SDK Commit'
required: true
default: ''
comment:
description: 'Comment'
required: false
default: ''
env:
REPO: nugu-linux
REPOSLUG: nugu-developers/nugu-linux
#
# Jobs
# -> build (matrix)
# - Generate .tgz
# - Upload to Github release
#
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target: [ koi_rpi4, koi_x64 ]
steps:
- name: Get SHA and ID from Release ${{ github.ref }}
run: |
if [ -z "${{ github.event.inputs.hash }}" ]; then
# Remove "refs/tags/" from "refs/tags/xxxxxxx"
SHORTSHA=$(echo ${GITHUB_REF} | cut -c11-)
else
SHORTSHA=${{ github.event.inputs.hash }}
fi
echo "SHA: $SHORTSHA"
# Get ID for Release-tag
ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -X GET https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${SHORTSHA} | jq '.id' -r)
echo "> Release ID = ${ID}"
if [[ ${ID} == "null" ]]; then
echo "Release ${ID} not exist."
exit
fi
echo "Release-ID: $ID"
echo "id=$ID" >> $GITHUB_ENV
echo "sha=$SHORTSHA" >> $GITHUB_ENV
- name: Check for duplicated files
run: |
COUNT=0
MATCH_COUNT=1
RESULT=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -X GET https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ env.id }}/assets?per_page=80)
FILES=$(echo $RESULT | jq '.[].name' -r)
for item in $FILES
do
echo "Check artifacts - $item"
if [[ $item == *"agl"* ]]; then
:
else
continue;
fi
declare -i COUNT; COUNT+=1
echo "> Found build artifacts: [${COUNT}/${MATCH_COUNT}] ${item}"
done
# Mark to flag file to trigger the build
if [[ $COUNT == $MATCH_COUNT ]]; then
echo "> There is no need to rebuild."
echo "exist=1" >> $GITHUB_ENV
else
echo "> Rebuild required"
echo "exist=0" >> $GITHUB_ENV
fi
- name: The build artifact already exists, so the build is skipped.
if: ${{ env.exist == '1'}}
run: echo "Done"
- name: Prepare SDK source
if: ${{ env.exist == '0'}}
run: |
git clone https://github.com/${REPOSLUG} --recursive
cd ${REPO}
git checkout ${{ env.sha }}
git reset --hard
rm -rf .git
# Fix permissions for docker
chmod 777 $PWD
ls -l
- name: Prepare AGL Docker image
if: ${{ env.exist == '0'}}
run: docker pull ghcr.io/webispy/agl:${{ matrix.target }}
- name: Build
if: ${{ env.exist == '0'}}
run: |
cd ${REPO}
cat <<EOF > sdkbuild.sh
#!/bin/bash
set -e
source /opt/agl-sdk/11.0.*/environment-setup-*
rm -rf build
mkdir build
cd build
cmake .. -DENABLE_BUILTIN_OPUS=ON \
-DENABLE_PORTAUDIO_PLUGIN=OFF \
-DENABLE_ASAN=OFF \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_TOOLCHAIN_FILE=/opt/toolchain/Toolchain.cmake
make -j6
mkdir SDK
DESTDIR=SDK make install
tar cvfz files_agl_${{ matrix.target }}_${{ env.sha }}.tgz SDK
EOF
chmod 755 sdkbuild.sh
echo "> Build cross-compile"
docker run -t --rm -v $PWD:$PWD -w $PWD \
ghcr.io/webispy/agl:${{ matrix.target }} ./sdkbuild.sh
cp build/files_*.tgz /tmp/
- name: Upload
if: ${{ env.exist == '0'}}
uses: svenstaro/upload-release-action@v2
with:
file: /tmp/*.tgz
file_glob: true
repo_token: ${{ secrets.GH_TOKEN }}
overwrite: true
tag: ${{ github.ref }}