Skip to content

Commit

Permalink
Rebuild MaixPy doc by commit refs/heads/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Jul 26, 2024
0 parents commit adb2856
Show file tree
Hide file tree
Showing 304 changed files with 141,229 additions and 0 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/build_maixcam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# This is a basic workflow to help you get started with Actions

name: Build MaixCAM

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
# pull_request:
# branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions: write-all

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# Only run job for specific repository
if: github.repository == 'sipeed/MaixPy'
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"] # MaixCAM use 3.11
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: 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
pwd_path=$(pwd)
cd ~
git clone https://github.com/sipeed/MaixCDK --depth=1
export MAIXCDK_PATH=`pwd`/MaixCDK
cd $pwd_path
python -m pip install -U pip setuptools wheel
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
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
mv dist/* artifact/
echo "----------------------------------"
echo "-- Build MaixPy for MaixCAM now --"
echo "----------------------------------"
python setup.py bdist_wheel maixcam
mv dist/* artifact/
- name: Upload MaixPy Linux firmware as artifact
uses: actions/upload-artifact@v4
with:
name: maixpy_firmware
path: artifact/*.whl

# Runs a set of commands using the runners shell
- name: Push doc to github pages
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 =="
cd out
cp -r ../../.github .
git config --global init.defaultBranch gh-pages
git init
git config user.name "${user_name}"
git config user.email ${user_email}
remote_addr="https://Neutree:${{ secrets.DISPATCH_PAT }}@${remote_addr}"
echo "-- user ${user_name}"
echo "-- remote addr: ${remote_addr}"
git remote add origin "${remote_addr}"
echo "== add web files =="
git add -A
git commit -m "Rebuild MaixPy doc by commit $GITHUB_REF"
git push origin HEAD:gh-pages --force
echo "== push complete =="
88 changes: 88 additions & 0 deletions .github/workflows/build_maixcam_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# This is a basic workflow to help you get started with Actions

name: Build MaixCAM Dev branch

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ dev ]
# pull_request:
# branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions: write-all

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# Only run job for specific repository
if: github.repository == 'sipeed/MaixPy'
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"] # MaixCAM use 3.11
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: 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
pwd_path=$(pwd)
cd ~
git clone https://github.com/sipeed/MaixCDK -b dev --depth=1
export MAIXCDK_PATH=`pwd`/MaixCDK
cd $pwd_path
python -m pip install -U pip setuptools wheel
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
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
mv dist/* artifact/
echo "----------------------------------"
echo "-- Build MaixPy for MaixCAM now --"
echo "----------------------------------"
python setup.py bdist_wheel maixcam
mv dist/* artifact/
- name: Upload MaixPy Linux firmware as artifact
uses: actions/upload-artifact@v4
with:
name: maixpy_firmware
path: artifact/*.whl

# Runs a set of commands using the runners shell
- name: build doc
run: |
pip3 install teedoc
cd docs
echo "== install plugins =="
teedoc install
echo "== start build =="
teedoc build
echo "== build complete =="
187 changes: 187 additions & 0 deletions .github/workflows/release_maixcam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
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
sha256sum $os_filepath > ${maixpy_path}/sha256sum_files.txt
sha256sum $release_path >> ${maixpy_path}/sha256sum_files.txt
echo "os_path=$os_filepath" >> $GITHUB_OUTPUT
echo "os_name=$os_filename" >> $GITHUB_OUTPUT
- name: Build doc
id: build_doc
run: |
maixpy_path=$(pwd)
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_dirname=maixpy_${{ github.ref_name }}_doc
doc_dir=${maixpy_path}/$doc_dirname
echo "#!/bin/bash" > out/view_doc.sh
echo "python -m http.server" >> out/view_doc.sh
echo "python -m http.server" > out/view_doc.bat
mkdir -p ${doc_dir}/html
mv ./out/* ${doc_dir}/html/
mkdir -p ${doc_dir}/source
mv ./* ${doc_dir}/source/
cd ${maixpy_path}
zip ${doc_dirname}.zip -r $doc_dirname
release_name=${doc_dirname}.zip
release_path=${maixpy_path}/$release_name
sha256sum $release_path >> ${maixpy_path}/sha256sum_files.txt
echo "release_doc_path=$release_path" >> $GITHUB_OUTPUT
echo "release_doc_name=$release_name" >> $GITHUB_OUTPUT
echo "sha256sum_path=${maixpy_path}/sha256sum_files.txt" >> $GITHUB_OUTPUT
echo "sha256sum_name=sha256sum_files.txt" >> $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 sha256sum file to release assets
uses: svenstaro/upload-release-action@v2
with:
file: ${{ steps.build_doc.outputs.sha256sum_path }}
asset_name: ${{ steps.build_doc.outputs.sha256sum_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
Loading

0 comments on commit adb2856

Please sign in to comment.