From 5831c432a9cf948377907fa1aab750d76e45f052 Mon Sep 17 00:00:00 2001 From: Evgeny Prilepin Date: Thu, 10 Apr 2025 23:22:57 +0100 Subject: [PATCH] build: add pipeline for publishing the package to PyPI --- .github/workflows/pypi.yaml | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/pypi.yaml diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml new file mode 100644 index 0000000..3f35378 --- /dev/null +++ b/.github/workflows/pypi.yaml @@ -0,0 +1,63 @@ +name: Publish to PyPI + +on: workflow_dispatch + +permissions: + actions: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout project + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install Poetry + uses: abatilo/actions-poetry@v4 + with: + poetry-version: "1.8.5" + + - name: Setup a local virtual environment + run: | + poetry config virtualenvs.create true --local + poetry config virtualenvs.in-project true --local + + - name: Define a cache for the virtual environment based on the dependencies lock file + uses: actions/cache@v4 + with: + path: ./.venv + key: venv-${{ hashFiles('poetry.lock') }} + + - name: Build + run: poetry build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: csaps-packages + path: dist/* + overwrite: true + + upload: + name: Upload to PyPI + needs: [ build ] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/csaps + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v4 + with: + name: csaps-packages + path: dist + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1