Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gtxaspec committed Feb 20, 2024
1 parent 196467a commit d90ef3e
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OUTPUT_DIR="./uboot_build"
DEBUG_MODE=0 # Flag to indicate whether debug mode is active

# Start timer
SECONDS=0
SECONDS_ELAPSED=0

# Function to build a specific version with possible debug mode
build_version() {
Expand Down Expand Up @@ -93,7 +93,7 @@ else
fi

# End timer and report
duration=$SECONDS
duration=$SECONDS_ELAPSED
echo "Done"
echo "Total build time: $(($duration / 60)) minutes and $(($duration % 60)) seconds."
exit 0
139 changes: 88 additions & 51 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,81 +8,118 @@ on:

env:
TAG_NAME: latest
TERM: linux
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: false

jobs:
build-notify:
runs-on: ubuntu-latest
steps:
- name: Send build alert
if: env.TG_ENABLE== 'true'
shell: bash
run: |
TG_MSG="u-boot-ingenic build started\nhttps://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\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 chat_id=${TG_CHANNEL} -F text="${TG_HEADER}" -F disable_web_page_preview=true)
echo Telegram response: ${HTTP}
build:
needs: build-notify
runs-on: ubuntu-latest
container: debian:sid
container:
image: debian:sid
strategy:
fail-fast: false
matrix:
u-boot-version:
- t10n
- t10l
- t10n_msc0
- t20n
- t20l
- t20x
- t20n_msc0
- t21n
- t21n_msc0
- t23n
- t23n_msc0
- t30n
- t30l
- t30x
- t30a
- t30a1
- t30n_msc0
- t31n
- t31l
- t31lc
- t31x
- t31a
- t31al
- t31l_msc0
- t31n_msc0
- t31x_msc0
- t31a_msc0
- t31al_msc0

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup ccache
uses: actions/cache@v4
if: always()
with:
path: /tmp/ccache
key: ${{ runner.os }}-ccache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-ccache-$-
- name: Install dependencies
- name: Update repo sources
run: |
apt-get update
apt-get install -y --no-install-recommends --no-install-suggests build-essential gcc-13 gcc-13-mipsel-linux-gnu lzop u-boot-tools git make ca-certificates
- name: Install dependencies
run: |
apt-get install -y --no-install-recommends --no-install-suggests build-essential gcc-13 gcc-13-mipsel-linux-gnu lzop u-boot-tools git make ca-certificates curl
CROSS_COMPILE=mipsel-linux-gnu-; VER=${1:-13}; for app in cpp gcc gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool lto-dump; do if update-alternatives --query ${CROSS_COMPILE}${app} >/dev/null; then update-alternatives --set ${CROSS_COMPILE}${app} /usr/bin/${CROSS_COMPILE}${app}-${VER}; else update-alternatives --install /usr/bin/${CROSS_COMPILE}${app} ${CROSS_COMPILE}${app} /usr/bin/${CROSS_COMPILE}${app}-${VER} 1; fi; done; echo "Done"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout
uses: actions/checkout@v4

- name: u-boot-ingenic Build
shell: bash
run: |
git clone https://github.com/gtxaspec/u-boot-ingenic.git --depth 1
cd u-boot-ingenic
echo "HASH IS"
git rev-parse --short ${GITHUB_SHA}
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
cp -f .github/scripts/build.sh build-ci.sh
VERSION=${{ matrix.u-boot-version }}
bash build-ci.sh $VERSION debug
- name: Check if file exists
id: check-file
TIME=$(date -d @${SECONDS} +%M:%S)
echo "TIME=${TIME}" >> ${GITHUB_ENV}
- name: Check if compiled u-boot exists
run: |
FILE=$(find . -type f -name "u-boot-${{ matrix.u-boot-version }}.bin")
if [ -z "$FILE" ]; then
echo "::error::File u-boot-${{ matrix.u-boot-version }}.bin does not exist."
echo "FILE_FOUND=false" >> $GITHUB_ENV
exit 1
else
echo "Found file: $FILE"
echo "FILE_FOUND=true" >> $GITHUB_ENV
FILE=./uboot_build/u-boot-${{ matrix.u-boot-version }}.bin
if [ ! -f "$FILE" ]; then
echo "File not found exit"
exit 1
fi
shell: bash --noprofile --norc -e -o pipefail {0}
env:
TAG_NAME: ${{ env.TAG_NAME }}
echo "Found file: $FILE"
echo "UBOOTFW=$FILE" >> $GITHUB_ENV
- name: Upload ${{ matrix.u-boot-version }}
if: env.FILE_FOUND == 'true'
uses: softprops/action-gh-release@v1
if: github.event_name != 'pull_request'
uses: softprops/action-gh-release@master
with:
tag_name: ${{ env.TAG_NAME }}
files: |
./u-boot-ingenic/uboot_build/u-boot-${{ matrix.u-boot-version }}.bin
files: ${{ env.UBOOTFW }}

- name: Send build alert
if: github.event_name != 'pull_request' && env.UBOOTFW && env.TG_ENABLE== 'true'
shell: bash
run: |
echo "GIT_HASH: ${GIT_HASH}"
echo "GIT_BRANCH: ${GIT_BRANCH}"
TG_MSG="u-boot-ingenic build finished\nCommit: ${GIT_HASH}\nBranch: ${GIT_BRANCH}\nTag: ${TAG_NAME}\nTime: ${TIME}\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 chat_id=${TG_CHANNEL} -F text="${TG_HEADER}" -F disable_web_page_preview=true)
echo Telegram response: ${HTTP}
- name: Send error
if: github.event_name != 'pull_request' && failure()
shell: bash
run: |
TG_WARN="Error: u-boot-ingenic build failed!\n"
TG_MSG="Commit: ${GIT_HASH}\nBranch: ${GIT_BRANCH}\nTag: ${TAG_NAME}\nhttps://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 chat_id=${TG_CHANNEL} -F text="${TG_HEADER}" -F disable_web_page_preview=true)
echo Telegram response: ${HTTP}

0 comments on commit d90ef3e

Please sign in to comment.