From 6f33274da429e7239518576f3d8789fdcfb65668 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Tue, 10 Nov 2026 11:01:29 +0800 Subject: [PATCH] Standardize tag-driven CI and staged release publishing --- .github/RELEASING.md | 80 ++++++ .github/actions/setup-build/action.yml | 37 +++ .github/patches/.gitattributes | 1 + .github/patches/maixcdk-yaml-cstdint.patch | 19 ++ .github/release-config.json | 16 ++ .github/requirements-build.txt | 9 + .github/scripts/release_tools.py | 248 +++++++++++++++++ .github/tests/test_release_tools.py | 170 ++++++++++++ .github/workflows/build_maixcam.yml | 107 -------- .github/workflows/build_maixcam_dev.yml | 89 ------ .github/workflows/build_maixcam_main_pr.yml | 89 ------ .github/workflows/ci.yml | 57 ++++ .github/workflows/publish_pypi.yml | 68 +++++ .github/workflows/release.yml | 181 ++++++++++++ .github/workflows/release_maixcam.yml | 290 ++++++-------------- .github/workflows/release_other_linux.yml | 126 ++++----- .github/workflows/sync_gitee.yml | 2 +- .github/workflows/trigger_wiki.yml | 90 +++--- 18 files changed, 1080 insertions(+), 599 deletions(-) create mode 100644 .github/RELEASING.md create mode 100644 .github/actions/setup-build/action.yml create mode 100644 .github/patches/.gitattributes create mode 100644 .github/patches/maixcdk-yaml-cstdint.patch create mode 100644 .github/release-config.json create mode 100644 .github/requirements-build.txt create mode 100644 .github/scripts/release_tools.py create mode 100644 .github/tests/test_release_tools.py delete mode 100755 .github/workflows/build_maixcam.yml delete mode 100755 .github/workflows/build_maixcam_dev.yml delete mode 100755 .github/workflows/build_maixcam_main_pr.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish_pypi.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/RELEASING.md b/.github/RELEASING.md new file mode 100644 index 00000000..b0e6ef11 --- /dev/null +++ b/.github/RELEASING.md @@ -0,0 +1,80 @@ +# CI and releases + +## Daily CI + +CI runs for pushes to main/dev and pull requests targeting them. It checks the +release helpers, Bash syntax, and workflow syntax, then builds and smoke-tests +a Linux Python 3.11 wheel and cross-compiles the MaixCAM wheel. It never publishes +a Release or uploads packages to PyPI. Superseded daily runs are cancelled. + +## Stable releases + +1. Update maix/version.py and review .github/release-config.json. +2. Merge the release changes to main. +3. Create an annotated matching tag, for example: + git tag -a v4.12.7 -m "Release MaixPy v4.12.7" + git push origin refs/tags/v4.12.7 +4. Wait for the Release workflow. A manually published GitHub Release is not + required and does not trigger another build. + +The tag must match the source version. Only stable vMAJOR.MINOR.PATCH tags are +accepted. Existing tags are never moved automatically. + +The pipeline builds six Linux wheels (Python 3.8 through 3.13), the MaixCAM +wheel, MaixCAM and MaixCAM-Pro images, and documentation. MaixCAM2 images are +not built by this pipeline. Each job stores its output as a GitHub Actions +artifact, even before publication. Matrix failures do not cancel other jobs. + +After every build succeeds, the publication job verifies the complete artifact +set, native wheel architectures and versions, per-job provenance, compressed +images, and SHA-256 checksums. It uploads to a draft Release and publishes only +after all assets are uploaded. Build jobs have read-only repository permissions; +only the final publication job has contents:write. + +Published releases are not overwritten. Failed draft uploads can be retried. +A failure that occurs before publication leaves no newly published Release. +GitHub Release and PyPI publication are separate operations. + +## Inputs and reproducibility + +Ubuntu 22.04 and CMake 3.22.1 are fixed. Build-tool versions are listed in +.github/requirements-build.txt. The SDK uses a full commit SHA, not a moving +branch. A small checked-in compatibility patch adds the missing cstdint header +and explicitly qualified integer types to the pinned SDK's yaml-cpp source. + +The base image and builtin archive URLs and SHA-256 hashes are pinned in +.github/release-config.json. Updating the SDK or images is a reviewed source +change. In particular, the current base is the official 20251230 image: +a local image on a developer workstation is NOT automatically used in CI. +The builtin archive is pinned to v4.12.5 and is also carried into the new +Release so native download tools can find it after publication. + +Native gen_os.sh/update_img.sh remain the image packaging entry points. +Build-info JSON files record source, SDK, CI revision, and artifact hashes. +release-manifest.json and sha256sum_files.txt accompany the final assets. +APT repositories and documentation plugins are not fully locked; this is +provenance-controlled publishing, not a claim of byte-for-byte reproducibility. + +## Manual rebuild and recovery + +Run Release from Actions, choose the branch containing the new workflow, +and enter an existing tag. Leave publish=false to build and validate without +publishing. This also supports testing the new CI against an older tag: +source and CI tooling are checked out separately and their SHAs are recorded. + +For the already-published v4.12.6 created by the former workflow, first verify +its failed run has no valid assets. An authorized maintainer can change that +empty Release back to a draft before retrying with publish=true. Do not +delete or force-update its tag. Manual rebuilds use the selected CI revision's +pinned SDK and inputs, which are visible in the output manifests. + +## PyPI + +PyPI is a separate manual workflow after a successful GitHub Release. It +downloads and verifies release wheels and their published checksums; it does +not rebuild them. It needs the existing PYPI_TOKEN secret. Configure the pypi +environment's protection rules in GitHub if approval is desired. + +Only platform-tagged Linux wheels are uploaded. The legacy MaixCAM wheel +contains RISC-V code despite its py3-none-any filename, so it remains a +GitHub Release asset and is not uploaded as a supposedly portable PyPI wheel. diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml new file mode 100644 index 00000000..36ca3adc --- /dev/null +++ b/.github/actions/setup-build/action.yml @@ -0,0 +1,37 @@ +name: Set up pinned MaixPy build dependencies +description: Install the supported toolchain and pinned MaixCDK with a recorded compatibility patch. +inputs: + sdk_sha: + required: true + description: Full MaixCDK commit SHA +runs: + using: composite + steps: + - name: Install system build dependencies + run: |- + sudo apt-get update + sudo apt-get install -y build-essential git libopencv-dev libopencv-contrib-dev libsdl2-dev libfuse-dev mtools autoconf automake libtool xz-utils curl zip fuse rsync + shell: bash + - name: Checkout pinned MaixCDK + run: |- + [[ "$SDK_SHA" =~ ^[0-9a-f]{40}$ ]] + sdk="$RUNNER_TEMP/MaixCDK" + git init "$sdk" + git -C "$sdk" remote add origin https://github.com/sipeed/MaixCDK.git + git -C "$sdk" fetch --depth=1 origin "$SDK_SHA" + git -C "$sdk" checkout --detach FETCH_HEAD + test "$(git -C "$sdk" rev-parse HEAD)" = "$SDK_SHA" + git -C "$sdk" apply --check "$GITHUB_WORKSPACE/_ci/.github/patches/maixcdk-yaml-cstdint.patch" + git -C "$sdk" apply "$GITHUB_WORKSPACE/_ci/.github/patches/maixcdk-yaml-cstdint.patch" + printf "MAIXCDK_PATH=%s\n" "$sdk" >> "$GITHUB_ENV" + shell: bash + env: + SDK_SHA: ${{ inputs.sdk_sha }} + - name: Install compatible Python build tools + run: |- + python -m pip install --upgrade pip + python -m pip install -r _ci/.github/requirements-build.txt + python -m pip check + cmake --version + python --version + shell: bash diff --git a/.github/patches/.gitattributes b/.github/patches/.gitattributes new file mode 100644 index 00000000..24e115f5 --- /dev/null +++ b/.github/patches/.gitattributes @@ -0,0 +1 @@ +*.patch -whitespace diff --git a/.github/patches/maixcdk-yaml-cstdint.patch b/.github/patches/maixcdk-yaml-cstdint.patch new file mode 100644 index 00000000..8a88114d --- /dev/null +++ b/.github/patches/maixcdk-yaml-cstdint.patch @@ -0,0 +1,19 @@ +--- a/components/3rd_party/yaml/yaml-cpp/src/emitterutils.cpp ++++ b/components/3rd_party/yaml/yaml-cpp/src/emitterutils.cpp +@@ -1,4 +1,5 @@ + #include ++#include + #include + #include + +@@ -218,8 +219,8 @@ + }); + } + +-std::pair EncodeUTF16SurrogatePair(int codePoint) { +- const uint32_t leadOffset = 0xD800 - (0x10000 >> 10); ++std::pair EncodeUTF16SurrogatePair(int codePoint) { ++ const std::uint32_t leadOffset = 0xD800 - (0x10000 >> 10); + + return { + leadOffset | (codePoint >> 10), diff --git a/.github/release-config.json b/.github/release-config.json new file mode 100644 index 00000000..b173561b --- /dev/null +++ b/.github/release-config.json @@ -0,0 +1,16 @@ +{ + "sdk_sha": "83f8b8d456813932526601a40757bdafe452e718", + "cmake": "3.22.1", + "inputs": { + "base": { + "tag": "20251230", + "url": "https://github.com/sipeed/LicheeRV-Nano-Build/releases/download/20251230/2025-12-30-20-00-6073d5.img.xz", + "sha256": "aba5199e4a4d3577221476462a86d890e902a80182070998410965ac655b31a7" + }, + "builtin": { + "tag": "v4.12.5", + "url": "https://github.com/sipeed/MaixPy/releases/download/v4.12.5/maixcam_builtin_files.tar.xz", + "sha256": "4f0f2d731c030e87a3b050aec89907bcf21e795f21942a24fce53d86b87a720e" + } + } +} diff --git a/.github/requirements-build.txt b/.github/requirements-build.txt new file mode 100644 index 00000000..a80cfc3a --- /dev/null +++ b/.github/requirements-build.txt @@ -0,0 +1,9 @@ +cmake==3.22.1 +setuptools==75.3.2 +wheel==0.45.1 +packaging==24.2 +PyYAML==6.0.2 +requests==2.32.3 +progress==1.6 +maixtool==1.4.1 +pybind11-stubgen==2.5.5 diff --git a/.github/scripts/release_tools.py b/.github/scripts/release_tools.py new file mode 100644 index 00000000..f48ba43e --- /dev/null +++ b/.github/scripts/release_tools.py @@ -0,0 +1,248 @@ +"""Validation and provenance helpers; packaging stays in the native scripts.""" +import argparse +import ast +import email +import hashlib +from importlib import metadata +import platform +import json +import lzma +import tempfile +import os +from pathlib import Path +import re +import struct +import subprocess +import zipfile + +PYTHONS = ("3.8", "3.9", "3.10", "3.11", "3.12", "3.13") + + +def sha256(path): + h = hashlib.sha256() + with Path(path).open("rb") as stream: + for chunk in iter(lambda: stream.read(1024 * 1024), b""): + h.update(chunk) + return h.hexdigest() + + +def version_from_text(text): + values = {} + for node in ast.parse(text).body: + if isinstance(node, ast.Assign): + for target in node.targets: + if isinstance(target, ast.Name) and target.id in ( + "version_major", "version_minor", "version_patch" + ): + values[target.id] = ast.literal_eval(node.value) + return ".".join(str(values["version_" + part]) for part in ("major", "minor", "patch")) + + +def version(path="."): + return version_from_text((Path(path) / "maix/version.py").read_text()) + + +def tag_version(tag): + match = re.fullmatch(r"v([0-9]+\.[0-9]+\.[0-9]+)", tag) + if not match: + raise ValueError("Expected a stable release tag such as v4.12.6") + return match.group(1) + + +def prepare(tag, config): + expected = tag_version(tag) # Validate before passing the ref to git. + subprocess.run(["git", "fetch", "--depth=1", "origin", "refs/tags/" + tag], check=True) + source_sha = subprocess.check_output( + ["git", "rev-parse", "FETCH_HEAD^{commit}"], text=True + ).strip() + text = subprocess.check_output(["git", "show", source_sha + ":maix/version.py"], text=True) + if version_from_text(text) != expected: + raise ValueError("Tag does not match maix/version.py") + settings = json.loads(Path(config).read_text()) + if not re.fullmatch(r"[0-9a-f]{40}", settings["sdk_sha"]): + raise ValueError("MaixCDK must be pinned to a full commit SHA") + base = subprocess.check_output( + ["git", "show", source_sha + ":maix/version_base_system_maixcam.txt"], text=True + ).strip() + if base != settings["inputs"]["base"]["tag"]: + raise ValueError("Base image version differs from release-config.json") + ci_sha = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip() + outputs = dict(tag=tag, version=expected, source_sha=source_sha, + sdk_sha=settings["sdk_sha"], ci_sha=ci_sha) + with open(os.environ["GITHUB_OUTPUT"], "a") as stream: + for key, value in outputs.items(): + stream.write("{}={}\n".format(key, value)) + print(json.dumps(outputs, indent=2)) + + +def wheel_info(path, expected_version=None, machine=None): + with zipfile.ZipFile(path) as archive: + bad = archive.testzip() + if bad: + raise ValueError("Damaged wheel member: " + bad) + metadata = [n for n in archive.namelist() if n.endswith(".dist-info/METADATA")] + modules = [n for n in archive.namelist() if n == "maix/_maix.so"] + if len(metadata) != 1 or len(modules) != 1: + raise ValueError("Wheel must contain one METADATA and maix/_maix.so") + info = email.message_from_bytes(archive.read(metadata[0])) + binary = archive.read(modules[0]) + if len(binary) < 20 or binary[:6] != b"\x7fELF\x02\x01": + raise ValueError("Expected a little-endian ELF64 native module") + actual = struct.unpack_from(" 64 * 1024 * 1024: + raise ValueError("Invalid boot partition geometry") + stream.seek(start * 512) + boot = stream.read(sectors * 512) + if len(boot) != sectors * 512: + raise ValueError("Truncated boot partition") + with tempfile.TemporaryDirectory() as directory: + image = Path(directory) / "boot.fat" + image.write_bytes(boot) + text = subprocess.check_output(["mtype", "-i", str(image), "::board"], text=True) + info = dict(line.strip().split("=", 1) for line in text.splitlines() if "=" in line) + expected_id = board.replace("-", "_") + if info.get("id") != expected_id or info.get("panel") != panels[board]: + raise ValueError("Image board configuration mismatch") + value = subprocess.check_output(["mtype", "-i", str(image), "::ver"], text=True).strip() + pattern = re.escape(board) + r"-[0-9]{4}-[0-9]{2}-[0-9]{2}-maixpy-v" + re.escape(expected_version) + if not re.fullmatch(pattern, value): + raise ValueError("Image version mismatch") + print("Verified image board, panel, and version:", path) + + +def manifest(directory, kind): + destination = Path(directory) + versions = {"python": platform.python_version()} + for package in ("cmake", "setuptools", "wheel", "PyYAML", "requests", "maixtool", "teedoc"): + try: + versions[package] = metadata.version(package) + except metadata.PackageNotFoundError: + pass + info = { + "tool_versions": versions, + "compatibility_patch_sha256": sha256( + Path(__file__).resolve().parents[1] / "patches/maixcdk-yaml-cstdint.patch" + ), + "kind": kind, "source_sha": os.environ["SOURCE_SHA"], + "sdk_sha": os.environ["SDK_SHA"], "ci_sha": os.environ["CI_SHA"], + "version": version(), "files": { + p.name: sha256(p) for p in sorted(destination.iterdir()) if p.is_file() + }, + } + (destination / ("build-info-" + kind + ".json")).write_text(json.dumps(info, indent=2) + "\n") + + +def download(config, directory): + settings = json.loads(Path(config).read_text()) + directory = Path(directory) + directory.mkdir(parents=True, exist_ok=True) + for name, filename in (("base", "base_os.img.xz"), ("builtin", "maixcam_builtin_files.tar.xz")): + item = settings["inputs"][name] + target = directory / filename + subprocess.run(["curl", "--fail", "--location", "--retry", "3", + "--output", str(target), item["url"]], check=True) + if sha256(target) != item["sha256"]: + raise ValueError("SHA-256 mismatch for release input: " + name) + (directory / "release-inputs.json").write_text(json.dumps(settings, indent=2) + "\n") + + +def collect(directory, expected_version, source_sha, sdk_sha, ci_sha): + directory = Path(directory) + wheels = sorted(directory.glob("*.whl")) + if len(wheels) != len(PYTHONS) + 1: + raise ValueError("Expected six Linux wheels and one MaixCAM wheel") + infos = [wheel_info(p, expected_version) for p in wheels] + linux = [p for p, i in zip(wheels, infos) if i["machine"] == 62] + riscv = [i for i in infos if i["machine"] == 243] + if len(linux) != 6 or len(riscv) != 1: + raise ValueError("Release wheel architectures do not match the build matrix") + for py in PYTHONS: + abi = "cp" + py.replace(".", "") + if sum(("-" + abi + "-") in p.name for p in linux) != 1: + raise ValueError("Missing or duplicate Linux wheel for Python " + py) + for board in ("maixcam", "maixcam-pro"): + images = list(directory.glob(board + "-????-??-??-maixpy-v" + expected_version + ".img.xz")) + if len(images) != 1: + raise ValueError("Missing or duplicate image for " + board) + subprocess.run(["xz", "--test", str(images[0])], check=True) + for name in ("maixpy_v" + expected_version + "_doc.zip", "maixcam_builtin_files.tar.xz", + "release-inputs.json"): + if not (directory / name).is_file(): + raise ValueError("Missing release artifact: " + name) + kinds = ["linux-" + p for p in PYTHONS] + ["maixcam", "docs"] + for kind in kinds: + data = json.loads((directory / ("build-info-" + kind + ".json")).read_text()) + if data["source_sha"] != source_sha or data["sdk_sha"] != sdk_sha or data.get("ci_sha") != ci_sha: + raise ValueError("Mixed source, SDK, or CI revisions in artifacts") + for name, digest in data["files"].items(): + if Path(name).name != name or sha256(directory / name) != digest: + raise ValueError("Artifact integrity mismatch: " + name) + with zipfile.ZipFile(directory / ("maixpy_v" + expected_version + "_doc.zip")) as archive: + if archive.testzip(): + raise ValueError("Corrupt documentation archive") + summary = dict(version=expected_version, source_sha=source_sha, sdk_sha=sdk_sha, + ci_sha=ci_sha, wheels=infos) + (directory / "release-manifest.json").write_text(json.dumps(summary, indent=2) + "\n") + with (directory / "sha256sum_files.txt").open("w") as stream: + for path in sorted(directory.iterdir()): + if path.is_file() and path.name != "sha256sum_files.txt": + stream.write("{} {}\n".format(sha256(path), path.name)) + + +def main(): + parser = argparse.ArgumentParser() + subs = parser.add_subparsers(dest="command", required=True) + p = subs.add_parser("prepare") + p.add_argument("--tag", required=True) + p.add_argument("--config", required=True) + p = subs.add_parser("verify-wheel") + p.add_argument("path") + p.add_argument("--machine", type=int, required=True) + p = subs.add_parser("check-image") + p.add_argument("path") + p.add_argument("--board", required=True, choices=["maixcam", "maixcam-pro"]) + p = subs.add_parser("manifest") + p.add_argument("directory") + p.add_argument("kind") + p = subs.add_parser("download") + p.add_argument("config") + p.add_argument("directory") + p = subs.add_parser("collect") + p.add_argument("directory") + p.add_argument("--version", required=True) + p.add_argument("--source-sha", required=True) + p.add_argument("--sdk-sha", required=True) + p.add_argument("--ci-sha", required=True) + args = parser.parse_args() + if args.command == "prepare": + prepare(args.tag, args.config) + elif args.command == "verify-wheel": + print(json.dumps(wheel_info(args.path, version(), args.machine), indent=2)) + elif args.command == "check-image": + check_image(args.path, args.board, version()) + elif args.command == "manifest": + manifest(args.directory, args.kind) + elif args.command == "download": + download(args.config, args.directory) + elif args.command == "collect": + collect(args.directory, args.version, args.source_sha, args.sdk_sha, args.ci_sha) + + +if __name__ == "__main__": + main() diff --git a/.github/tests/test_release_tools.py b/.github/tests/test_release_tools.py new file mode 100644 index 00000000..d7495f5d --- /dev/null +++ b/.github/tests/test_release_tools.py @@ -0,0 +1,170 @@ +import importlib.util +import json +import lzma +import os +from pathlib import Path +import struct +import tempfile +import unittest +from unittest.mock import patch +import zipfile + +spec = importlib.util.spec_from_file_location( + "release_tools", Path(__file__).resolve().parents[1] / "scripts/release_tools.py" +) +tools = importlib.util.module_from_spec(spec) +spec.loader.exec_module(tools) + + +def make_wheel(directory, name, machine, version="4.12.6"): + path = Path(directory) / name + binary = bytearray(20) + binary[:6] = b"\x7fELF\x02\x01" + struct.pack_into("= (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 autoconf automake libtool git build-essential - 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 ==" diff --git a/.github/workflows/build_maixcam_dev.yml b/.github/workflows/build_maixcam_dev.yml deleted file mode 100755 index 6bd3821f..00000000 --- a/.github/workflows/build_maixcam_dev.yml +++ /dev/null @@ -1,89 +0,0 @@ -# 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: [ dev ] - - # 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 autoconf automake libtool git build-essential - 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: | - echo "== install teedoc ==" - pip3 install teedoc - cd docs - echo "== install plugins ==" - teedoc install - echo "== start build ==" - teedoc build - echo "== build complete ==" - diff --git a/.github/workflows/build_maixcam_main_pr.yml b/.github/workflows/build_maixcam_main_pr.yml deleted file mode 100755 index 0dc37fcf..00000000 --- a/.github/workflows/build_maixcam_main_pr.yml +++ /dev/null @@ -1,89 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Build MaixCAM PR - -# 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 autoconf automake libtool git build-essential - 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: | - echo "== install teedoc ==" - pip3 install teedoc - cd docs - echo "== install plugins ==" - teedoc install - echo "== start build ==" - teedoc build - echo "== build complete ==" - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..98048d4b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: CI +'on': + push: + branches: + - main + - dev + pull_request: + branches: + - main + - dev + workflow_dispatch: {} +permissions: + contents: read +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + validate: + runs-on: ubuntu-22.04 + timeout-minutes: 15 + outputs: + sdk_sha: ${{ steps.config.outputs.sdk_sha }} + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Validate release helpers and packaging scripts + run: |- + python -m unittest discover -s .github/tests -v + bash -n tools/os/maixcam/gen_os.sh tools/os/maixcam/update_img.sh + - name: Lint workflow syntax + run: |- + go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.7 + "$(go env GOPATH)/bin/actionlint" -shellcheck= + - name: Read pinned SDK revision + run: python -c 'import json,os,re; c=json.load(open(".github/release-config.json")); assert re.fullmatch("[0-9a-f]{40}",c["sdk_sha"]); + print("sdk_sha="+c["sdk_sha"],file=open(os.environ["GITHUB_OUTPUT"],"a"))' + id: config + linux: + needs: validate + uses: ./.github/workflows/release_other_linux.yml + with: + source_sha: ${{ github.sha }} + ci_sha: ${{ github.sha }} + sdk_sha: ${{ needs.validate.outputs.sdk_sha }} + python_version: '3.11' + maixcam: + needs: validate + uses: ./.github/workflows/release_maixcam.yml + with: + source_sha: ${{ github.sha }} + ci_sha: ${{ github.sha }} + sdk_sha: ${{ needs.validate.outputs.sdk_sha }} + images: false diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml new file mode 100644 index 00000000..15f859d8 --- /dev/null +++ b/.github/workflows/publish_pypi.yml @@ -0,0 +1,68 @@ +name: Publish Linux wheels to PyPI +'on': + workflow_dispatch: + inputs: + tag: + description: Published release tag, for example v4.12.7 + required: true + type: string +permissions: + contents: read +concurrency: + group: pypi-${{ inputs.tag }} + cancel-in-progress: false +jobs: + publish: + runs-on: ubuntu-22.04 + timeout-minutes: 20 + environment: pypi + env: + TAG: ${{ inputs.tag }} + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Download and verify published Linux wheels + run: |- + python -c 'import os,sys;sys.path.insert(0,".github/scripts");import release_tools;release_tools.tag_version(os.environ["TAG"])' + gh api "repos/$GH_REPO/releases/tags/$TAG" > "$RUNNER_TEMP/release.json" + python -c 'import json,sys; r=json.load(open(sys.argv[1])); assert not r["draft"], "Release must be published first"' "$RUNNER_TEMP/release.json" + gh release download "$TAG" --pattern "*.whl" --pattern sha256sum_files.txt --dir downloads + python - <<'PY' + import os, shutil, sys + from pathlib import Path + sys.path.insert(0, ".github/scripts") + import release_tools as tools + expected = tools.tag_version(os.environ["TAG"]) + sums = {} + for line in Path("downloads/sha256sum_files.txt").read_text().splitlines(): + digest, name = line.split(" ", 1) + if Path(name).name != name: + raise ValueError("Unsafe checksum entry") + sums[name] = digest + target = Path("packages"); target.mkdir() + for wheel in Path("downloads").glob("*.whl"): + if tools.sha256(wheel) != sums.get(wheel.name): + raise ValueError("Wheel checksum mismatch: " + wheel.name) + info = tools.wheel_info(wheel, expected) + if info["machine"] == 62: + if "manylinux" not in wheel.name or "-py3-none-any" in wheel.name: + raise ValueError("Linux wheel must have an explicit platform tag") + shutil.copy2(wheel, target) + elif info["machine"] != 243: + raise ValueError("Unexpected wheel architecture") + if len(list(target.glob("*.whl"))) != 6: + raise ValueError("Expected six platform-tagged Linux wheels") + PY + - name: Publish verified wheels + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_TOKEN }} + packages-dir: packages/ + skip-existing: true + attestations: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..e0006247 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,181 @@ +name: Release +'on': + push: + tags: + - v* + workflow_dispatch: + inputs: + tag: + description: Existing stable tag to rebuild, for example v4.12.6 + required: true + type: string + publish: + description: Publish GitHub Release after all checks (false builds artifacts only) + required: true + type: boolean + default: false +permissions: + contents: read +concurrency: + group: release-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} + cancel-in-progress: false +jobs: + prepare: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + outputs: + tag: ${{ steps.prepare.outputs.tag }} + version: ${{ steps.prepare.outputs.version }} + source_sha: ${{ steps.prepare.outputs.source_sha }} + sdk_sha: ${{ steps.prepare.outputs.sdk_sha }} + ci_sha: ${{ steps.prepare.outputs.ci_sha }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Validate release tag and resolve immutable revisions + run: python .github/scripts/release_tools.py prepare --tag "$TAG" --config .github/release-config.json + id: prepare + env: + TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} + linux: + needs: prepare + strategy: + fail-fast: false + matrix: + python: + - '3.8' + - '3.9' + - '3.10' + - '3.11' + - '3.12' + - '3.13' + uses: ./.github/workflows/release_other_linux.yml + with: + source_sha: ${{ needs.prepare.outputs.source_sha }} + ci_sha: ${{ needs.prepare.outputs.ci_sha }} + sdk_sha: ${{ needs.prepare.outputs.sdk_sha }} + python_version: ${{ matrix.python }} + maixcam: + needs: prepare + uses: ./.github/workflows/release_maixcam.yml + with: + source_sha: ${{ needs.prepare.outputs.source_sha }} + ci_sha: ${{ needs.prepare.outputs.ci_sha }} + sdk_sha: ${{ needs.prepare.outputs.sdk_sha }} + images: true + docs: + needs: prepare + runs-on: ubuntu-22.04 + timeout-minutes: 45 + env: + SOURCE_SHA: ${{ needs.prepare.outputs.source_sha }} + SDK_SHA: ${{ needs.prepare.outputs.sdk_sha }} + CI_SHA: ${{ needs.prepare.outputs.ci_sha }} + VERSION: ${{ needs.prepare.outputs.version }} + steps: + - name: Checkout source + uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare.outputs.source_sha }} + persist-credentials: false + - name: Checkout CI tooling + uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare.outputs.ci_sha }} + path: _ci + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Build documentation archive + run: |- + python -m pip install teedoc==1.37.9 + (cd docs && teedoc install && teedoc build) + mkdir -p out "doc-package/maixpy_v${VERSION}_doc/html" "doc-package/maixpy_v${VERSION}_doc/source" + cp -a docs/out/. "doc-package/maixpy_v${VERSION}_doc/html/" + rsync -a --exclude out --exclude node_modules docs/ "doc-package/maixpy_v${VERSION}_doc/source/" + (cd doc-package && zip -qr "../out/maixpy_v${VERSION}_doc.zip" "maixpy_v${VERSION}_doc") + python _ci/.github/scripts/release_tools.py manifest out docs + - name: Store build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-docs + path: out/* + if-no-files-found: error + retention-days: 14 + overwrite: true + assemble: + needs: + - prepare + - linux + - maixcam + - docs + runs-on: ubuntu-22.04 + timeout-minutes: 30 + env: + VERSION: ${{ needs.prepare.outputs.version }} + SOURCE_SHA: ${{ needs.prepare.outputs.source_sha }} + SDK_SHA: ${{ needs.prepare.outputs.sdk_sha }} + CI_SHA: ${{ needs.prepare.outputs.ci_sha }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare.outputs.ci_sha }} + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Download complete build matrix + uses: actions/download-artifact@v4 + with: + pattern: build-* + path: out + merge-multiple: true + - name: Validate artifacts and generate checksums + run: python .github/scripts/release_tools.py collect out --version "$VERSION" --source-sha "$SOURCE_SHA" --sdk-sha + "$SDK_SHA" + - name: Store complete release bundle + uses: actions/upload-artifact@v4 + with: + name: release-bundle + path: out/* + if-no-files-found: error + overwrite: true + retention-days: 14 + publish: + needs: + - prepare + - assemble + if: ${{ github.event_name == 'push' || inputs.publish }} + runs-on: ubuntu-22.04 + timeout-minutes: 30 + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + TAG: ${{ needs.prepare.outputs.tag }} + VERSION: ${{ needs.prepare.outputs.version }} + SOURCE_SHA: ${{ needs.prepare.outputs.source_sha }} + SDK_SHA: ${{ needs.prepare.outputs.sdk_sha }} + steps: + - name: Download verified release bundle + uses: actions/download-artifact@v4 + with: + name: release-bundle + path: out + - name: Upload to draft, then publish the complete release + run: | + if gh api "repos/$GH_REPO/releases/tags/$TAG" > "$RUNNER_TEMP/release.json" 2> "$RUNNER_TEMP/release-error.log"; then + jq -e '.draft == true' "$RUNNER_TEMP/release.json" > /dev/null || { echo "Published releases will not be overwritten"; exit 1; } + else + if ! grep -q "HTTP 404" "$RUNNER_TEMP/release-error.log"; then cat "$RUNNER_TEMP/release-error.log"; exit 1; fi + gh release create "$TAG" --target "$SOURCE_SHA" --draft --title "MaixPy $TAG" --generate-notes + fi + gh release upload "$TAG" out/* --clobber + gh release edit "$TAG" --draft=false + printf "Published: https://github.com/%s/releases/tag/%s\n" "$GH_REPO" "$TAG" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release_maixcam.yml b/.github/workflows/release_maixcam.yml index 17417d72..767ae782 100644 --- a/.github/workflows/release_maixcam.yml +++ b/.github/workflows/release_maixcam.yml @@ -1,206 +1,90 @@ -name: Relase MaixPy for MaixCAM - -on: - release: - types: [published] - workflow_dispatch: - -permissions: write-all - +name: Build MaixCAM wheel and images +'on': + workflow_call: + inputs: + source_sha: + required: true + type: string + ci_sha: + required: true + type: string + sdk_sha: + required: true + type: string + images: + required: false + type: boolean + default: false +permissions: + contents: read 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 }} + runs-on: ubuntu-22.04 + timeout-minutes: 240 + env: + SOURCE_SHA: ${{ inputs.source_sha }} + SDK_SHA: ${{ inputs.sdk_sha }} + CI_SHA: ${{ inputs.ci_sha }} 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 packaging - 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 autoconf automake libtool git build-essential - python -m pip install "cmake==3.22.1" - 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/maixcam - 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/maixcam_builtin_files - ./gen_os.sh $base_os_path $release_path $builtin_files_dir 0 maixcam - os_filename=${os_version_name}.img.xz - os_filepath=`pwd`/images/$os_filename - sha256sum $release_path >> ${maixpy_path}/sha256sum_files.txt - sha256sum $os_filepath > ${maixpy_path}/sha256sum_files.txt - echo "os_path=$os_filepath" >> $GITHUB_OUTPUT - echo "os_name=$os_filename" >> $GITHUB_OUTPUT - echo "-------------------------------------" - echo "-- Generate system for MaixCAM-Pro --" - echo "-------------------------------------" - os_version_name_pro="maixcam-pro-${date_now}-maixpy-${maixpy_version}" - ./gen_os.sh $base_os_path $release_path $builtin_files_dir 1 maixcam-pro - os_filename=${os_version_name_pro}.img.xz - os_filepath=`pwd`/images/$os_filename - sha256sum $os_filepath >> ${maixpy_path}/sha256sum_files.txt - echo "os_pro_path=$os_filepath" >> $GITHUB_OUTPUT - echo "os_pro_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 MaixCAM 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: Upload MaixCAM-Pro OS to release assets - uses: svenstaro/upload-release-action@v2 - with: - file: ${{ steps.build_maixpy.outputs.os_pro_path }} - asset_name: ${{ steps.build_maixpy.outputs.os_pro_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 - + - name: Checkout source + uses: actions/checkout@v4 + with: + ref: ${{ inputs.source_sha }} + persist-credentials: false + - name: Checkout CI tooling + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ci_sha }} + path: _ci + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Set up build environment + uses: ./_ci/.github/actions/setup-build + with: + sdk_sha: ${{ inputs.sdk_sha }} + - name: Build native bindings and cross-compile MaixCAM wheel + run: |- + python setup.py bdist_wheel linux + bash run.sh test/test_basic.py + python setup.py bdist_wheel maixcam + mkdir -p out + cp dist/*.whl out/ + for wheel in out/*.whl; do python _ci/.github/scripts/release_tools.py verify-wheel "$wheel" --machine 243; done + - name: Download and verify pinned image inputs + run: |- + python _ci/.github/scripts/release_tools.py download _ci/.github/release-config.json build/release-inputs + mkdir -p build/release-inputs/builtin + tar -xJf build/release-inputs/maixcam_builtin_files.tar.xz -C build/release-inputs/builtin + cp build/release-inputs/maixcam_builtin_files.tar.xz build/release-inputs/release-inputs.json out/ + if: ${{ inputs.images }} + - name: Package MaixCAM and MaixCAM Pro using native scripts + run: |- + root="$PWD" + wheel=$(find "$root/out" -maxdepth 1 -name "*.whl" -print) + test "$(find "$root/out" -maxdepth 1 -name "*.whl" | wc -l)" -eq 1 + base="$root/build/release-inputs/base_os.img.xz" + builtin="$root/build/release-inputs/builtin/maixcam_builtin_files" + cd tools/os/maixcam + bash gen_os.sh "$base" "$wheel" "$builtin" 0 maixcam + bash gen_os.sh "$base" "$wheel" "$builtin" 1 maixcam-pro + for board in maixcam maixcam-pro; do + for image in images/"$board"-????-??-??-maixpy-v*.img.xz; do + xz --test "$image" + (cd "$root" && python _ci/.github/scripts/release_tools.py check-image "tools/os/maixcam/$image" --board "$board") + done + done + cp images/*.img.xz "$root/out/" + if: ${{ inputs.images }} + - name: Record build provenance + run: python _ci/.github/scripts/release_tools.py manifest out maixcam + - name: Store build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-maixcam + path: out/* + if-no-files-found: error + retention-days: 14 + overwrite: true diff --git a/.github/workflows/release_other_linux.yml b/.github/workflows/release_other_linux.yml index 08b38c30..07930f4d 100644 --- a/.github/workflows/release_other_linux.yml +++ b/.github/workflows/release_other_linux.yml @@ -1,68 +1,64 @@ -name: Relase MaixPy for Linux - -on: - release: - types: [published] - workflow_dispatch: - -permissions: write-all - +name: Build Linux wheel +'on': + workflow_call: + inputs: + source_sha: + required: true + type: string + ci_sha: + required: true + type: string + sdk_sha: + required: true + type: string + python_version: + required: true + type: string +permissions: + contents: read jobs: build: - name: release and upload assets task - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.12", "3.13"] # 3.11 released by release_maixcam - os: ["ubuntu-latest"] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-22.04 + timeout-minutes: 120 + env: + SOURCE_SHA: ${{ inputs.source_sha }} + SDK_SHA: ${{ inputs.sdk_sha }} + CI_SHA: ${{ inputs.ci_sha }} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Build MaixPy - id: build_maixpy - run: | - 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 twine packaging - 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 autoconf automake libtool git build-essential - python -m pip install "cmake==3.22.1" - cmake --version - python setup.py bdist_wheel linux - echo "--------------------------------" - echo "-- Test MaixPy basic for Linux now --" - echo "--------------------------------" - release_name=`ls dist|awk '{print $1}'` - release_path=dist/$release_name - echo "release_path=$release_path" >> $GITHUB_OUTPUT - echo "release_name=$release_name" >> $GITHUB_OUTPUT - - - name: Publish MaixPy to pypi.org - run: | - echo "[pypi]" > ~/.pypirc - echo " username = __token__" >> ~/.pypirc - echo " password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc - twine upload dist/*.whl - - - name: Upload 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: Checkout source + uses: actions/checkout@v4 + with: + ref: ${{ inputs.source_sha }} + persist-credentials: false + - name: Checkout CI tooling + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ci_sha }} + path: _ci + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python_version }} + - name: Set up build environment + uses: ./_ci/.github/actions/setup-build + with: + sdk_sha: ${{ inputs.sdk_sha }} + - name: Build and smoke-test Linux wheel + run: |- + python setup.py bdist_wheel linux + bash run.sh test/test_basic.py + mkdir -p out + cp dist/*.whl out/ + for wheel in out/*.whl; do python _ci/.github/scripts/release_tools.py verify-wheel "$wheel" --machine 62; done + python _ci/.github/scripts/release_tools.py manifest out "linux-$PYTHON_VERSION" + env: + PYTHON_VERSION: ${{ inputs.python_version }} + - name: Store build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-linux-${{ inputs.python_version }} + path: out/* + if-no-files-found: error + retention-days: 14 + overwrite: true diff --git a/.github/workflows/sync_gitee.yml b/.github/workflows/sync_gitee.yml index 13686bbe..33e5df38 100644 --- a/.github/workflows/sync_gitee.yml +++ b/.github/workflows/sync_gitee.yml @@ -31,7 +31,7 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: checkout code from github - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Runs a set of commands using the runners shell - name: sync shell cmd diff --git a/.github/workflows/trigger_wiki.yml b/.github/workflows/trigger_wiki.yml index 35e99749..31ca181a 100755 --- a/.github/workflows/trigger_wiki.yml +++ b/.github/workflows/trigger_wiki.yml @@ -1,45 +1,45 @@ -# This is a basic workflow to help you get started with Actions - -name: trigger wiki - -# Controls when the action will run. -on: - push: - branches: - - gh-pages - pull_request: - branches: - - gh-pages - - # 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" - trigger_wiki: - name: trigger sipeed_wiki - # 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.8] - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - name: trigger sipeed wiki request - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.DISPATCH_PAT }} - script: | - const result = await github.rest.repos.createDispatchEvent({ - owner: 'sipeed', - repo: 'sipeed_wiki', - event_type: 'update_maixpy_doc', - client_payload: {"key": "value"} - }) - console.log(result); +# This is a basic workflow to help you get started with Actions + +name: trigger wiki + +# Controls when the action will run. +on: + push: + branches: + - gh-pages + pull_request: + branches: + - gh-pages + + # 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" + trigger_wiki: + name: trigger sipeed_wiki + # 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.8] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: trigger sipeed wiki request + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.DISPATCH_PAT }} + script: | + const result = await github.rest.repos.createDispatchEvent({ + owner: 'sipeed', + repo: 'sipeed_wiki', + event_type: 'update_maixpy_doc', + client_payload: {"key": "value"} + }) + console.log(result);