From cdddc9681acf3cdbae83625f434a239c397cc906 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Wed, 21 Feb 2024 10:07:30 +0100 Subject: [PATCH] ci: Generate Python package --- .github/workflows/github-actions.yml | 47 ++++++++++++++++++++++++++++ ci/generate-python-package.sh | 3 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 50235ae1..1d0ba3dd 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -21,3 +21,50 @@ jobs: - uses: actions/checkout@v2 - run: sudo apt install libbluetooth-dev - run: mkdir build && pushd build && cmake -DGATTLIB_FORCE_DBUS=TRUE -DCMAKE_BUILD_TYPE=Release .. && make + + generate-python-binary-packages: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v2 + - run: sudo apt install -y libbluetooth-dev + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - run: ./ci/generate-python-package.sh + - name: Archive Python packages + uses: actions/upload-artifact@v4 + with: + name: python-${{ matrix.python-version }}-binary-package + path: dist/* + + # publish-python-packages: + # needs: + # - generate-python-binary-packages + # runs-on: ubuntu-latest + # steps: + # - uses: actions/download-artifact@master + # - run: ls * + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - generate-python-binary-packages + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/gattlib-py # Replace with your PyPI project name + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - uses: actions/download-artifact@master + - run: ls * + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ \ No newline at end of file diff --git a/ci/generate-python-package.sh b/ci/generate-python-package.sh index 217f8625..8cbac500 100755 --- a/ci/generate-python-package.sh +++ b/ci/generate-python-package.sh @@ -41,12 +41,13 @@ pushd ${gattlib_py_package_dir} # Binary package python3 setup.py bdist_wheel + # Source package python setup.py sdist # Move generated artifact to project root path ls dist/* -mv dist/* ${ROOT_PATH} +mv dist ${ROOT_PATH} popd