-
Notifications
You must be signed in to change notification settings - Fork 20
213 lines (182 loc) · 6.97 KB
/
NanoPi-Build.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#=================================================
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
name: NanoPi Build
on:
# release:
# types: published
#push:
# branches:
# - 21.02
# paths:
# - '.github/workflows/openwrt-rockchip-2102.yml'
# - 'step/00-prepare_openwrt.sh'
# - 'step/01-prepare_package.sh'
# - 'seed/rockchip.seed'
#schedule:
# - cron: 30 21 * * *
#watch:
# types: started
workflow_dispatch:
inputs:
openwrt_branch:
description: 'OpenWrt Branch to build'
required: true
default: '23.05'
type: choice
options:
- '23.05'
model_R5S:
description: 'Build R5S'
type: boolean
default: true
build_mini:
description: 'Build mini seed'
type: boolean
default: true
build_full:
description: 'Build full seed'
type: boolean
default: false
jobs:
init:
runs-on: ubuntu-22.04
if: github.event.repository.owner.id == github.event.sender.id
# Map a step output to a job output
outputs:
build_string: ${{ steps.gen_build_string.outputs.build_string }}
release_tag: ${{ steps.gen_release_tag.outputs.release_tag }}
matrix: ${{ steps.build_matrix.outputs.matrix }}
steps:
- id: gen_build_string
run: echo "build_string=$(date +%Y.%m.%d)" >> $GITHUB_OUTPUT
- id: gen_release_tag
run: echo "release_tag=$(date +%Y%m%d)" >> $GITHUB_OUTPUT
- id: build_matrix
run: |
model_R5S="${{ fromJSON('["", "R5S"]')[github.event.inputs.model_R5S == 'true'] }}"
models="$model_R5S"
modelsJson=$(echo -n "$models" | jq -R -s -c 'split(" ") | map(select(length>0))')
matrix="{\"nanopi_model\":$modelsJson}"
echo "matrix=$matrix" >> $GITHUB_OUTPUT
build:
needs: init
strategy:
matrix: ${{ fromJson(needs.init.outputs.matrix) }}
runs-on: ubuntu-22.04
if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Free space
run: ./workflow-scripts/free_disk_space.sh
- name: Setup Linux Requirements
uses: ./.github/actions/setup-devenv
- name: Set GITHUB_ENV
run: |
echo "TZ=Europe/Paris" >>$GITHUB_ENV
echo "BUILD_STRING=${{ needs.init.outputs.build_string }}" >> $GITHUB_ENV
echo "RELTAG=${{ needs.init.outputs.release_tag }}" >> $GITHUB_ENV
echo "OPENWRT_BRANCH=${{ github.event.inputs.openwrt_branch }}" >> $GITHUB_ENV
echo "NANOPI_MODEL=${{ matrix.nanopi_model }}" >> $GITHUB_ENV
echo "BUILD_MINI=${{ github.event.inputs.build_mini }}" >> $GITHUB_ENV
echo "BUILD_FULL=${{ github.event.inputs.build_full }}" >> $GITHUB_ENV
- name: Show GITHUB_ENV
run: echo $GITHUB_ENV
- name: Clone OpenWrt source
run: ./openwrt-$OPENWRT_BRANCH/steps/01_clone_openwrt.sh
- name: Make working copy of OpenWrt source
run: ./openwrt-$OPENWRT_BRANCH/steps/02_prepare_openwrt_folder.sh
- name: Patch OpenWrt Source
run: ./openwrt-$OPENWRT_BRANCH/steps/03_patch_openwrt.sh
- name: Prepare package
run: ./openwrt-$OPENWRT_BRANCH/steps/04-prepare_package.sh
- name: Add ACL
run: ./openwrt-$OPENWRT_BRANCH/steps/05-create_luci_acl.sh
- name: Load toolchain seed
run: ./openwrt-$OPENWRT_BRANCH/steps/06-create_config_from_seed.sh $NANOPI_MODEL full
- name: Download package
id: package
run: |
cd build/openwrt
make download -j10
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Make toolchain-aarch64
id: compiletoolchain
continue-on-error: true
run: |
cd build/openwrt
let make_process=$(nproc)+1
make toolchain/install -j${make_process}
- name: If toolchain Error
if: steps.compiletoolchain.outcome == 'failure'
run: |
echo '================================================================'
cd build/openwrt && make toolchain/install -j1 V=s
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
shell: bash
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Load AO seed (mini)
if: github.event.inputs.build_mini == 'true'
run: ./openwrt-$OPENWRT_BRANCH/steps/06-create_config_from_seed.sh $NANOPI_MODEL mini
- name: Build kmods (mini)
if: github.event.inputs.build_mini == 'true'
run: ./openwrt-$OPENWRT_BRANCH/steps/07-all_kmods.sh
- name: Compile OpenWRT (mini)
id: compileopenwrtmini
if: github.event.inputs.build_mini == 'true'
continue-on-error: true
run: |
cd build/openwrt
let make_process=$(nproc)+1
make -j${make_process} || make -j${make_process}
- name: If compile openwrt Error
if: github.event.inputs.build_mini == 'true' && steps.compileopenwrtmini.outcome == 'failure'
run: |
cat build/openwrt/.config
echo '================================================================'
cd build/openwrt && make -j1 V=s
- name: Organize files (mini)
id: organizemini
if: github.event.inputs.build_mini == 'true'
run: ./openwrt-$OPENWRT_BRANCH/steps/organize_files.sh $NANOPI_MODEL mini $OPENWRT_BRANCH $RELTAG
- name: Load AO seed (full)
if: github.event.inputs.build_full == 'true'
run: ./openwrt-$OPENWRT_BRANCH/steps/06-create_config_from_seed.sh $NANOPI_MODEL full
- name: Build kmods (full)
if: github.event.inputs.build_full == 'true'
run: ./openwrt-$OPENWRT_BRANCH/steps/07-all_kmods.sh
- name: Compile OpenWRT (full)
id: compileopenwrtfull
if: github.event.inputs.build_full == 'true'
continue-on-error: true
run: |
cd build/openwrt
let make_process=$(nproc)+1
make -j${make_process} || make -j${make_process}
- name: If compile openwrt Error
if: github.event.inputs.build_full == 'true' && steps.compileopenwrtfull.outcome == 'failure'
run: |
cat build/openwrt/.config
echo '================================================================'
cd build/openwrt && make -j1 V=s
- name: Organize files (full)
id: organizefull
if: github.event.inputs.build_full == 'true'
run: ./openwrt-$OPENWRT_BRANCH/steps/organize_files.sh $NANOPI_MODEL full $OPENWRT_BRANCH $RELTAG
- name: Create release
id: create_release
uses: ncipollo/[email protected]
if: ${{ !cancelled() }}
with:
name: OpenWrt ${{ env.OPENWRT_BRANCH }} ${{ env.BUILD_STRING }}
allowUpdates: true
tag: OpenWrtAO-${{ env.OPENWRT_BRANCH }}-${{ env.RELTAG }}
commit: main
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
bodyFile: "openwrt-${{ env.OPENWRT_BRANCH }}/release-info.md"
artifacts: ./artifact/*.img.gz