-
Notifications
You must be signed in to change notification settings - Fork 36
169 lines (158 loc) · 7.06 KB
/
release_maixcam.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
name: Relase MaixPy for MaixCAM
on:
release:
types: [published]
workflow_dispatch:
permissions: write-all
jobs:
build:
name: release and upload assets task
strategy:
matrix:
python-version: ["3.11"] # must use str, not int, or 3.10 will be recognized as 3.1
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build MaixPy
id: build_maixpy
run: |
echo "-- Check python version must python 3.11 --"
python3 -c 'import sys;print(sys.version);assert sys.version_info >= (3, 11);assert sys.version_info < (3, 12)'
python -c 'import sys;print(sys.version);assert sys.version_info >= (3, 11);assert sys.version_info < (3, 12)'
whereis python
whereis python3
# export PATH=~/.local/bin/:$PATH
# pull sipeed/MaixCDK repo here first
maixpy_path=$(pwd)
maixpy_version=`git describe --tag`
cd ~
git clone https://github.com/sipeed/MaixCDK --depth=1
export MAIXCDK_PATH=`pwd`/MaixCDK
cd $maixpy_path
python -m pip install -U pip setuptools wheel twine
python -m pip install -r $MAIXCDK_PATH/requirements.txt
python -m pip install pybind11-stubgen
echo "--------------------------------"
echo "-- Build MaixPy for Linux now --"
echo "--------------------------------"
sudo apt update -y
sudo apt install -y libopencv-dev libopencv-contrib-dev libsdl2-dev cmake libfuse-dev mtools
cmake --version
python setup.py bdist_wheel linux
echo "--------------------------------"
echo "-- Test MaixPy basic for Linux now --"
echo "--------------------------------"
chmod +x ./run.sh && ./run.sh test/test_basic.py
mkdir -p artifact
cp dist/* artifact/
release_name=`ls artifact|awk '{print $1}'`
release_path=artifact/$release_name
echo "release_linux_path=$release_path" >> $GITHUB_OUTPUT
echo "release_linux_name=$release_name" >> $GITHUB_OUTPUT
echo "----------------------------------"
echo "-- Build MaixPy for MaixCAM now --"
echo "----------------------------------"
python setup.py bdist_wheel maixcam
cp dist/* artifact/
release_name=`ls dist|awk '{print $1}'`
release_path=`realpath dist/$release_name`
echo "release_path=$release_path" >> $GITHUB_OUTPUT
echo "release_name=$release_name" >> $GITHUB_OUTPUT
echo "--------------------------------"
echo "-- Generate MaixCDK version file --"
echo "--------------------------------"
cd $MAIXCDK_PATH
maixcdk_rev=`git rev-parse HEAD`
maixcdk_version_name="maixcdk_version_${maixcdk_rev}.txt"
echo "MaixPy ${maixpy_version} use MaixCDK commit ${maixcdk_rev}" > $maixcdk_version_name
maixcdk_version_path=`realpath "${MAIXCDK_PATH}/${maixcdk_version_name}"`
echo "maixcdk_version_path=$maixcdk_version_path" >> $GITHUB_OUTPUT
echo "maixcdk_version_name=$maixcdk_version_name" >> $GITHUB_OUTPUT
cd $maixpy_path
echo "--------------------------------"
echo "-- Generate system --"
echo "--------------------------------"
cd tools/os
chmod +x gen_os.sh
date_now=`date +"%Y-%m-%d"`
os_version_name="maixcam-${date_now}-maixpy-${maixpy_version}"
base_os_path=tmp/base_os.img.xz
python download_base_os.py -o ${base_os_path}
python download_builtin_files.py --unzip tmp/dl_builtin_files
builtin_files_dir=tmp/dl_builtin_files/sys_builtin_files
./gen_os.sh $base_os_path $release_path $builtin_files_dir $os_version_name
os_filename=${os_version_name}.img.xz
os_filepath=`pwd`/tmp/$os_filename
echo "os_path=$os_filepath" >> $GITHUB_OUTPUT
echo "os_name=$os_filename" >> $GITHUB_OUTPUT
- name: Build doc
id: build_doc
run: |
pip3 install teedoc
cd docs
echo "== install plugins =="
teedoc install
echo "== start build =="
teedoc build
echo "== build complete =="
remote_addr=`git remote get-url --push origin`
remote_addr=`echo $remote_addr| awk -F'://' '{print $2}'`
user_name=`git log -1 --pretty=format:'%an'`
user_email=`git log -1 --pretty=format:'%ae'`
echo "== checkout gh-pages branch =="
doc_dir=maixpy_${{ github.ref_name }}_doc
echo "#!/bin/bash" > out/view_doc.sh
echo "python3 -m http.server" >> out/view_doc.sh
echo "python3 -m http.server" > out/view_doc.bat
mv out $doc_dir
zip ${doc_dir}.zip -r $doc_dir
cd ..
release_name=${doc_dir}.zip
release_path=docs/$release_name
echo "release_doc_path=$release_path" >> $GITHUB_OUTPUT
echo "release_doc_name=$release_name" >> $GITHUB_OUTPUT
- name: Upload MaixPy Doc to release assets
uses: svenstaro/upload-release-action@v2
with:
file: ${{ steps.build_doc.outputs.release_doc_path }}
asset_name: ${{ steps.build_doc.outputs.release_doc_name }}
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload MaixCDK version txt to release assets
uses: svenstaro/upload-release-action@v2
with:
file: ${{ steps.build_maixpy.outputs.maixcdk_version_path }}
asset_name: ${{ steps.build_maixpy.outputs.maixcdk_version_name }}
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload MaixPy MaixCAM to release assets
uses: svenstaro/upload-release-action@v2
with:
file: ${{ steps.build_maixpy.outputs.release_path }}
asset_name: ${{ steps.build_maixpy.outputs.release_name }}
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload MaixPy Linux to release assets
uses: svenstaro/upload-release-action@v2
with:
file: ${{ steps.build_maixpy.outputs.release_linux_path }}
asset_name: ${{ steps.build_maixpy.outputs.release_linux_name }}
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload OS to release assets
uses: svenstaro/upload-release-action@v2
with:
file: ${{ steps.build_maixpy.outputs.os_path }}
asset_name: ${{ steps.build_maixpy.outputs.os_name }}
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish MaixPy to pypi.org
run: |
echo "[pypi]" > ~/.pypirc
echo " username = __token__" >> ~/.pypirc
echo " password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
twine upload artifact/*.whl