Created
November 14, 2024 22:58
-
-
Save JucaRei/3b9ed62aa5997357746736cd02854267 to your computer and use it in GitHub Desktop.
testing
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: Custom-Friendlywrt | |
on: push | |
# watch: | |
# types: started | |
jobs: | |
prepare_release: | |
runs-on: ubuntu-20.04 | |
if: github.event.repository.owner.id == github.event.sender.id | |
steps: | |
- name: Get release tag | |
id: release_tag | |
run: | | |
release_tag="friendlyWrt-$(date +%Y-%m-%d)" | |
echo "##[set-output name=release_tag;]$release_tag" | |
- name: Create empty release | |
id: release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.release_tag.outputs.release_tag }} | |
draft: false | |
prerelease: false | |
outputs: | |
release_tag: ${{ steps.release_tag.outputs.release_tag }} | |
upload_url: ${{ steps.release.outputs.upload_url }} | |
build_friendlywrt_and_kernel: | |
needs: prepare_release | |
runs-on: ubuntu-20.04 | |
if: github.event.repository.owner.id == github.event.sender.id | |
strategy: | |
matrix: | |
VERSION: [21.02, 23.05] | |
SET: [docker, non-docker] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d | |
wget https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh | |
sed -i -e 's/^apt-get -y install openjdk-8-jdk/# apt-get -y install openjdk-8-jdk/g' install.sh | |
sed -i -e 's/^\[ -d fa-toolchain \]/# [ -d fa-toolchain ]/g' install.sh | |
sed -i -e 's/^(cat fa-toolchain/# (cat fa-toolchain/g' install.sh | |
sed -i -e 's/^(tar xf fa-toolchain/# (tar xf fa-toolchain/g' install.sh | |
sudo -E bash ./install.sh | |
sudo -E update-alternatives --install $(which python) python /usr/bin/python2.7 20 | |
sudo -E git config --global user.name 'GitHub Actions' | |
sudo -E git config --global user.email '[email protected]' | |
git clone https://github.com/friendlyarm/repo | |
sudo -E cp repo/repo /usr/bin/ | |
mkdir -p ./artifact | |
sudo swapoff -a | |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android/sdk /usr/local/share/boost /opt/ghc | |
echo "cores: $(nproc)" | |
- name: Download source | |
run: | | |
mkdir project | |
cd project | |
repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \ | |
-m rk3566.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle | |
repo sync -c friendlywrt --no-clone-bundle | |
repo sync -c configs --no-clone-bundle | |
repo sync -c device/common --no-clone-bundle | |
repo sync -c device/friendlyelec --no-clone-bundle | |
repo sync -c scripts --no-clone-bundle | |
repo sync -c scripts/sd-fuse --no-clone-bundle | |
repo sync -c toolchain --no-clone-bundle | |
- name: Apply customizations | |
run: | | |
cd project | |
source ../scripts/add_packages.sh | |
source ../scripts/custome_config.sh | |
- name: Prepare dot config and feeds | |
run: | | |
cd project | |
[ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker" | |
DIRNAME=friendlywrt$(echo ${{ matrix.VERSION }}|awk -F . '{print $1}')${SUFFIX} | |
CONFIG=rockchip${SUFFIX} | |
cat > .current_config.mk <<EOL | |
. device/friendlyelec/rk3566/base.mk | |
TARGET_IMAGE_DIRNAME=${DIRNAME} | |
TARGET_FRIENDLYWRT_CONFIG=${CONFIG} | |
EOL | |
DEBUG_DOT_CONFIG=1 ./build.sh friendlywrt | |
- name: Download package | |
run: | | |
cd project/friendlywrt | |
wget https://gist.githubusercontent.com/JucaRei/4a258c69898f21157fccb47705607e90/raw/806f702c1620e66c9b65a0b6808c5a2a7581e160/.config | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Compile friendlyWrt | |
id: compile | |
continue-on-error: true | |
run: | | |
cd project/friendlywrt | |
make -j$(nproc) || make -j1 V=s | |
echo $? | |
- name: Check the result and try again | |
if: steps.compile.outcome == 'failure' | |
run: | | |
cd project/friendlywrt | |
make -j1 V=s | |
- name: Create rootfs package | |
id: create_rootfs_package | |
run: | | |
cd project | |
source .current_config.mk | |
[ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker" | |
rootfs_filename="rootfs-friendlywrt-${{ matrix.VERSION }}${SUFFIX}.tgz" | |
tar cvzf ../artifact/${rootfs_filename} ${FRIENDLYWRT_SRC}/${FRIENDLYWRT_ROOTFS} \ | |
${FRIENDLYWRT_SRC}/${FRIENDLYWRT_PACKAGE_DIR} | |
echo "##[set-output name=rootfs_filename;]$rootfs_filename" | |
- name: Upload rootfs package | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./artifact/${{ steps.create_rootfs_package.outputs.rootfs_filename }} | |
asset_name: ${{ steps.create_rootfs_package.outputs.rootfs_filename }} | |
tag: ${{ needs.prepare_release.outputs.release_tag }} | |
overwrite: true | |
build_img: | |
needs: [prepare_release,build_friendlywrt_and_kernel] | |
runs-on: ubuntu-20.04 | |
if: github.event.repository.owner.id == github.event.sender.id | |
strategy: | |
matrix: | |
VERSION: [21.02, 23.05] | |
CPU: [ rk3566 ] | |
SET: [docker, non-docker] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d | |
wget https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh | |
sed -i -e 's/^apt-get -y install openjdk-8-jdk/# apt-get -y install openjdk-8-jdk/g' install.sh | |
sed -i -e 's/^\[ -d fa-toolchain \]/# [ -d fa-toolchain ]/g' install.sh | |
sed -i -e 's/^(cat fa-toolchain/# (cat fa-toolchain/g' install.sh | |
sed -i -e 's/^(tar xf fa-toolchain/# (tar xf fa-toolchain/g' install.sh | |
sudo -E bash ./install.sh | |
sudo -E update-alternatives --install $(which python) python /usr/bin/python2.7 20 | |
sudo -E git config --global user.name 'GitHub Actions' | |
sudo -E git config --global user.email '[email protected]' | |
git clone https://github.com/friendlyarm/repo | |
sudo -E cp repo/repo /usr/bin/ | |
mkdir -p ./artifact | |
sudo swapoff -a | |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android/sdk /usr/local/share/boost /opt/ghc | |
echo "cores: $(nproc)" | |
- name: Download source | |
run: | | |
mkdir project | |
cd project | |
repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \ | |
-m ${{ matrix.CPU }}.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle | |
repo sync -c kernel --no-clone-bundle | |
repo sync -c u-boot --no-clone-bundle | |
repo sync -c rkbin --no-clone-bundle | |
repo sync -c configs --no-clone-bundle | |
repo sync -c device/common --no-clone-bundle | |
repo sync -c device/friendlyelec --no-clone-bundle | |
repo sync -c scripts --no-clone-bundle | |
repo sync -c scripts/sd-fuse --no-clone-bundle | |
repo sync -c toolchain --no-clone-bundle | |
- name: Download friendlywrt rootfs (non-docker) | |
if: matrix.SET == 'non-docker' | |
uses: robinraju/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
repository: ${{ github.repository }} | |
tag: ${{ needs.prepare_release.outputs.release_tag }} | |
fileName: "rootfs-friendlywrt-${{ matrix.VERSION }}.tgz" | |
- name: Download friendlywrt rootfs (docker) | |
if: matrix.SET == 'docker' | |
uses: robinraju/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
repository: ${{ github.repository }} | |
tag: ${{ needs.prepare_release.outputs.release_tag }} | |
fileName: "rootfs-friendlywrt-${{ matrix.VERSION }}-docker.tgz" | |
- name: Prepare config | |
id: config | |
run: | | |
cd project | |
case ${{ matrix.CPU }} in | |
rk3328) | |
MODEL=R2S-R2C-Series | |
;; | |
rk3528) | |
MODEL=NanoPi-Zero2 | |
;; | |
rk3399) | |
MODEL=R4S-Series | |
;; | |
rk3568) | |
MODEL=R5S-R5C-Series | |
;; | |
rk3566) | |
MODEL=R3S-Series | |
;; | |
rk3588) | |
MODEL=T6-R6S-R6C-M6-Series | |
;; | |
*) | |
echo "unknow cpu" | |
exit 1 | |
;; | |
esac | |
[ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker" | |
FILENAME=${MODEL}-friendlyWrt-${{ matrix.VERSION }}${SUFFIX}.img | |
DIRNAME=friendlywrt$(echo ${{ matrix.VERSION }}|awk -F . '{print $1}')${SUFFIX} | |
CONFIG=rockchip${SUFFIX} | |
cat > .current_config.mk <<EOL | |
. device/friendlyelec/${{ matrix.CPU }}/base.mk | |
TARGET_IMAGE_DIRNAME=${DIRNAME} | |
TARGET_FRIENDLYWRT_CONFIG=${CONFIG} | |
TARGET_SD_RAW_FILENAME=${FILENAME} | |
EOL | |
echo "##[set-output name=img_filename;]$FILENAME" | |
- name: Unpack friendlywrt rootfs | |
run: | | |
cd project | |
[ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker" | |
tar xvzf "../rootfs-friendlywrt-${{ matrix.VERSION }}${SUFFIX}.tgz" | |
- name: Compile uboot and kernel | |
run: | | |
cd project | |
./build.sh uboot | |
wget https://gist.githubusercontent.com/JucaRei/4a258c69898f21157fccb47705607e90/raw/3aefa02f9fd1097c458b631d3a15d23c8a6f3b90/.config -P kernel | |
./build.sh kernel | |
- name: Build sd image && Emmc Image | |
id: build_sd_image | |
run: | | |
cd project | |
./build.sh sd-img | |
./build.sh emmc-img | |
mv out/${{ steps.config.outputs.img_filename }} ../artifact/ | |
cd ../artifact/ | |
gzip *.img | |
- name: Build emmc image | |
id: build_emmc_img | |
run: | | |
cd project | |
./build.sh emmc-img | |
cd out | |
for oldname in *eflasher.img; do | |
new_base_name="${{ steps.config.outputs.img_filename }}-emmc" | |
newfilename=$(echo "$oldname" | sed 's/.*eflasher/'"$new_base_name"'/') | |
mv "$oldname" "$newfilename" | |
echo "Arquivo renomeado de $oldname para $newfilename" done | |
cd .. | |
mv out/${{ steps.config.outputs.img_filename }}-emmc ../artifact/ | |
cd ../artifact/ | |
gzip *.img | |
- name: Upload image to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./artifact/${{ steps.config.outputs.img_filename }}.gz | |
asset_name: ${{ steps.config.outputs.img_filename }}.gz | |
tag: ${{ needs.prepare_release.outputs.release_tag }} | |
overwrite: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment