From 679b41e8b6cef2b3c0cfb69636428c06d5c03c6d Mon Sep 17 00:00:00 2001 From: Vladimir Babin Date: Tue, 21 Nov 2023 18:26:39 +0500 Subject: [PATCH] Add workflow to autopublish to pypi --- .github/workflows/pypi.yml | 59 +++++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 5 ++-- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..318e8dc --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,59 @@ +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI + +on: push + +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11"] + + steps: + - name: Install Poetry + uses: actions/checkout@v4 + run: pipx install poetry + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: "poetry" + + - name: Install dependencies + run: | + poetry config virtualenvs.in-project true + poetry install + + - name: Build a binary wheel and a source tarball + run: python -m build + + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/viz-python-lib + permissions: + id-token: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 381a2fa..cc6e0d4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,14 +10,15 @@ jobs: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v4 - name: Install Poetry + uses: actions/checkout@v4 run: pipx install poetry + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - cache: 'poetry' + cache: "poetry" - name: Install dependencies run: |