-
Notifications
You must be signed in to change notification settings - Fork 7
337 lines (312 loc) · 12.4 KB
/
release.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
name: K230 CanMV Release
on:
release:
types: [released]
push:
branches:
- dev
pull_request:
branches:
- main
- dev
defaults:
run:
shell: bash
jobs:
build_image:
name: CanMV Build
runs-on: [ubuntu-latest]
timeout-minutes: 180
strategy:
matrix:
cfg: ["canmv"]
env:
CONF: k230_${{ matrix.cfg }}_defconfig
steps:
- name: Check for dockerenv
run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)
- name: show runner file and release runner disk space
run: |
echo “show runner hostname”
hostname
echo “show runner user”
whoami
echo “show runner pwd”
pwd
echo “show runner kernel”
uname -a
echo "show runner disk usage BEFORE delete"
df -h /
echo "show disk usage BEFORE delete"
du -h -d 1 /usr/local | grep G || echo "skip error"
du -h -d 1 /usr/local/lib | grep G || echo "skip error"
du -h -d 1 /usr/share | grep G || echo "skip error"
du -h -d 1 /opt/ | grep G || echo "skip error"
du -h -d 1 /opt/hostedtoolcache | grep G || echo "skip error"
echo "show disk usage BEFORE delete"
echo "show removed directories disk usage"
du -h -d 0 /usr/share/dotnet/ || echo "dir not exist"
du -h -d 0 /usr/share/swift/ || echo "dir not exist"
du -h -d 0 /usr/local/.ghcup/ || echo "dir not exist"
du -h -d 0 /usr/local/share/powershell/ || echo "dir not exist"
du -h -d 0 /usr/local/share/chromium/ || echo "dir not exist"
du -h -d 0 /usr/local/lib/android/ || echo "dir not exist"
du -h -d 0 /usr/local/lib/node_modules/ || echo "dir not exist"
du -h -d 0 /opt/hostedtoolcache/ || echo "dir not exist"
ls /opt/hostedtoolcache || echo "dir not exist"
ls /opt/microsoft || echo "dir not exist"
echo “show /home/ dir in runner”
ls /home/
echo “show /home/runner/ dir in runner”
ls -alht /home/runner/ || echo "dir not exist"
echo “show /home/runner/work/ dir in runner”
ls -alht /home/runner/work/ || echo "dir not exist"
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
- name: Delete file and release runner disk space
run: |
echo “show runner hostname”
hostname
echo “show runner user”
whoami
echo “show runner pwd”
pwd
echo “show runner kernel”
uname -a
echo "show disk usage BEFORE delete"
df -h /
echo "Removing large directories"
sudo rm -rf /usr/share/dotnet/ || echo "remove dotnet failed"
sudo rm -rf /usr/share/swift/ || echo "remove dotnet failed"
sudo rm -rf /usr/local/.ghcup/ || echo "remove ghcup failed"
sudo rm -rf /usr/local/share/powershell || echo "remove powershell failed"
sudo rm -rf /usr/local/share/chromium || echo "remove chromium failed"
sudo rm -rf /usr/local/lib/android || echo "remove android failed"
sudo rm -rf /usr/local/lib/node_modules || echo "remove node_modules failed"
sudo rm -rf /opt/hostedtoolcache || echo "remove hostedtoolcache failed"
echo "show disk usage AFTER delete"
df -h /
- name: Install Nvm/Node for Actions Checkout Env
run: |
pwd
ls -alht
export NVM_DIR="$HOME/.nvm" && (
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"
nvm install node || exit 1
node --version || exit 1
- name: Checkout Source Code
uses: actions/checkout@v4
with:
fetch-depth: 0
clean: true
submodules: recursive
- name: Download Toolchain and Setup Build Env
run: |
ls -alht micropython
ls -alht k230_sdk
pwd
echo "manual update micropython submodules directly from github and skip local mirror download"
cd micropython || exit 1
git submodule update --recursive --init || exit 1
cd ../ || exit 1
echo "add safe dir for prepare_sourcecode use git command with permission error"
git config --global --add safe.directory $PWD
git config --global --add safe.directory $PWD/k230_sdk
git config --global --add safe.directory $PWD/micropython/micropython
git config --global --add safe.directory $PWD/micropython/port/3d-party/freetype/freetype
git config --global --add safe.directory $PWD/micropython/port/3d-party/lvgl/lv_binding_micropython
git config --global --add safe.directory $PWD/micropython/port/3d-party/wrap/micropython-wrap
git config --global --list
ls -alht
echo "download toolchain and build env"
time make prepare_sourcecode FAST_DL=0 || exit 1
ls -alht
mkdir -p /opt/ || exit 1
rm -rf /opt/toolchain/
echo "show PWD toolchain"
ls -alht $PWD/k230_sdk/toolchain/ || exit 1
echo "link ./k230_sdk/toolchain to /opt/toolchain"
ln -s $PWD/k230_sdk/toolchain /opt/ || exit 1
echo "show /opt/toolchain/"
ls -alht /opt/toolchain/ || exit 1
ls -alht /opt/toolchain/Xuantie-900-gcc-linux* || exit 1
ls -alht /opt/toolchain/riscv64-linux* || exit 1
- name: Build with docker
run: |
echo “show runner hostname”
hostname
echo “show runner user”
whoami
echo “show runner pwd”
pwd
echo “show runner kernel”
uname -a
docker run \
--workdir $PWD \
--name k230_sdk \
--hostname release \
--user root \
--volume /home/:/home \
--volume /opt:/opt \
ghcr.io/kendryte/k230_sdk:latest \
/bin/bash -c "pwd; ls -alht; \
(ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv); \
echo 'show docker hostname';hostname; \
echo 'show docker user';whoami; \
echo 'start to build k230 canmv image'; \
git config --global --add safe.directory $PWD; \
git config --global --add safe.directory $PWD/k230_sdk; \
git config --global --add safe.directory $PWD/micropython/micropython; \
git config --global --add safe.directory $PWD/micropython/port/3d-party/freetype/freetype; \
git config --global --add safe.directory $PWD/micropython/port/3d-party/lvgl/lv_binding_micropython; \
git config --global --add safe.directory $PWD/micropython/port/3d-party/wrap/micropython-wrap; \
time make CONF=$CONF || exit 1; \
echo '---show docker build output---'; \
ls -alht output/${CONF}/images || exit 1"
- name: Show Output Directory For Debug Purpose
run: |
echo “show runner hostname”
hostname
echo “show runner user”
whoami
echo “show runner pwd”
pwd
echo “show runner kernel”
uname -a
echo “show runner pwd file list”
ls
ls -alht output/${CONF}/images/
echo "k230 sdk version:"
cat output/${CONF}/images/little-core/rootfs/etc/version/release_version || echo "k230 sdk version file not exist"
# Copy compiled files to /github/workspace/artifacts
sudo mkdir -p /github/workspace/artifacts
sudo chown -R $(id -u):$(id -g) /github/workspace/artifacts
sudo chmod -R 755 /github/workspace/artifacts
cp output/${CONF}/images/CanMV*.img.gz /github/workspace/artifacts/
cp output/${CONF}/images/little-core/rootfs/etc/version/release_version /github/workspace/artifacts/k230_sdk_version.txt || echo "k230 sdk version file not exist"
ls -alht /github/workspace/artifacts/
shell: bash
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.cfg }}
path: /github/workspace/artifacts
upload_release:
needs: build_image
name: CanMV Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: artifacts-*
merge-multiple: true
- name: Display Structure of Artifacts Files
run: ls -R
- name: Show Working Directory For Debug Purpose
run: |
echo “show runner hostname”
hostname
echo “show runner user”
whoami
echo “show runner pwd”
pwd
echo “show runner kernel”
uname -a
echo “show runner pwd file list”
ls
ls -alht
echo “show runner artifacts”
ls -alht artifacts || exit 0
echo "github.ref: ${{github.ref}} "
- name: Upload images to Release Asset
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.CR_PAT }}
pre_release:
needs: build_image
name: CanMV PreRelease
if: ${{ github.ref_name == 'dev' }}
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: artifacts-*
merge-multiple: true
- name: Display Structure of Artifacts Files
run: ls -R
- name: Show Working Directory For Debug Purpose
run: |
echo “show runner hostname”
hostname
echo “show runner user”
whoami
echo “show runner pwd”
pwd
echo “show runner kernel”
uname -a
echo “show runner pwd file list”
ls
ls -alht
echo “show runner artifacts”
ls -alht artifacts || exit 0
- name: Delete current prerelease assets
uses: andreaswilli/delete-release-assets-action@main
with:
github_token: ${{ secrets.CR_PAT }}
tagPrefix: 'PreRelease-'
tag: ${{ github.ref_name }}
deleteOnlyFromDrafts: false
- name: Set Env
run: |
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
- name: Tag Repo
uses: richardsimko/update-tag@v1
with:
tag_name: PreRelease-${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.CR_PAT }}
- name: Set Relese Txt
run: |
cat > prerelease.txt << 'EOF'
Pre Release基于最新的开发分支dev branch自动编译,并会自动删除旧的编译,只保留当前最新镜像,仅供测试使用
Pre Release build with latest ${{ github.ref_name }} branch, it will delete old build and only keeping the latest version.
Current ${{ github.ref_name }} branch build at ${{ env.BUILDTIME }} , Current build git commit id ${{ github.sha }}
<br>
[k230_canmv](https://github.com/kendryte/k230_canmv)
[k230_canmv_docs](https://github.com/kendryte/k230_canmv_docs)
[k230_sdk](https://github.com/kendryte/k230_sdk)
[k230_sdk_docs](https://github.com/kendryte/k230_sdk_docs)
EOF
- name: Upload images to PreRelease Asset
uses: softprops/action-gh-release@v2
if: ${{ success() }}
with:
tag_name: PreRelease-${{ github.ref_name }}
files: |
artifacts/*
prerelease: true
generate_release_notes: true
body_path: prerelease.txt
env:
GITHUB_TOKEN: ${{ secrets.CR_PAT }}