mirror of
https://github.com/MiyooCFW/buildroot.git
synced 2025-09-27 22:24:19 +03:00
GENIMAGE/ACTIONS: automate CFW release tag & status ver. (#94)
* [GENIMAGE] automate CFW release tag & status ver. - shell formatting - add CFW_ITERATION count for Dev-build - separate CFW and BR2 tagging - don't use $BR2_VERSION_FULL * [ACTIONS] build.yml: - allow for manual workflow dispatch - fetch-depth=0 (can't fetch-tags) - rm commented line - cleanup - append `ref_name` for unofficials
This commit is contained in:
39
.github/workflows/build.yml
vendored
39
.github/workflows/build.yml
vendored
@@ -2,6 +2,7 @@ name: Buildroot
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
submodule:
|
||||
@@ -26,8 +27,10 @@ jobs:
|
||||
remove-docker-images: true
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- if: inputs.submodule
|
||||
run: git submodule update --init --depth 1 -- ${{ inputs.submodule }}
|
||||
run: git submodule update --init -- ${{ inputs.submodule }}
|
||||
|
||||
- name: retrieve ccache
|
||||
uses: actions/cache@v3
|
||||
@@ -37,22 +40,27 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ inputs.submodule }}-uclibc-ccache-
|
||||
|
||||
- name: generate cfw hash
|
||||
- name: generate cfw hash & iteration count
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/buildroot/buildroot
|
||||
echo "cfwsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "cfw_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
if test $(git tag | wc -l) -ne 0; then \
|
||||
echo "cfw_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT; \
|
||||
echo "cfw_iteration=$(git rev-list --count $(git describe --tags --abbrev=0)..HEAD)" >> $GITHUB_OUTPUT; \
|
||||
fi
|
||||
id: cfwsha
|
||||
|
||||
- name: build
|
||||
run: |
|
||||
cd ${{ inputs.submodule || '.' }}
|
||||
#apt update && apt install -y wget unzip build-essential git bc swig libncurses-dev libpython3-dev libssl-dev cpio rsync subversion
|
||||
sudo apt update && sudo apt install -y gsfonts
|
||||
make miyoo_uclibc_defconfig
|
||||
CPU_N=$(getconf _NPROCESSORS_ONLN)
|
||||
set -o pipefail
|
||||
if ! ( \
|
||||
make -j $CPU_N sdk CFW_HASH="${{ steps.cfwsha.outputs.cfwsha }}" APPEND_VERSION="-Dev_build" 2>&1 \
|
||||
make -j $CPU_N sdk \
|
||||
CFW_HASH="${{ steps.cfwsha.outputs.cfw_sha }}" CFW_TAG="${{ steps.cfwsha.outputs.cfw_tag }}" CFW_ITERATION="${{ steps.cfwsha.outputs.cfw_iteration }}" \
|
||||
APPEND_VERSION="-Dev_build$(echo ${{ github.ref_name != 'master' && github.ref_name || '' }} | sed 's/\//-/g' | sed '/./ s/^/-/')" 2>&1 \
|
||||
| tee build.log \
|
||||
| grep ">>>" \
|
||||
); then tail -n100 build.log && exit 1
|
||||
@@ -74,7 +82,7 @@ jobs:
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build image (uClibc)
|
||||
path: ${{ inputs.submodule || '.' }}/output/images/miyoo-cfw-*.img
|
||||
path: ${{ inputs.submodule || '.' }}/output/images/miyoo-*.img
|
||||
if-no-files-found: error # 'error', 'warn', 'ignore'; defaults to `warn`
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
@@ -111,8 +119,10 @@ jobs:
|
||||
remove-docker-images: true
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- if: inputs.submodule
|
||||
run: git submodule update --init --depth 1 -- ${{ inputs.submodule }}
|
||||
run: git submodule update --init -- ${{ inputs.submodule }}
|
||||
|
||||
- name: retrieve ccache
|
||||
uses: actions/cache@v3
|
||||
@@ -122,22 +132,27 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ inputs.submodule }}-musl-ccache-
|
||||
|
||||
- name: generate cfw hash
|
||||
- name: generate cfw hash & iteration count
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/buildroot/buildroot
|
||||
echo "cfwsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "cfw_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
if test $(git tag | wc -l) -ne 0; then \
|
||||
echo "cfw_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT; \
|
||||
echo "cfw_iteration=$(git rev-list --count $(git describe --tags --abbrev=0)..HEAD)" >> $GITHUB_OUTPUT; \
|
||||
fi
|
||||
id: cfwsha
|
||||
|
||||
- name: build
|
||||
run: |
|
||||
cd ${{ inputs.submodule || '.' }}
|
||||
#apt update && apt install -y wget unzip build-essential git bc swig libncurses-dev libpython3-dev libssl-dev cpio rsync subversion
|
||||
sudo apt update && sudo apt install -y gsfonts
|
||||
make miyoo_musl_defconfig
|
||||
CPU_N=$(getconf _NPROCESSORS_ONLN)
|
||||
set -o pipefail
|
||||
if ! ( \
|
||||
make -j $CPU_N sdk CFW_HASH="${{ steps.cfwsha.outputs.cfwsha }}" APPEND_VERSION="-Dev_build" 2>&1 \
|
||||
make -j $CPU_N sdk \
|
||||
CFW_HASH="${{ steps.cfwsha.outputs.cfw_sha }}" CFW_TAG="${{ steps.cfwsha.outputs.cfw_tag }}" CFW_ITERATION="${{ steps.cfwsha.outputs.cfw_iteration }}" \
|
||||
APPEND_VERSION="-Dev_build$(echo ${{ github.ref_name != 'master' && github.ref_name || '' }} | sed 's/\//-/g' | sed '/./ s/^/-/')" 2>&1 \
|
||||
| tee build.log \
|
||||
| grep ">>>" \
|
||||
); then tail -n100 build.log && exit 1
|
||||
@@ -159,7 +174,7 @@ jobs:
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build image (musl)
|
||||
path: ${{ inputs.submodule || '.' }}/output/images/miyoo-cfw-*.img
|
||||
path: ${{ inputs.submodule || '.' }}/output/images/miyoo-*.img
|
||||
if-no-files-found: error # 'error', 'warn', 'ignore'; defaults to `warn`
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
|
||||
@@ -5,7 +5,7 @@ Opensource development package for Miyoo handhelds
|
||||
|
||||
### Install necessary packages
|
||||
``` shell
|
||||
sudo apt install -y wget unzip build-essential git bc swig libncurses-dev libpython3-dev libssl-dev cpio rsync subversion python3
|
||||
sudo apt install -y wget unzip build-essential git bc swig libncurses-dev libpython3-dev libssl-dev cpio rsync subversion python3 mercurial imagemagick btrfs-progs
|
||||
```
|
||||
|
||||
### Download BSP
|
||||
|
||||
@@ -1,18 +1,65 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
CFW_RELEASE="2.0.0"
|
||||
STATUS="BETAv2"
|
||||
|
||||
BR2_VENDOR=${2}
|
||||
BR2_VERSION_FULL=${3}
|
||||
LIBC=${4}
|
||||
export IMAGE_NAME="${BR2_VENDOR}-cfw-${CFW_RELEASE}${BR2_VERSION_FULL}_${LIBC}-${STATUS}${APPEND_VERSION}.img"
|
||||
STARTDIR=`pwd`
|
||||
SELFDIR=`dirname \`realpath ${0}\``
|
||||
STARTDIR=$(pwd)
|
||||
SELFDIR=$(dirname $(realpath ${0}))
|
||||
|
||||
# Generate CFW release tag, status and append iteration count
|
||||
if test $(git tag | wc -l) -ne 0; then
|
||||
BR2_TAG="$(git describe --tags --abbrev=0)"
|
||||
BR2_ITERATION="$(git rev-list --count ${BR2_TAG}..HEAD)"
|
||||
fi
|
||||
|
||||
BR2_HASH="$(git rev-parse --short HEAD)" # not using print-version from BR2_VERSION_FULL
|
||||
if (test "$CFW_HASH" == "$BR2_HASH" || test -z "$CFW_HASH"); then
|
||||
CFW_TYPE="br2_dist"
|
||||
CFW_HASH="$BR2_HASH"
|
||||
CFW_VERSION="BR2=${BR2_HASH}"
|
||||
GIT_TAG="$BR2_TAG"
|
||||
ITERATION_VERSION="$BR2_ITERATION"
|
||||
else
|
||||
CFW_TYPE="cfw"
|
||||
CFW_VERSION="CFW=${CFW_HASH}"
|
||||
GIT_TAG="$CFW_TAG"
|
||||
ITERATION_VERSION="$CFW_ITERATION"
|
||||
fi
|
||||
|
||||
if test -n "$GIT_TAG"; then
|
||||
CFW_RELEASE="$(echo ${GIT_TAG} | sed 's/-.*//')"
|
||||
STATUS="$(echo ${GIT_TAG} | sed 's/^[^-]*-//' | tr '[:lower:]' '[:upper:]' | tr '-' 'v')"
|
||||
if test $ITERATION_VERSION -eq 0; then
|
||||
APPEND_VERSION=""
|
||||
if test "$STATUS" == "$CFW_RELEASE"; then STATUS="STABLE"; fi
|
||||
else
|
||||
if [[ "$(echo ${STATUS} | sed 's/^[^-]*v//')" =~ ^-?[0-9]+$ ]]; then
|
||||
APPEND_VERSION="v$(echo ${STATUS} | sed 's/^[^-]*v//' | expr $(cat -) + 1)${APPEND_VERSION}"
|
||||
STATUS="$(echo ${STATUS} | sed 's/v.*//')"
|
||||
elif test -n "$STATUS" ; then
|
||||
STATUS="${STATUS}v2"
|
||||
fi
|
||||
if test "$STATUS" == "$CFW_RELEASE"; then
|
||||
STATUS="BETA"
|
||||
CFW_RELEASE="$(echo ${CFW_RELEASE} | sed 's/[0-9]$//')$(echo ${CFW_RELEASE} | grep -oE '[0-9]+$' | expr $(cat -) + 1)"
|
||||
fi
|
||||
APPEND_VERSION="${APPEND_VERSION}-n${ITERATION_VERSION}"
|
||||
fi
|
||||
else
|
||||
CFW_RELEASE="0.0.0"
|
||||
STATUS="UNKNOWN"
|
||||
fi
|
||||
|
||||
export IMAGE_NAME="${BR2_VENDOR}-${CFW_TYPE}-${CFW_RELEASE}-${CFW_HASH}_${LIBC}-${STATUS}${APPEND_VERSION}.img"
|
||||
|
||||
# Relocate board files for genimage-sdcard config to read (see last cmd)
|
||||
cp -r board/miyoo/boot "${BINARIES_DIR}"
|
||||
cp -r board/miyoo/main "${BINARIES_DIR}"
|
||||
|
||||
# Write CFW version to splash image
|
||||
convert board/miyoo/miyoo-splash.png -pointsize 12 -fill white -annotate +10+230 "v${CFW_RELEASE} ${CFW_VERSION} (${LIBC}) ${STATUS}${APPEND_VERSION}" -type Palette -colors 224 -depth 8 -compress none -verbose BMP3:"${BINARIES_DIR}"/boot/miyoo-splash.bmp
|
||||
|
||||
# Workaround for build apss and configs being placed in /usr/ after img generation (as we use MAIN)
|
||||
test -d "${BINARIES_DIR}/gmenu2x" && cp -r "${BINARIES_DIR}/gmenu2x/" "${BINARIES_DIR}/main/"
|
||||
test -d "${BINARIES_DIR}/emus" && cp -r "${BINARIES_DIR}/emus/" "${BINARIES_DIR}/main/"
|
||||
@@ -37,17 +84,6 @@ if test -d "${BINARIES_DIR}/retroarch";then
|
||||
done
|
||||
fi
|
||||
|
||||
# BR2 Version is tracked by git
|
||||
BR2_HASH=$(echo $BR2_VERSION_FULL | sed 's/^[-]g//')
|
||||
if (test "$CFW_HASH" == "$BR2_HASH" || test -z "$CFW_HASH"); then
|
||||
CFW_VERSION="BR2=${BR2_HASH}"
|
||||
else
|
||||
CFW_VERSION="CFW=${CFW_HASH}"
|
||||
fi
|
||||
|
||||
# Write CFW version to splash image
|
||||
convert board/miyoo/miyoo-splash.png -pointsize 12 -fill white -annotate +10+230 "v${CFW_RELEASE} ${CFW_VERSION} (${LIBC}) ${STATUS}${APPEND_VERSION}" -type Palette -colors 224 -depth 8 -compress none -verbose BMP3:"${BINARIES_DIR}"/boot/miyoo-splash.bmp
|
||||
|
||||
# Generate MAIN BTRFS partition
|
||||
image="${BINARIES_DIR}/main.img"
|
||||
label="MAIN"
|
||||
|
||||
Reference in New Issue
Block a user