diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..cbcdbf6 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,57 @@ +name: Publish to PyPI.org +on: + release: + types: [published] + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build sdist + run: pipx run build --sdist ${{github.workspace}}/python/ + - name: Move sdist to dist + run: mkdir -p dist && mv ${{github.workspace}}/python/dist/*.tar.gz dist/ + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + cibuildwheel: + name: Build wheels on ${{ matrix.os }} + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Build wheels + if: github.event_name == 'release' + uses: pypa/cibuildwheel@v2.16.5 + with: + package-dir: ${{github.workspace}}/python/ + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + pypi: + if: github.event_name == 'release' + needs: [cibuildwheel, build_sdist] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + + + diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index 1fcdb2e..0000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python application - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - pip install python/ - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index 92074cd..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,39 +0,0 @@ -# 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.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build python/ - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..1f8767f --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,23 @@ +name: Python API +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + python_package: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + steps: + - uses: actions/checkout@v3 + - name: Set up Python3 + uses: actions/setup-python@v3 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + - name: Build pip package + run: | + python -m pip install --verbose ./python/