Skip to content

build-one

build-one #88

Workflow file for this run

name: build-one
on:
workflow_dispatch:
inputs:
platform:
description: 'Platform to build (e.g. hi3516cv100_lite)'
required: true
commit:
description: 'Commit SHA to build (optional; defaults to current branch HEAD). Use this from `git bisect run` or for one-off historic rebuilds.'
required: false
jobs:
resolve:
name: Resolve commit
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.r.outputs.ref }}
short_sha: ${{ steps.r.outputs.short_sha }}
tag_name: ${{ steps.r.outputs.tag_name }}
steps:
- id: r
run: |
REF="${{ inputs.commit }}"
[ -z "$REF" ] && REF="${{ github.sha }}"
SHORT="$(printf '%s' "$REF" | cut -c1-7)"
if [ -n "${{ inputs.commit }}" ]; then
TAG="nightly-bisect-${SHORT}"
else
TAG="nightly-bisect-${SHORT}-$(date -u +%Y%m%d%H%M%S)"
fi
echo "ref=$REF" >> "$GITHUB_OUTPUT"
echo "short_sha=$SHORT" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG" >> "$GITHUB_OUTPUT"
echo "Building ${{ inputs.platform }} at $REF -> release tag $TAG"
buildroot:
name: Firmware (${{inputs.platform}})
needs: resolve
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
ref: ${{ needs.resolve.outputs.ref }}
- name: Prepare firmware
run: |
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
echo CACHE_DATE=$(date +%m) >> ${GITHUB_ENV}
- name: Setup ccache
uses: actions/cache@v4
with:
path: /tmp/ccache
key: ${{inputs.platform}}-${{env.CACHE_DATE}}
- name: Setup dl cache
uses: actions/cache@v4
with:
path: output/dl
key: dl-${{env.CACHE_DATE}}
restore-keys: dl-
- name: Build firmware
env:
BUILD_ID: ${{ needs.resolve.outputs.tag_name }}
BUILD_SHA: ${{ needs.resolve.outputs.ref }}
run: |
export GIT_HASH=$(git rev-parse --short ${GITHUB_SHA})
export GIT_BRANCH=${GITHUB_REF_NAME}
echo GIT_HASH=${GIT_HASH} >> ${GITHUB_ENV}
echo GIT_BRANCH=${GIT_BRANCH} >> ${GITHUB_ENV}
mkdir -p /tmp/ccache
ln -s /tmp/ccache ${HOME}/.ccache
backoffs="30 60 120 300 600 1200"
attempt=1
for sleep_for in $backoffs ""; do
make BOARD=${{inputs.platform}} && break
if [ -z "$sleep_for" ]; then
echo "::error::build failed after ${attempt} attempts"
exit 1
fi
echo "::warning::attempt ${attempt} failed, retrying after ${sleep_for}s"
sleep "$sleep_for"
attempt=$((attempt + 1))
done
TIME=$(date -d @${SECONDS} +%M:%S)
echo TIME=${TIME} >> ${GITHUB_ENV}
NORFW=$(find output/images -name openipc*nor*)
if [ -e ${NORFW} ]; then
echo NORFW=${NORFW} >> ${GITHUB_ENV}
fi
NANDFW=$(find output/images -name openipc*nand*)
if [ -e ${NANDFW} ]; then
echo NANDFW=${NANDFW} >> ${GITHUB_ENV}
fi
- name: Verify kernel modules
run: sh .github/scripts/check_target_modules.sh
- name: Upload firmware
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.resolve.outputs.tag_name }}
prerelease: true
body: |
sha=${{ needs.resolve.outputs.ref }}
short=${{ needs.resolve.outputs.short_sha }}
platform=${{ inputs.platform }}
one_off=true
files: |
${{env.NORFW}}
${{env.NANDFW}}