Skip to content

Commit 841e109

Browse files
committed
x86_64
1 parent a747e90 commit 841e109

2 files changed

Lines changed: 7618 additions & 0 deletions

File tree

.github/workflows/x86_64.yml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
#
2+
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com>
3+
#
4+
# This is free software, licensed under the MIT License.
5+
# See /LICENSE for more information.
6+
#
7+
# https://github.com/P3TERX/Actions-OpenWrt
8+
# Description: Build OpenWrt using GitHub Actions
9+
#
10+
11+
name: x86_64 OpenWrt
12+
13+
on:
14+
repository_dispatch:
15+
workflow_dispatch:
16+
inputs:
17+
ssh:
18+
description: 'SSH connection to Actions'
19+
required: true
20+
default: 'false'
21+
schedule:
22+
- cron: 0 19 * * *
23+
# watch:
24+
# types: started
25+
26+
env:
27+
REPO_URL: http://github.com/immortalwrt/immortalwrt
28+
REPO_BRANCH: openwrt-21.02
29+
FEEDS_CONF: feeds.conf.default
30+
CONFIG_FILE: config/x86_64.config
31+
DIY_P1_SH: diy-part1.sh
32+
DIY_P2_SH: diy-part2.sh
33+
UPLOAD_BIN_DIR: true
34+
UPLOAD_FIRMWARE: true
35+
UPLOAD_COWTRANSFER: true
36+
UPLOAD_WETRANSFER: true
37+
UPLOAD_RELEASE: false
38+
TZ: Asia/Shanghai
39+
40+
jobs:
41+
build:
42+
runs-on: ubuntu-18.04
43+
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@main
47+
48+
- name: Initialization environment
49+
env:
50+
DEBIAN_FRONTEND: noninteractive
51+
run: |
52+
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
53+
sudo -E apt-get -qq update
54+
sudo -E apt-get -qq install $(curl -fsSL git.io/depends-ubuntu-1804)
55+
sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential bzip2 ccache cmake cpio curl device-tree-compiler ecj fastjar flex gawk gettext gcc-multilib g++-multilib git git-core gperf haveged help2man intltool lib32gcc1 libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncurses5-dev libreadline-dev libssl-dev libtool libz-dev lrzsz mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pip python3-ply python-docutils qemu-utils re2c rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
56+
sudo -E apt-get -qq autoremove --purge
57+
sudo -E apt-get -qq clean
58+
sudo timedatectl set-timezone "$TZ"
59+
sudo mkdir -p /workdir
60+
sudo chown $USER:$GROUPS /workdir
61+
- name: Clone source code
62+
working-directory: /workdir
63+
run: |
64+
df -hT $PWD
65+
git clone $REPO_URL -b $REPO_BRANCH openwrt
66+
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
67+
- name: Load custom feeds
68+
run: |
69+
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default
70+
#chmod +x $DIY_P1_SH
71+
#cd openwrt
72+
#$GITHUB_WORKSPACE/$DIY_P1_SH
73+
- name: Update feeds
74+
run: cd openwrt && ./scripts/feeds update -a
75+
76+
- name: Install feeds
77+
run: cd openwrt && ./scripts/feeds install -a
78+
79+
- name: Load custom configuration
80+
run: |
81+
[ -e files ] && mv files openwrt/files
82+
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
83+
# Modify default IP
84+
sed -i 's/192.168.1.1/192.168.30.3/g' package/base-files/files/bin/config_generate
85+
# Modify hostname
86+
sed -i 's/OpenWrt/OpenWrt-Calmact-x86/g' package/base-files/files/bin/config_generate
87+
# Modify the version number
88+
sed -i "s/OpenWrt /Calmact build $(TZ=UTC-8 date "+%Y.%m.%d") @ OpenWrt /g" package/lean/default-settings/files/zzz-default-settings
89+
# Add kernel build user
90+
[ -z $(grep "CONFIG_KERNEL_BUILD_USER=" .config) ] &&
91+
echo 'CONFIG_KERNEL_BUILD_USER="Calmact"' >>.config ||
92+
sed -i 's@\(CONFIG_KERNEL_BUILD_USER=\).*@\1$"Calmact"@' .config
93+
# Add kernel build domain
94+
[ -z $(grep "CONFIG_KERNEL_BUILD_DOMAIN=" .config) ] &&
95+
echo 'CONFIG_KERNEL_BUILD_DOMAIN="GitHub Actions"' >>.config ||
96+
sed -i 's@\(CONFIG_KERNEL_BUILD_DOMAIN=\).*@\1$"GitHub Actions"@' .config
97+
cd openwrt
98+
#$GITHUB_WORKSPACE/$DIY_P2_SH
99+
- name: SSH connection to Actions
100+
uses: P3TERX/ssh2actions@v1.0.0
101+
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
102+
env:
103+
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
104+
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
105+
106+
- name: Download package
107+
id: package
108+
run: |
109+
cd openwrt
110+
make defconfig
111+
make download -j8
112+
find dl -size -1024c -exec ls -l {} \;
113+
find dl -size -1024c -exec rm -f {} \;
114+
- name: Compile the firmware
115+
id: compile
116+
run: |
117+
cd openwrt
118+
echo -e "$(nproc) thread compile"
119+
make -j$(nproc) || make -j2 || make -j2 V=s
120+
echo "::set-output name=status::success"
121+
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME
122+
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV
123+
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
124+
- name: Check space usage
125+
if: (!cancelled())
126+
run: df -hT
127+
128+
- name: Upload bin directory
129+
uses: actions/upload-artifact@main
130+
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
131+
with:
132+
name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
133+
path: openwrt/bin
134+
135+
- name: Organize files
136+
id: organize
137+
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
138+
run: |
139+
cd openwrt/bin/targets/*/*
140+
rm -rf packages
141+
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
142+
echo "::set-output name=status::success"
143+
- name: Upload firmware directory
144+
uses: actions/upload-artifact@main
145+
if: steps.organize.outputs.status == 'success' && !cancelled()
146+
with:
147+
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
148+
path: ${{ env.FIRMWARE }}
149+
150+
- name: Upload firmware to cowtransfer
151+
id: cowtransfer
152+
if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled()
153+
run: |
154+
curl -fsSL git.io/file-transfer | sh
155+
./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log
156+
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)"
157+
echo "::set-output name=url::$(cat cowtransfer.log | grep https | cut -f3 -d" ")"
158+
159+
- name: Upload firmware to WeTransfer
160+
id: wetransfer
161+
if: steps.organize.outputs.status == 'success' && env.UPLOAD_WETRANSFER == 'true' && !cancelled()
162+
run: |
163+
curl -fsSL git.io/file-transfer | sh
164+
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log
165+
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"
166+
echo "::set-output name=url::$(cat wetransfer.log | grep https | cut -f3 -d" ")"
167+
168+
- name: Generate release tag
169+
id: tag
170+
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
171+
run: |
172+
echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")"
173+
touch release.txt
174+
[ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt
175+
[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt
176+
echo "::set-output name=status::success"
177+
178+
- name: Upload firmware to release
179+
uses: softprops/action-gh-release@v1
180+
if: steps.tag.outputs.status == 'success' && !cancelled()
181+
env:
182+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
183+
with:
184+
tag_name: ${{ steps.tag.outputs.release_tag }}
185+
body_path: release.txt
186+
files: ${{ env.FIRMWARE }}/*
187+
188+
- name: Delete workflow runs
189+
uses: GitRML/delete-workflow-runs@main
190+
with:
191+
retain_days: 1
192+
keep_minimum_runs: 3
193+
194+
- name: Remove old Releases
195+
uses: dev-drprasad/delete-older-releases@v0.1.0
196+
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
197+
with:
198+
keep_latest: 7
199+
delete_tags: true
200+
env:
201+
GITHUB_TOKEN: ${{ secrets.TOKEN }}

0 commit comments

Comments
 (0)