toolchain #7
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: toolchain | |
on: | |
schedule: | |
# 00:15 PST / Sunday | |
- cron: '15 08 * * 0' | |
workflow_dispatch: | |
env: | |
TAG_NAME: toolchain | |
TERM: linux | |
BR2_DL_DIR: /tmp/dl | |
TG_TOKEN: ${{secrets.TELEGRAM_TOKEN_BOT_THINGINO}} | |
TG_CHANNEL: ${{secrets.TELEGRAM_CHANNEL_THINGINO_BUILD}} | |
TG_OPTIONS: -s -o /dev/null -w %{http_code} | |
TG_ENABLE: true | |
jobs: | |
notify-begin: | |
runs-on: ubuntu-latest | |
outputs: | |
start_time: ${{ steps.set_output.outputs.time }} | |
steps: | |
- name: Save workflow start time | |
id: set_output | |
run: echo "time=$(date +%s)" >> $GITHUB_OUTPUT | |
- name: Send build start notifcation | |
if: env.TG_ENABLE== 'true' | |
run: | | |
TG_MSG="Toolchain build started:\nJob: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n\n" | |
TG_ICON="\xF0\x9F\x9A\xA6 GitHub Actions" | |
TG_HEADER=$(echo -e ${TG_MSG}${TG_ICON}) | |
HTTP=$(curl ${TG_OPTIONS} -H "Content-Type: multipart/form-data" -X POST https://api.telegram.org/bot${TG_TOKEN}/sendMessage -F parse_mode=MarkdownV2 -F chat_id=${TG_CHANNEL} -F text="${TG_HEADER}" -F disable_web_page_preview=true) | |
echo Telegram response: ${HTTP} | |
build-toolchain: | |
name: ${{ matrix.toolchain-version }} | |
needs: notify-begin | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain-version: | |
- toolchain_xburst1_musl_gcc13 | |
- toolchain_xburst1_musl_gcc12 | |
- toolchain_xburst2_musl_gcc13 | |
- toolchain_xburst2_musl_gcc12 | |
- toolchain_xburst1_gnu_gcc13 | |
- toolchain_xburst1_gnu_gcc12 | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
- name: Setup Environment | |
id: date | |
run: | | |
echo "WEEK_NUMBER=$(date +%U)" >> $GITHUB_ENV | |
echo "CURRENT_YEAR=$(date +%Y)" >> $GITHUB_ENV | |
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} | |
- name: Setup cache directories | |
run: | | |
mkdir -p /tmp/ccache | |
mkdir -p /tmp/dl | |
ln -s /tmp/ccache ${HOME}/.ccache | |
ln -s /tmp/dl ${HOME}/dl | |
- name: Setup ccache | |
uses: actions/cache@v4 | |
if: always() | |
with: | |
path: /tmp/ccache | |
key: ${{ runner.os }}-ccache-${{ matrix.toolchain-version }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-ccache-${{ matrix.toolchain-version }}- | |
- name: Setup buildroot download directory cache | |
uses: actions/cache@v4 | |
if: always() | |
with: | |
path: /tmp/dl | |
key: ${{ runner.os }}-dl-shared-v1-${{ env.CURRENT_YEAR }}-week-${{ env.WEEK_NUMBER }} | |
restore-keys: | | |
${{ runner.os }}-dl-shared-v1-${{ env.CURRENT_YEAR }}-week- | |
- name: Setup repo sources for GCC13 | |
run: | | |
sudo echo "deb http://archive.ubuntu.com/ubuntu/ lunar main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list | |
sudo tee -a /etc/apt/preferences.d/prefer-jammy <<EOF | |
Package: * | |
Pin: release a=jammy | |
Pin-Priority: 500 | |
Package: * | |
Pin: release a=lunar | |
Pin-Priority: 100 | |
EOF | |
- name: Update system sources | |
run: | | |
sudo apt-get update | |
- name: Install build dependencies | |
run: | | |
sudo apt-get install -y --no-install-recommends --no-install-suggests build-essential bc bison cpio curl file flex git libncurses-dev make rsync unzip wget whiptail gcc gcc-mipsel-linux-gnu lzop u-boot-tools ca-certificates ccache | |
- name: Install GCC13 dependencies | |
run: | | |
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests libc6=2.37-0ubuntu2 libc-bin=2.37-0ubuntu2 libc6-mipsel-cross=2.37-0ubuntu1cross1 libc6-dev=2.37-0ubuntu2 libc-dev-bin=2.37-0ubuntu2 coreutils=9.1-1ubuntu2 libgmp10=2:6.2.1+dfsg1-1.1ubuntu1 | |
- name: Build toolchain | |
run: | | |
BOARD=${{ matrix.toolchain-version }} make sdk | |
TIME=$(date -d @${SECONDS} +%M:%S) | |
echo "TIME=${TIME}" >> ${GITHUB_ENV} | |
- name: Rename toolchain package for release | |
run: | | |
INGTC=$(find ${HOME}/output/${{ matrix.toolchain-version }}*/images/ -name "mipsel-thingino-linux-*_sdk-buildroot.tar.gz" | head -n 1) | |
if [[ -n "$INGTC" ]]; then | |
DIR_PATH=$(dirname "$INGTC") | |
INGTC_FINAL="${DIR_PATH}/thingino-${{ matrix.toolchain-version }}-linux-mipsel.tar.gz" | |
mv "$INGTC" "$INGTC_FINAL" | |
echo "INGTC=$INGTC_FINAL" >> $GITHUB_ENV | |
else | |
echo "Matching file not found." | |
exit 1 | |
fi | |
- name: Upload toolchain as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: thingino-${{ matrix.toolchain-version }}-linux-mipsel.tar.gz | |
path: ${{ env.INGTC }} | |
- name: Upload toolchain | |
if: github.event_name != 'pull_request' | |
uses: softprops/action-gh-release@master | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
files: ${{ env.INGTC }} | |
- name: Send completion notification with job link | |
if: github.event_name != 'pull_request' && env.INGTC && env.TG_ENABLE== 'true' | |
run: | | |
TG_ESCAPED_VERSION=$(echo "${{ matrix.toolchain-version }}" | sed 's/_/\\_/g') | |
TG_MSG="${TG_ESCAPED_VERSION}\nCommit: [${GIT_HASH}](https://github.com/${GITHUB_REPOSITORY}/commit/${GIT_HASH})\nBranch: [${GIT_BRANCH}](https://github.com/${GITHUB_REPOSITORY}/tree/${GIT_BRANCH})\nTag: [${TAG_NAME}](https://github.com/${GITHUB_REPOSITORY}/releases/tag/${TAG_NAME})\nTime: ${TIME}\nJob: [${{ github.run_id }}](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }})\n\n" | |
TG_ICON="\xE2\x9C\x85 GitHub Actions" | |
TG_HEADER=$(echo -e "${TG_MSG}${TG_ICON}") | |
HTTP=$(curl ${TG_OPTIONS} -H "Content-Type: multipart/form-data" -X POST https://api.telegram.org/bot${TG_TOKEN}/sendMessage -F parse_mode=MarkdownV2 -F chat_id=${TG_CHANNEL} -F text="${TG_HEADER}" -F disable_web_page_preview=true) | |
echo Telegram response: ${HTTP} | |
- name: Send error notification | |
if: github.event_name != 'pull_request' && failure() | |
run: | | |
TG_ESCAPED_VERSION=$(echo "${{ matrix.toolchain-version }}" | sed 's/_/\\_/g') | |
TG_WARN="Error: ${TG_ESCAPED_VERSION}\n" | |
TG_MSG="Commit: [${GIT_HASH}](https://github.com/${GITHUB_REPOSITORY}/commit/${GIT_HASH})\nBranch: [${GIT_BRANCH}](https://github.com/${GITHUB_REPOSITORY}/tree/${GIT_BRANCH})\nTag: [${TAG_NAME}](https://github.com/${GITHUB_REPOSITORY}/releases/tag/${TAG_NAME})\nJob: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n\n" | |
TG_ICON="\xE2\x9A\xA0 GitHub Actions" | |
TG_HEADER=$(echo -e ${TG_WARN}${TG_MSG}${TG_ICON}) | |
HTTP=$(curl ${TG_OPTIONS} -H "Content-Type: multipart/form-data" -X POST https://api.telegram.org/bot${TG_TOKEN}/sendMessage -F parse_mode=MarkdownV2 -F chat_id=${TG_CHANNEL} -F text="${TG_HEADER}" -F disable_web_page_preview=true) | |
echo Telegram response: ${HTTP} | |
notify-completion: | |
needs: [build-toolchain, notify-begin] | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Send completion summary | |
if: env.TG_ENABLE == 'true' | |
run: | | |
START_TIME=${{ needs.notify-begin.outputs.start_time }} | |
END_TIME=$(date -u +%s) | |
ELAPSED=$((END_TIME - START_TIME)) | |
ELAPSED_MIN=$((ELAPSED / 60)) | |
ELAPSED_SEC=$((ELAPSED % 60)) | |
TG_MSG="Toolchain build completed:\nTotal build time: ${ELAPSED_MIN}m ${ELAPSED_SEC}s\nJob: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n\n" | |
TG_ICON="\xF0\x9F\x9A\xA9 GitHub Actions" | |
TG_HEADER=$(echo -e ${TG_MSG}${TG_ICON}) | |
HTTP=$(curl ${TG_OPTIONS} -H "Content-Type: multipart/form-data" -X POST https://api.telegram.org/bot${TG_TOKEN}/sendMessage -F parse_mode=MarkdownV2 -F chat_id=${TG_CHANNEL} -F text="${TG_HEADER}" -F disable_web_page_preview=true) | |
echo Telegram response: ${HTTP} |