forked from sbwml/r4s_build_script
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
509 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
name: Build Self release | ||
|
||
on: | ||
workflow_dispatch: | ||
# schedule: | ||
# - cron: 0 20 * * * | ||
|
||
jobs: | ||
build: | ||
name: Build ${{ matrix.model }}-${{ matrix.tag.version }} | ||
runs-on: ubuntu-24.04 | ||
defaults: | ||
run: | ||
shell: bash | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
model: | ||
- armv8 | ||
- x86_64 | ||
tag: | ||
- type: rc2 | ||
version: openwrt-24.10 | ||
|
||
steps: | ||
- name: Checkout | ||
continue-on-error: true | ||
uses: actions/checkout@main | ||
with: | ||
path: r4s_build_script | ||
|
||
- name: Setup variables | ||
run: | | ||
sudo timedatectl set-timezone 'Asia/Shanghai' | ||
git config --global user.name 'actions' | ||
git config --global user.email '[email protected]' | ||
echo build_dir="/builder" >> "$GITHUB_ENV" | ||
- name: Show system | ||
run: | | ||
echo -e "\n\e[1;32mCPU:\e[0m" | ||
echo "$(grep 'model name' /proc/cpuinfo | head -1 | awk -F ': ' '{print $2}') ($(grep 'cpu MHz' /proc/cpuinfo | head -1 | awk -F ': ' '{print $2}')MHz) x $(grep processor /proc/cpuinfo | wc -l)" | ||
echo -e "\n\e[1;32mMemory:\e[0m" | ||
free -h | ||
echo -e "\n\e[1;32mStorage:\e[0m" | ||
df -Th / /mnt | ||
echo -e "\n\e[1;32mSystem:\e[0m" | ||
lsb_release -a | ||
echo -e "\n\e[1;32mKernel:\e[0m" | ||
uname -a | ||
echo | ||
- name: Install Caddy Server | ||
run: | | ||
sudo curl -sL -o /usr/bin/caddy https://github.com/sbwml/r4s_build_script/releases/download/caddy/caddy | ||
sudo chmod 755 /usr/bin/caddy | ||
echo ":8080 {" > caddyfile | ||
echo " root * $(pwd)/r4s_build_script" >> caddyfile | ||
echo " file_server browse" >> caddyfile | ||
echo "}" >> caddyfile | ||
sudo /usr/bin/caddy start --config caddyfile --adapter caddyfile | ||
- name: Free disk space | ||
uses: sbwml/actions@free-disk | ||
with: | ||
build-mount-path: /builder | ||
|
||
- name: Build System Setup | ||
uses: sbwml/actions@openwrt-build-setup | ||
|
||
- name: Install LLVM | ||
uses: sbwml/actions@install-llvm | ||
|
||
- name: Restore Cached | ||
#if: ${{ matrix.model != 'armv8' }} | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: /builder/.ccache | ||
key: ${{ matrix.tag.version }}-${{ matrix.model }}-ccache | ||
|
||
- name: Restore Cached (releases) | ||
if: ${{ matrix.model == 'armv8-test' }} | ||
continue-on-error: true | ||
working-directory: /builder | ||
run: | | ||
curl -s https://api.github.com/repos/${{ github.repository }}/releases | grep 'browser_download_url' | grep ccache | grep armv8 | awk -F '"' '{print $4}' | grep -v '^$' | xargs -n 1 wget -q | ||
cat armv8.tar.* | tar -xf - || true | ||
rm -rf armv8.tar.* || true | ||
[ -d .ccache ] && cache_size=$(du -sb .ccache | awk '{print $1}') || cache_size=0 | ||
cache_size_mb=$(echo "scale=0; ${cache_size} / (1024 * 1024)" | bc) | ||
echo "Cache Size: ~${cache_size_mb} MB (${cache_size} B)" | ||
echo "Cache restored successfully" | ||
echo "Cache restored from key: ${{ matrix.model }}" | ||
- name: Compile OpenWrt | ||
working-directory: /builder | ||
id: compile | ||
continue-on-error: true | ||
run: | | ||
export BUILD_FAST=y ENABLE_BPF=y ENABLE_LTO=y ENABLE_LRNG=y ENABLE_MOLD=y KERNEL_CLANG_LTO=y LAN=10.0.0.1 USE_GCC15=y ENABLE_CCACHE=y | ||
bash <(curl -sS http://127.0.0.1:8080/build.sh) ${{ matrix.tag.type }} ${{ matrix.model }} | ||
cd openwrt | ||
tags=$(git describe --abbrev=0 --tags) | ||
echo "latest_release=$tags" >>$GITHUB_ENV | ||
- name: Extensive logs after a failed compilation | ||
if: steps.compile.outcome == 'failure' | ||
working-directory: /builder | ||
run: | | ||
cd openwrt | ||
make V=s IGNORE_ERRORS="n m" | ||
- name: Delete Cached | ||
#if: ${{ matrix.model != 'armv8' }} | ||
continue-on-error: true | ||
working-directory: /builder | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_REPO: ${{ github.repository }} | ||
run: | | ||
gh cache delete ${{ matrix.tag.version }}-${{ matrix.model }}-ccache || true | ||
- name: Save Cached | ||
#if: ${{ matrix.model != 'armv8' }} | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: /builder/.ccache | ||
key: ${{ matrix.tag.version }}-${{ matrix.model }}-ccache | ||
|
||
- name: Create Ccache tar files | ||
if: ${{ matrix.model == 'armv8-test' }} | ||
continue-on-error: true | ||
working-directory: /builder | ||
run: | | ||
mkdir -p ccache | ||
tar cf - .ccache | split -d -b 1800m - ccache/${{ matrix.model }}.tar. | ||
- name: Save Cached (releases) | ||
if: ${{ matrix.model == 'armv8-test' }} | ||
continue-on-error: true | ||
uses: ncipollo/[email protected] | ||
with: | ||
name: ccache | ||
allowUpdates: true | ||
tag: ccache | ||
commit: master | ||
replacesArtifacts: true | ||
prerelease: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
artifacts: | | ||
${{ env.build_dir }}/ccache/* | ||
- name: Assemble Artifact | ||
working-directory: /builder | ||
run: | | ||
mkdir -p rom info | ||
if [ "${{ matrix.model }}" = "x86_64" ]; then | ||
cp -a openwrt/bin/targets/x86/*/*-ext4-combined-efi.img.gz rom/ | ||
cp -a openwrt/bin/targets/x86/*/*-squashfs-combined-efi.img.gz rom/ | ||
cp -a openwrt/bin/targets/x86/*/*-generic-rootfs.tar.gz rom/ | ||
cp -a openwrt/bin/targets/x86/*/*-x86-64-generic.manifest info/manifest.txt | ||
cp -a openwrt/bin/targets/x86/*/config.buildinfo info/config.buildinfo | ||
cd rom && sha256sum *gz > ../info/sha256sums.txt | ||
elif [ "${{ matrix.model }}" = "armv8" ]; then | ||
tar zcf rom/u-boot-qemu_armv8.tar.gz -C openwrt/bin/targets/armsr/armv8*/ ./u-boot-qemu_armv8 | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-initramfs-kernel.bin rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-kernel.bin rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-ext4-combined-efi.img.gz rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-squashfs-combined-efi.img.gz rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-rootfs.tar.gz rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*.manifest info/manifest.txt | ||
cp -a openwrt/bin/targets/armsr/armv8*/config.buildinfo info/config.buildinfo | ||
cd rom && sha256sum * > ../info/sha256sums.txt | ||
fi | ||
echo current_hour="$(date +'%H')" >> "$GITHUB_ENV" | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.build_date }}-${{ matrix.model }}-${{ matrix.tag.version }} | ||
path: ${{ env.build_dir }}/rom/*.* | ||
|
||
|
||
- name: Create release | ||
continue-on-error: true | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
name: ${{ env.latest_release }} | ||
allowUpdates: true | ||
tag: ${{ env.latest_release }} | ||
commit: master | ||
replacesArtifacts: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
artifacts: ${{ env.build_dir }}/rom/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
name: Build Snapshot | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: 0 20 * * * | ||
|
||
jobs: | ||
build: | ||
name: Build ${{ matrix.model }}-${{ matrix.tag.version }} | ||
runs-on: ubuntu-24.04 | ||
defaults: | ||
run: | ||
shell: bash | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
model: | ||
- armv8 | ||
- x86_64 | ||
tag: | ||
- type: dev | ||
version: openwrt-24.10 | ||
|
||
steps: | ||
- name: Checkout | ||
continue-on-error: true | ||
uses: actions/checkout@main | ||
with: | ||
path: r4s_build_script | ||
|
||
- name: Setup variables | ||
run: | | ||
sudo timedatectl set-timezone 'Asia/Shanghai' | ||
git config --global user.name 'actions' | ||
git config --global user.email '[email protected]' | ||
echo build_dir="/builder" >> "$GITHUB_ENV" | ||
- name: Show system | ||
run: | | ||
echo -e "\n\e[1;32mCPU:\e[0m" | ||
echo "$(grep 'model name' /proc/cpuinfo | head -1 | awk -F ': ' '{print $2}') ($(grep 'cpu MHz' /proc/cpuinfo | head -1 | awk -F ': ' '{print $2}')MHz) x $(grep processor /proc/cpuinfo | wc -l)" | ||
echo -e "\n\e[1;32mMemory:\e[0m" | ||
free -h | ||
echo -e "\n\e[1;32mStorage:\e[0m" | ||
df -Th / /mnt | ||
echo -e "\n\e[1;32mSystem:\e[0m" | ||
lsb_release -a | ||
echo -e "\n\e[1;32mKernel:\e[0m" | ||
uname -a | ||
echo | ||
- name: Install Caddy Server | ||
run: | | ||
sudo curl -sL -o /usr/bin/caddy https://github.com/sbwml/r4s_build_script/releases/download/caddy/caddy | ||
sudo chmod 755 /usr/bin/caddy | ||
echo ":8080 {" > caddyfile | ||
echo " root * $(pwd)/r4s_build_script" >> caddyfile | ||
echo " file_server browse" >> caddyfile | ||
echo "}" >> caddyfile | ||
sudo /usr/bin/caddy start --config caddyfile --adapter caddyfile | ||
- name: Free disk space | ||
uses: sbwml/actions@free-disk | ||
with: | ||
build-mount-path: /builder | ||
|
||
- name: Build System Setup | ||
uses: sbwml/actions@openwrt-build-setup | ||
|
||
- name: Install LLVM | ||
uses: sbwml/actions@install-llvm | ||
|
||
- name: Restore Cached | ||
#if: ${{ matrix.model != 'armv8' }} | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: /builder/.ccache | ||
key: ${{ matrix.tag.version }}-${{ matrix.model }}-ccache | ||
|
||
- name: Restore Cached (releases) | ||
if: ${{ matrix.model == 'armv8-test' }} | ||
continue-on-error: true | ||
working-directory: /builder | ||
run: | | ||
curl -s https://api.github.com/repos/${{ github.repository }}/releases | grep 'browser_download_url' | grep ccache | grep armv8 | awk -F '"' '{print $4}' | grep -v '^$' | xargs -n 1 wget -q | ||
cat armv8.tar.* | tar -xf - || true | ||
rm -rf armv8.tar.* || true | ||
[ -d .ccache ] && cache_size=$(du -sb .ccache | awk '{print $1}') || cache_size=0 | ||
cache_size_mb=$(echo "scale=0; ${cache_size} / (1024 * 1024)" | bc) | ||
echo "Cache Size: ~${cache_size_mb} MB (${cache_size} B)" | ||
echo "Cache restored successfully" | ||
echo "Cache restored from key: ${{ matrix.model }}" | ||
- name: Compile OpenWrt | ||
working-directory: /builder | ||
id: compile | ||
continue-on-error: true | ||
run: | | ||
export BUILD_FAST=y ENABLE_BPF=y ENABLE_LTO=y ENABLE_LRNG=y ENABLE_MOLD=y KERNEL_CLANG_LTO=y LAN=10.0.0.1 USE_GCC15=y ENABLE_CCACHE=y | ||
bash <(curl -sS http://127.0.0.1:8080/build.sh) ${{ matrix.tag.type }} ${{ matrix.model }} | ||
cd openwrt | ||
tags=snapshot-24.10-$(git log -n 1 --date=format:"%Y%m%d" --format="%cd")-$(git log --pretty=format:"%h" -1) | ||
echo "latest_release=$tags" >>$GITHUB_ENV | ||
build_date=$(date "+%Y-%m-%d") | ||
echo "build_date=$build_date" >> $GITHUB_ENV | ||
- name: Extensive logs after a failed compilation | ||
if: steps.compile.outcome == 'failure' | ||
working-directory: /builder | ||
run: | | ||
cd openwrt | ||
make V=s IGNORE_ERRORS="n m" | ||
- name: Delete Cached | ||
#if: ${{ matrix.model != 'armv8' }} | ||
continue-on-error: true | ||
working-directory: /builder | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_REPO: ${{ github.repository }} | ||
run: | | ||
gh cache delete ${{ matrix.tag.version }}-${{ matrix.model }}-ccache || true | ||
- name: Save Cached | ||
#if: ${{ matrix.model != 'armv8' }} | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: /builder/.ccache | ||
key: ${{ matrix.tag.version }}-${{ matrix.model }}-ccache | ||
|
||
- name: Create Ccache tar files | ||
if: ${{ matrix.model == 'armv8-test' }} | ||
continue-on-error: true | ||
working-directory: /builder | ||
run: | | ||
mkdir -p ccache | ||
tar cf - .ccache | split -d -b 1800m - ccache/${{ matrix.model }}.tar. | ||
- name: Save Cached (releases) | ||
if: ${{ matrix.model == 'armv8-test' }} | ||
continue-on-error: true | ||
uses: ncipollo/[email protected] | ||
with: | ||
name: ccache | ||
allowUpdates: true | ||
tag: ccache | ||
commit: master | ||
replacesArtifacts: true | ||
prerelease: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
artifacts: | | ||
${{ env.build_dir }}/ccache/* | ||
- name: Assemble Artifact | ||
working-directory: /builder | ||
run: | | ||
mkdir -p rom info | ||
if [ "${{ matrix.model }}" = "x86_64" ]; then | ||
cp -a openwrt/bin/targets/x86/*/*-ext4-combined-efi.img.gz rom/ | ||
cp -a openwrt/bin/targets/x86/*/*-squashfs-combined-efi.img.gz rom/ | ||
cp -a openwrt/bin/targets/x86/*/*-generic-rootfs.tar.gz rom/ | ||
cp -a openwrt/bin/targets/x86/*/*-x86-64-generic.manifest info/manifest.txt | ||
cp -a openwrt/bin/targets/x86/*/config.buildinfo info/config.buildinfo | ||
cd rom && sha256sum *gz > ../info/sha256sums.txt | ||
elif [ "${{ matrix.model }}" = "armv8" ]; then | ||
tar zcf rom/u-boot-qemu_armv8.tar.gz -C openwrt/bin/targets/armsr/armv8*/ ./u-boot-qemu_armv8 | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-initramfs-kernel.bin rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-kernel.bin rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-ext4-combined-efi.img.gz rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-squashfs-combined-efi.img.gz rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*-rootfs.tar.gz rom/ | ||
cp -a openwrt/bin/targets/armsr/armv8*/*.manifest info/manifest.txt | ||
cp -a openwrt/bin/targets/armsr/armv8*/config.buildinfo info/config.buildinfo | ||
cd rom && sha256sum * > ../info/sha256sums.txt | ||
fi | ||
echo current_hour="$(date +'%H')" >> "$GITHUB_ENV" | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.build_date }}-${{ matrix.model }}-${{ matrix.tag.version }} | ||
path: ${{ env.build_dir }}/rom/*.* | ||
|
||
|
||
- name: Create release | ||
continue-on-error: true | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
name: ${{ env.latest_release }} | ||
allowUpdates: true | ||
tag: ${{ env.latest_release }} | ||
commit: master | ||
replacesArtifacts: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
artifacts: ${{ env.build_dir }}/rom/* | ||
prerelease: true |
Oops, something went wrong.