build-cache: make cache useful for builds in forks

This commit is contained in:
John Doe
2021-03-04 14:40:07 +08:00
parent 731ad60806
commit 4177d89443
5 changed files with 36 additions and 19 deletions

View File

@@ -25,7 +25,7 @@ jobs:
sudo sysctl vm.swappiness=0
sudo rm -rf /usr/share/dotnet #/usr/local/lib/android/sdk
sudo -E apt update
sudo -E apt -y --no-upgrade --no-install-recommends install jq zstd secure-delete build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libreadline-dev libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint ccache curl wget vim nano python python3 python-pip python3-pip python-ply python3-ply haveged lrzsz device-tree-compiler scons antlr3 gperf intltool rsync swig &
sudo -E apt -y --no-install-recommends install jq zstd secure-delete build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libreadline-dev libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint ccache curl wget vim nano python python3 python-pip python3-pip python-ply python3-ply haveged lrzsz device-tree-compiler scons antlr3 gperf intltool rsync swig &
- uses: actions/checkout@v2
with:
@@ -33,43 +33,60 @@ jobs:
- name: Checkout
run: |
sudo curl https://raw.githubusercontent.com/klever1988/nanopi-openwrt/zstd-bin/zstd | sudo tee /usr/bin/zstd > /dev/null
cd
sudo curl -sL https://raw.githubusercontent.com/klever1988/nanopi-openwrt/zstd-bin/zstd | sudo tee /usr/bin/zstd > /dev/null
for i in {1..6}
do
curl -s -L --fail https://github.com/klever1988/sshactions/releases/download/cache/lede.${{ github.event.client_payload.device || github.event.inputs.device }}.img.zst.0$i || break
curl -sL --fail https://github.com/klever1988/sshactions/releases/download/cache/lede.${{ github.event.client_payload.device || github.event.inputs.device }}.img.zst.0$i || break
done | zstdmt -d -o lede.img || (truncate -s 40g lede.img && mkfs.xfs lede.img)
LOOP_DEVICE=$(losetup -f) && echo $LOOP_DEVICE > LOOP_DEVICE
sudo losetup -P --direct-io $LOOP_DEVICE lede.img
mkdir lede && sudo mount $LOOP_DEVICE lede && sudo chown -R $USER:$USER lede
[ ! -e lede/.git ] && (cd lede && git init && git remote add -t openwrt-18.06-k5.4 -f origin https://github.com/immortalwrt/immortalwrt && git checkout openwrt-18.06-k5.4)
mkdir lede && sudo mount $LOOP_DEVICE lede
if [ -d 'lede/.git' ]; then
cd lede && git config --local user.email "action@github.com" && git config --local user.name "GitHub Action" && git pull --ff -X theirs
else
sudo chown $USER:$(id -gn) lede && (cd lede && git init && git remote add -t openwrt-18.06-k5.4 -f origin https://github.com/immortalwrt/immortalwrt && git checkout openwrt-18.06-k5.4)
fi
- name: Update feeds and packages
run: |
cd lede/
git clone --depth=1 https://github.com/destan19/OpenAppFilter.git && rm -rf package/OpenAppFilter && mv OpenAppFilter package/
git clone --depth=1 -b 18.06 https://github.com/jerrykuku/luci-theme-argon.git && rm -rf package/lean/luci-theme-argon && mv luci-theme-argon package/lean/
cd ~/lede
./scripts/feeds update -a
./scripts/feeds install -a
git clone --depth=1 https://github.com/destan19/OpenAppFilter.git && rm -rf package/OpenAppFilter && mv OpenAppFilter package/
git clone --depth=1 -b 18.06 https://github.com/jerrykuku/luci-theme-argon.git && rm -rf package/lean/luci-theme-argon && mv luci-theme-argon package/lean/
- name: Custom configure file
run: |
cd lede
cd ~/lede
rm -f .config*
cat ../${{ github.event.client_payload.device || github.event.inputs.device }}.config.seed > .config
cat $GITHUB_WORKSPACE/${{ github.event.client_payload.device || github.event.inputs.device }}.config.seed > .config
sed -i 's/^[ \t]*//g' .config
echo '
# CONFIG_v2ray-plugin_INCLUDE_GOPROXY is not set
# CONFIG_XRAY_CORE_COMPRESS_GOPROXY is not set
# CONFIG_UnblockNeteaseMusicGo_INCLUDE_GOPROXY is not set
' >> .config
make defconfig && cat .config
cat .config
- name: Compile firmware
run: |
cd lede
cd ~/lede
if [[ ${{ github.event.client_payload.device || github.event.inputs.device }} =~ ('r2s'|'r4s') ]]; then
sdk_src='https://downloads.openwrt.org/snapshots/targets/rockchip/armv8/openwrt-sdk-rockchip-armv8_gcc-8.4.0_musl.Linux-x86_64.tar.xz'
elif [[ ${{ github.event.client_payload.device || github.event.inputs.device }} == 'r1s' ]]; then
sdk_src='https://downloads.openwrt.org/snapshots/targets/sunxi/cortexa53/openwrt-sdk-sunxi-cortexa53_gcc-8.4.0_musl.Linux-x86_64.tar.xz'
fi
mkdir sdk && wget -qO- $sdk_src | tar -xJf - -C sdk
mv sdk/*/build_dir ./ && rsync -a --ignore-existing sdk/*/staging_dir/ ./staging_dir/
rm -rf sdk
ln -sf /usr/bin/upx-ucl staging_dir/host/bin/upx
sed -i '/\(tools\|toolchain\)\/Makefile/d' Makefile
echo -e '# CONFIG_SIGNED_PACKAGES is not set\n' >> .config
make defconfig
while true; do make download -j && break || true; done
make -j$(($(nproc) + 1)) -s || (make clean && make -j1 V=sc)
while true; do make package/download -j && break || true; done
make -j$(($(nproc) + 1)) || make V=sc
echo "======================="
echo "Space usage:"
echo "======================="
@@ -81,6 +98,7 @@ jobs:
- name: Prepare artifact
run: |
cd
mkdir -p ./artifact/firmware
mkdir -p ./artifact/package
mkdir -p ./artifact/buildinfo
@@ -96,12 +114,10 @@ jobs:
echo "strDevice=$(echo ${{ github.event.client_payload.device || github.event.inputs.device }} | awk '{print toupper($0)}')" >> $GITHUB_ENV
rm -rf bin/ tmp/
cd ..
rm -f *zst*
mv artifact release $GITHUB_WORKSPACE
sudo umount lede
LOOP_DEVICE=$(cat LOOP_DEVICE)
sudo losetup -d $LOOP_DEVICE
#zstdmt -c lede.img | split -d -b 2000m - lede.${{ github.event.client_payload.device || github.event.inputs.device }}.img.zst.
#ls -l *zst*
- name: Deliver buildinfo
uses: actions/upload-artifact@v2
@@ -133,6 +149,7 @@ jobs:
- name: Save cache state
run: |
cd
export AUTH="Authorization: token ${{ secrets.SEC_TOKEN }}"
export cache_path='github.com/repos/klever1988/sshactions/releases'
export cache_repo_id='39020554'
@@ -151,7 +168,6 @@ jobs:
- name: Send tg notification
uses: appleboy/telegram-action@master
#if: always()
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}

View File

@@ -1,7 +1,5 @@
## Nanopi r1s r2s openwrt 固件自动编译
### 临时说明:
暂时不要fork自己编译因为编译缓存因为github actions工作路径不同是无效的会导致你的编译时间非常长。我正在生成统一路径的编译缓存并且修改脚本统一fork之后的编译路径稍后更新。
### 发布地址:

View File

@@ -2,6 +2,7 @@ CONFIG_TARGET_sunxi=y
CONFIG_TARGET_sunxi_cortexa53=y
CONFIG_TARGET_sunxi_cortexa53_DEVICE_friendlyarm_nanopi-r1s-h5=y
CONFIG_DEVEL=y
# CONFIG_CCACHE is not set
CONFIG_TARGET_OPTIONS=y
CONFIG_TARGET_OPTIMIZATION="-O3 -pipe -march=armv8-a+crypto+crc -mcpu=cortex-a53+crypto+crc -mtune=cortex-a53"
CONFIG_TARGET_KERNEL_PARTSIZE=32

View File

@@ -2,6 +2,7 @@ CONFIG_TARGET_rockchip=y
CONFIG_TARGET_rockchip_armv8=y
CONFIG_TARGET_rockchip_armv8_DEVICE_friendlyarm_nanopi-r2s=y
CONFIG_DEVEL=y
# CONFIG_CCACHE is not set
CONFIG_TARGET_OPTIONS=y
CONFIG_TARGET_OPTIMIZATION="-O3 -pipe -march=armv8-a+crypto+crc -mcpu=cortex-a53+crypto+crc -mtune=cortex-a53"
CONFIG_TARGET_KERNEL_PARTSIZE=32

View File

@@ -2,6 +2,7 @@ CONFIG_TARGET_rockchip=y
CONFIG_TARGET_rockchip_armv8=y
CONFIG_TARGET_rockchip_armv8_DEVICE_friendlyarm_nanopi-r4s=y
CONFIG_DEVEL=y
# CONFIG_CCACHE is not set
CONFIG_TARGET_OPTIONS=y
CONFIG_TARGET_OPTIMIZATION="-O3 -pipe -march=armv8-a+crypto+crc -mcpu=cortex-a72.cortex-a53+crypto+crc -mtune=cortex-a72.cortex-a53"
CONFIG_TARGET_KERNEL_PARTSIZE=32