diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml new file mode 100644 index 0000000..09896a5 --- /dev/null +++ b/.github/workflows/build_test.yml @@ -0,0 +1,42 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + strategy: + matrix: + python-version: [3.8, 3.9, "3.10", "3.11"] + os: [windows-latest, ubuntu-20.04, macos-latest] + # exclude: + # # package dependencies error on macos 3.9+ for unkwown reason + # - os: macos-latest + # python-version: 3.9 + # - os: macos-latest + # python-version: "3.10" + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: | + python -m pip install --upgrade pip + pip install setuptools wheel + - name: Install typing-extensions + if: ${{ matrix.python-version == 3.6 }} + run: | + pip install typing-extensions==4.1.1 + - name: Build dist and test with unittest + run: | + make build install test build_dist diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..bde15ca --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +name: lint + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + flake8-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install flake8 + run: pip install flake8 + - name: Run flake8 + run: make lint diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index fca78d7..f52ae0b 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,39 +1,122 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Upload Python Package - -on: - release: - types: [published] - -permissions: - contents: read - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.8' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + create: + workflow_dispatch: + +permissions: + contents: read + +jobs: + deploy-wheels: + name: Deploy wheels on ${{ matrix.os }} for ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [36, 37, 38, 39, 310] + manylinux-image: [manylinux2010, manylinux2014, manylinux_2_24] + arch: [auto] + include: + - os: ubuntu-latest + manylinux-image: manylinux2014 + arch: aarch64 + python-version: 36 + - os: ubuntu-latest + manylinux-image: manylinux2014 + arch: aarch64 + python-version: 37 + - os: ubuntu-latest + manylinux-image: manylinux2014 + arch: aarch64 + python-version: 38 + - os: ubuntu-latest + manylinux-image: manylinux2014 + arch: aarch64 + python-version: 39 + - os: ubuntu-latest + manylinux-image: manylinux2014 + arch: aarch64 + python-version: 310 + exclude: + # manyliunx image is not a valid variation on MacOS and Windows + - os: macos-latest + manylinux-image: manylinux2010 + - os: windows-latest + manylinux-image: manylinux2010 + - os: macos-latest + manylinux-image: manylinux2014 + - os: windows-latest + manylinux-image: manylinux2014 + + steps: + - uses: actions/checkout@v2 + - name: Set up QEMU + if: ${{ matrix.arch == 'aarch64' }} + uses: docker/setup-qemu-action@v1 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install twine setuptools wheel + - name: Install cibuildwheel + run: python -m pip install cibuildwheel -U + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: 'cp${{ matrix.python-version }}-*' + CIBW_SKIP: '*musllinux*' + CIBW_ARCHS: ${{matrix.arch}} + CIBW_MANYLINUX_*_IMAGE: ${{ matrix.manylinux-image }} + CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux-image }} + + - name: Publish wheels to PyPI Unix + if: matrix.os != 'windows-latest' + continue-on-error: true + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + twine upload wheelhouse/*.whl + - name: Publish wheels to PyPI Windows + if: matrix.os == 'windows-latest' + continue-on-error: true + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + twine upload (Get-ChildItem wheelhouse/*.whl) + deploy-tar: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install twine setuptools wheel + - name: Build source tar + run: | + python setup.py sdist + - name: Publish wheels to PyPI + continue-on-error: true + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + twine upload dist/*tar* diff --git a/README.md b/README.md index 9ccf895..01ba9a4 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,14 @@ From pip: From source code: - python setup.py install + git clone https://github.com/Ovizro/Karuha.git + cd Karuha + make install ## Quick Start +> Before starting, you need to make sure you have the Tinode service running locally with its gRPC port set to the default value of 16060. If your service is not local or the default port has been changed, you need to add additional server configuration items in the following code. + Create a new file `config.json` and write the following content: ```json @@ -60,7 +64,7 @@ Well, you can actually go a step further and send messages to users. Currently, if you want to reply to a message, you currently need to add a handler for the event yourself. This is not a simple process. Fortunately, we are about to introduce a command module to improve this. -Because this is a relatively low-level function, I will only give an example to show how karuha is currently used in python: +Because this is a relatively low-level API, I will only give an example to show how karuha is currently used in python: ```python import karuha diff --git a/README_cn.md b/README_cn.md new file mode 100644 index 0000000..2cfe99a --- /dev/null +++ b/README_cn.md @@ -0,0 +1,95 @@ +# Karuha + +[![License](https://img.shields.io/github/license/Ovizro/Karuha.svg)](/LICENSE) +[![PyPI](https://img.shields.io/pypi/v/KaruhaBot.svg)](https://pypi.python.org/pypi/KaruhaBot) +![Python Version](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11-blue.svg) + +一个简单的Tinode聊天机器人框架 + +> 目前项目仍处于开发期,部分次要接口可能会频繁变化,造成的不便敬请谅解 + +库的名称`Karuha`来自游戏星空列车与白的旅行中的角色 狩叶·朗姆柯妮(カルハ・ラムコネ) + +