06461db #315
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Ubuntu | |
on: | |
release: | |
types: | |
- created | |
env: | |
REPO: nugu-linux | |
REPOSLUG: nugu-developers/nugu-linux | |
# | |
# Jobs | |
# check | |
# -> build (matrix) | |
# - Generate DEB package and .tgz | |
# - Upload to Github release | |
# -> pages | |
# - Doxygen | |
# - DEB Repository | |
# - Upload to Github pages | |
# -> docker | |
# - Generate nugulinux/sdk:unstable docker image | |
# | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
outputs: | |
release_id: ${{ steps.check.outputs.id }} | |
sha: ${{ steps.check.outputs.sha }} | |
steps: | |
- name: Get SHA and ID from Release ${{ github.ref }} | |
id: check | |
run: | | |
# Remove "refs/tags/" from "refs/tags/xxxxxxx" | |
SHORTSHA=$(echo ${GITHUB_REF} | cut -c11-) | |
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_OUTPUT | |
echo "sha=$SHORTSHA" >> $GITHUB_OUTPUT | |
build: | |
runs-on: ubuntu-latest | |
needs: check | |
strategy: | |
fail-fast: true | |
matrix: | |
target: | |
[ | |
bionic_x64, | |
bionic_arm64, | |
bionic_armhf, | |
focal_x64, | |
focal_arm64, | |
focal_armhf, | |
jammy_x64, | |
jammy_arm64, | |
jammy_armhf, | |
] | |
steps: | |
- name: Setup | |
run: | | |
UBUNTU_VER=$(echo ${{ matrix.target }} | cut -d "_" -f 1) | |
ARCH=$(echo ${{ matrix.target }} | cut -d "_" -f 2) | |
if [ "$ARCH" == "x64" ]; then | |
ARCH2="amd64" | |
else | |
ARCH2="${ARCH}" | |
fi | |
echo "ubuntuver=$UBUNTU_VER" >> $GITHUB_ENV | |
echo "arch=$ARCH" >> $GITHUB_ENV | |
echo "arch2=$ARCH2" >> $GITHUB_ENV | |
echo "id=${{ needs.check.outputs.release_id }}" >> $GITHUB_ENV | |
echo "sha=${{ needs.check.outputs.sha }}" >> $GITHUB_ENV | |
- name: Check for duplicated files | |
run: | | |
COUNT=0 | |
MATCH_COUNT=6 | |
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" | |
# Check ARCH or ARCH2 | |
if [[ $item == *"${{ env.arch }}"* ]]; then | |
: | |
elif [[ $item == *"${{ env.arch2 }}"* ]]; then | |
: | |
else | |
continue; | |
fi | |
# Check Ubuntu version (jammy / focal / bionic) | |
if [[ $item == *"${{ env.ubuntuver }}"* ]]; 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: Start Ubuntu build | |
if: ${{ env.exist == '0'}} | |
run: | | |
# Get date for commit to generate version | |
DATETIME=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -X GET https://api.github.com/repos/${REPOSLUG}/commits/${{ env.sha }} | jq '.commit.committer.date' -r) | |
echo "commit.committer.date = ${DATETIME}" | |
STAMP=$(date -d ${DATETIME} +%Y%m%d) | |
VERSION="${STAMP}${{ env.sha }}" | |
echo "package version = ${VERSION}" | |
echo "Clone the sdk repository" | |
git clone https://github.com/${REPOSLUG} --recursive | |
cd ${REPO} | |
git checkout ${{ env.sha }} | |
git reset --hard | |
rm -rf .git | |
echo "Add commit-id(${{ env.sha }}) to package version" | |
sed -i "1 s/ubuntu[0-9]*~bionic/ubuntu${VERSION}~bionic/" packaging/bionic/changelog | |
sed -i "1 s/ubuntu[0-9]*~focal/ubuntu${VERSION}~focal/" packaging/focal/changelog | |
sed -i "1 s/ubuntu[0-9]*~jammy/ubuntu${VERSION}~jammy/" packaging/jammy/changelog | |
head -1 packaging/bionic/changelog | |
head -1 packaging/focal/changelog | |
head -1 packaging/jammy/changelog | |
cd - | |
# Fix permissions for docker | |
chmod 777 $PWD | |
chmod 777 $PWD/${REPO} | |
echo "Build debian package" | |
docker run -t --rm --privileged -v $PWD:$PWD -w $PWD/${REPO} \ | |
-v /var/lib/schroot/chroots \ | |
nugulinux/buildenv:${{ matrix.target }} sdkbuild.sh | |
ls -l | |
echo "Create /tmp/result" | |
mkdir /tmp/result | |
cp *.deb /tmp/result/ | |
echo "Completed" | |
echo "files=1" >> $GITHUB_ENV | |
- name: Generate tgz | |
if: ${{ env.files == '1'}} | |
run: | | |
FILENAME=files_${{ matrix.target }}_${{ env.sha }} | |
# Create temporary directory | |
mkdir dest | |
# Extract all deb packages | |
FILES=$(ls *.deb) | |
for item in $FILES | |
do | |
echo "Extract ${item}" | |
ar x ${item} | |
if [ -f data.tar.xz ]; then | |
tar -C dest -xvf data.tar.xz | |
rm data.tar.xz | |
elif [ -f data.tar.zst ]; then | |
tar -C dest -xvf data.tar.zst | |
rm data.tar.zst | |
fi | |
done | |
# Generate tgz | |
cd dest | |
tar cvfz ../${FILENAME}.tgz . | |
cd - | |
cp ${FILENAME}.tgz /tmp/result/ | |
- name: Upload artifact to release | |
if: ${{ env.files == '1'}} | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
file: /tmp/result/* | |
file_glob: true | |
repo_token: ${{ secrets.GH_TOKEN }} | |
overwrite: true | |
tag: ${{ github.ref }} | |
pages: | |
runs-on: ubuntu-latest | |
needs: [check, build] | |
env: | |
BASEROOT: /tmp/www | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Setup | |
id: setup | |
run: | | |
sudo apt-get install doxygen graphviz | |
POOL_BIONIC=${BASEROOT}/ubuntu/dists/bionic/pool | |
POOL_FOCAL=${BASEROOT}/ubuntu/dists/focal/pool | |
POOL_JAMMY=${BASEROOT}/ubuntu/dists/jammy/pool | |
DIRS=( | |
${POOL_BIONIC} | |
${POOL_JAMMY} | |
${BASEROOT}/ubuntu/dists/bionic/main/binary-amd64 | |
${BASEROOT}/ubuntu/dists/bionic/main/binary-arm64 | |
${BASEROOT}/ubuntu/dists/bionic/main/binary-armhf | |
${BASEROOT}/ubuntu/dists/focal/main/binary-amd64 | |
${BASEROOT}/ubuntu/dists/focal/main/binary-arm64 | |
${BASEROOT}/ubuntu/dists/focal/main/binary-armhf | |
${BASEROOT}/ubuntu/dists/jammy/main/binary-amd64 | |
${BASEROOT}/ubuntu/dists/jammy/main/binary-arm64 | |
${BASEROOT}/ubuntu/dists/jammy/main/binary-armhf | |
) | |
for item in "${DIRS[@]}" | |
do | |
echo "- Create ${item}" | |
if [[ ! -d ${item} ]]; then | |
mkdir -p ${item} | |
fi | |
done | |
# Generate index.html | |
DATE=$(date) | |
cat <<EOF > ${BASEROOT}/index.html | |
<html> | |
<body> | |
<h1>DEB Package repository for unstable release</h1> | |
<p> | |
last unstable commit: <a href="https://github.com/nugu-developers/nugu-linux/commit/${{ env.sha }}">${{ env.sha }}</a> | |
</p> | |
<p> | |
API Document(doxygen): <a href="https://nugulinux.github.io/sdk-unstable/doxygen/">https://nugulinux.github.io/sdk-unstable/doxygen/</a> | |
</p> | |
<hr/> | |
<h2>NUGU SDK for Linux PPA Setup (stable release)</h2> | |
<pre> | |
add-apt-repository ppa:nugulinux/sdk | |
apt-get update | |
</pre> | |
<hr/> | |
<h2>Unstable package repository setup</h2> | |
<h3>Jammy (22.04)</h3> | |
<pre> | |
echo "deb [trusted=yes] https://nugulinux.github.io/sdk-unstable/ubuntu/ jammy main" > /etc/apt/sources.list.d/nugudev.list | |
apt-get update | |
</pre> | |
<h3>Focal (20.04)</h3> | |
<pre> | |
echo "deb [trusted=yes] https://nugulinux.github.io/sdk-unstable/ubuntu/ focal main" > /etc/apt/sources.list.d/nugudev.list | |
apt-get update | |
</pre> | |
<h3>Bionic (18.04)</h3> | |
<pre> | |
echo "deb [trusted=yes] https://nugulinux.github.io/sdk-unstable/ubuntu/ bionic main" > /etc/apt/sources.list.d/nugudev.list | |
apt-get update | |
</pre> | |
<hr/> | |
<p>Generated at ${DATE}</p> | |
</body> | |
</html> | |
EOF | |
echo "id=${{ needs.check.outputs.release_id }}" >> $GITHUB_ENV | |
echo "sha=${{ needs.check.outputs.sha }}" >> $GITHUB_ENV | |
echo "pool_bionic=${POOL_BIONIC}" >> $GITHUB_ENV | |
echo "pool_focal=${POOL_FOCAL}" >> $GITHUB_ENV | |
echo "pool_jammy=${POOL_JAMMY}" >> $GITHUB_ENV | |
- name: Generate doxygen | |
run: | | |
git clone https://github.com/${REPOSLUG} | |
cd ${REPO} | |
git checkout ${{ env.sha }} | |
git reset --hard | |
rm -rf .git | |
doxygen | |
mv doc/html ${BASEROOT}/doxygen | |
cd .. | |
rm -rf ${REPO} | |
- name: Generate unstable DEB repository | |
run: | | |
function generate { | |
DIST=$1 | |
HOST=$2 | |
PKGSREPO="dists/${DIST}/pool" | |
PKGS="dists/${DIST}/main/binary-${HOST}/" | |
echo "> DEB Repo: ${PKGSREPO}" | |
echo "> Packages path: ${PKGS}" | |
cd ${BASEROOT}/ubuntu | |
dpkg-scanpackages -m -a $HOST ${PKGSREPO} > ${PKGS}/Packages | |
cd - | |
} | |
echo "> Get file list" | |
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 '.[].browser_download_url' -r) | |
for item in $FILES | |
do | |
if [[ $item != *.deb ]]; then | |
echo "- ignore: ${item}" | |
continue | |
fi | |
echo "Download ${item}" | |
if [[ $item == *"bionic"* ]]; then | |
echo "- 18.04: ${item}" | |
wget -nv ${item} -P ${{ env.pool_bionic }} | |
if [[ $item == *"amd64"* ]]; then | |
generate "bionic" "amd64" | |
elif [[ $item == *"armhf"* ]]; then | |
generate "bionic" "armhf" | |
elif [[ $item == *"arm64"* ]]; then | |
generate "bionic" "arm64" | |
fi | |
elif [[ $item == *"focal"* ]]; then | |
echo "- 20.04: ${item}" | |
wget -nv ${item} -P ${{ env.pool_focal }} | |
if [[ $item == *"amd64"* ]]; then | |
generate "focal" "amd64" | |
elif [[ $item == *"armhf"* ]]; then | |
generate "focal" "armhf" | |
elif [[ $item == *"arm64"* ]]; then | |
generate "focal" "arm64" | |
fi | |
elif [[ $item == *"jammy"* ]]; then | |
echo "- 20.04: ${item}" | |
wget -nv ${item} -P ${{ env.pool_jammy }} | |
if [[ $item == *"amd64"* ]]; then | |
generate "jammy" "amd64" | |
elif [[ $item == *"armhf"* ]]; then | |
generate "jammy" "armhf" | |
elif [[ $item == *"arm64"* ]]; then | |
generate "jammy" "arm64" | |
fi | |
else | |
echo "- unknown version: ${item}" | |
fi | |
done | |
- name: Deploy to Github Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
branch: gh-pages | |
folder: /tmp/www | |
clean: true | |
single-commit: true |