diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml new file mode 100644 index 0000000..28b9b53 --- /dev/null +++ b/.github/workflows/publish_pypi.yml @@ -0,0 +1,56 @@ +# @Author: jankincai +# @Date: 2024-09-13 10:48:33 +# @Last Modified by: jankincai +# @Last Modified time: 2024-09-14 11:21:11 + +# 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: + push: + branches: [ "master" ] + + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + name: Build and publish Python to PyPI and TestPyPI + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + cache: 'pip' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + sudo apt install libpcap-dev + - name: Build package + run: python -m build -s + - name: Publish package to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish package to PyPI + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/python-package.yml b/.github/workflows/test_py36.yml similarity index 69% rename from .github/workflows/python-package.yml rename to .github/workflows/test_py36.yml index 304175a..aa08df0 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/test_py36.yml @@ -1,25 +1,27 @@ # @Author: jankincai # @Date: 2024-09-12 10:45:37 # @Last Modified by: jankincai -# @Last Modified time: 2024-09-12 10:56:55 +# @Last Modified time: 2024-09-14 11:16:35 # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: Python package +name: Tests on: push: branches: [ "master", "develop" ] + pull_request: + branches: [ "master", "develop" ] jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.6"] steps: - uses: actions/checkout@v4 @@ -30,11 +32,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install flake8 pytest tox + sudo apt install libpcap-dev - name: Lint with flake8 - run: | - flake8 pylibpcap + run: flake8 pylibpcap - name: Test with pytest run: | - pytest \ No newline at end of file + python -m pip install -e . + pytest . \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..aac82f6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,43 @@ +# @Author: jankincai +# @Date: 2024-09-12 10:45:37 +# @Last Modified by: jankincai +# @Last Modified time: 2024-09-12 17:18:27 + +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Tests + +on: + push: + branches: [ "master", "develop" ] + pull_request: + branches: [ "master", "develop" ] + +jobs: + build: + + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest tox + sudo apt install libpcap-dev + - name: Lint with flake8 + run: flake8 pylibpcap + - name: Run tox targets for ${{ matrix.python-version }} + run: python -m tox + # - name: Test with pytest + # run: | + # pytest . \ No newline at end of file diff --git a/setup.py b/setup.py index 168253c..f8c7dd6 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # @Author: JanKinCai # @Date: 2019-11-09 10:08:53 # @Last Modified by: jankincai -# @Last Modified time: 2024-09-12 10:31:22 +# @Last Modified time: 2024-09-14 10:04:08 import os import glob @@ -12,10 +12,6 @@ from Cython.Distutils import build_ext -with open('README.md') as f: - long_description = f.read() - - def read_requirements(path): """read requirements @@ -59,7 +55,7 @@ def read_requirements(path): setup( name="python-libpcap", - version="0.5.0", + version="0.5.1", author="JanKinCai", author_email="jankincai12@gmail.com", maintainer="JanKinCai", @@ -68,7 +64,8 @@ def read_requirements(path): download_url="https://github.com/caizhengxin/python-libpcap.git", license="BSD", description="Cython libpcap", - long_description=long_description, + long_description=open('README.md').read(), + long_description_content_type="text/markdown", keywords=[ "python-libpcap", "pylibpcap", diff --git a/tox.ini b/tox.ini index 76afc89..8d11f8b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py36, flake8 +envlist = py36, py37, py38, py39, py310, py311, py312, flake8 requires = Cython [testenv]