-
Notifications
You must be signed in to change notification settings - Fork 5
158 lines (132 loc) · 4.44 KB
/
openwrt-builder.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Build ImmortalWrt for N1
on:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
schedule:
- cron: "0 0 1 * *"
env:
REPO_URL: https://github.com/immortalwrt/immortalwrt
REPO_BRANCH: openwrt-23.05
CONFIG_FILE: N1/.config
DIY_SH: N1/diy.sh
FILES: N1/files
TZ: Asia/Shanghai
GITHUB_TOKEN: ${{ secrets.TOKEN }}
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: 准备完成
uses: actions/checkout@main
- name: 清理磁盘空间
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: 初始化编译环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update -y
sudo -E apt-get -qq install -y $(curl -fsSL https://raw.githubusercontent.com/nantayo/My-Pkg/master/2305)
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: 克隆源码
working-directory: /workdir
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH --single-branch --depth=1 openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: 更新 & 安装 feeds
working-directory: ./openwrt
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: 加载自定义配置
run: |
[ -e $FILES ] && mv $FILES openwrt/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
chmod +x $DIY_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_SH
- name: SSH 连接到 Actions
uses: P3TERX/ssh2actions@main
if: (github.event.inputs.ssh == 'true') || contains(github.event.action, 'ssh')
- name: 下载软件包
working-directory: ./openwrt
run: |
make defconfig
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: 编译固件
run: |
chmod -R 755 openwrt
cd openwrt
echo -e "$(nproc) thread compile"
make -j$(nproc) || make -j1 || make -j1 V=s
echo "compile_status=success" >> $GITHUB_ENV
- name: 打包镜像文件
if: ${{ env.compile_status }} == 'success' && !cancelled()
uses: unifreq/openwrt_packit@master
env:
OPENWRT_ARMVIRT: openwrt/bin/targets/*/*/*.tar.gz
KERNEL_VERSION_NAME: 5.15.y_6.6.y
PACKAGE_SOC: s905d
GZIP_IMGS: .xz
SCRIPT_DIY_PATH: N1/mk_s905d_n1.sh
WHOAMI: innmonkey
OPENWRT_VER: $(date +"%Y.%m.%d")
SW_FLOWOFFLOAD: 0
SFE_FLOW: 0
ENABLE_WIFI_K510: 0
- name: 生成发布标签
if: ${{ env.PACKAGED_STATUS == 'success' }} && !cancelled()
run: |
echo "release_tag=$(date +"%Y.%m.%d-%H.%M")" >> ${GITHUB_OUTPUT}
touch release.txt
echo "
🍁 注意事项:首次使用建议全新刷写
💻 适用机型: 斐讯N1
📂 源码: ${{ env.REPO_URL }}
🌳 分支: ${{ env.REPO_BRANCH }}
⏱️ 编译时间: $(date +"%Y年%m月%d日%H时%M分")
🌐 管理地址: 192.168.0.2
👤 用户名: root
🔒 密码: password
" >> release.txt
echo "tag_status=success" >> $GITHUB_ENV
- name: 发布固件到 Releases
uses: softprops/action-gh-release@v2
if: ${{ env.tag_status == 'success' }} && !cancelled()
with:
tag_name: OpenWrt_${{ env.PACKAGED_OUTPUTDATE }}
files: ${{ env.PACKAGED_OUTPUTPATH }}/*.img.xz
body_path: release.txt
token: ${{ env.GITHUB_TOKEN }}
- name: 消息推送
run: curl "https://api2.pushdeer.com/message/push?pushkey=${{ secrets.PUSHDEER_TOKEN }}&text=【Github Actions】OpenWrt-N1打包成功"
- name: 删除运行记录
uses: Mattraks/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 1
token: ${{ env.GITHUB_TOKEN }}
- name: 删除自动发布的旧固件
uses: dev-drprasad/delete-older-releases@master
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 2
delete_tags : true