From c787b6a9e43992eade0e7aa348c82ad3ea559486 Mon Sep 17 00:00:00 2001
From: vbugaeva <vbugaeva@croc.ru>
Date: Wed, 11 Dec 2024 18:29:06 +0300
Subject: [PATCH] gha:  build and publish to PyPi

---
 .github/workflows/build-publish.yml | 55 +++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 .github/workflows/build-publish.yml

diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml
new file mode 100644
index 0000000..1789133
--- /dev/null
+++ b/.github/workflows/build-publish.yml
@@ -0,0 +1,55 @@
+name: Publish python distribution to PyPI
+
+on:
+  release:
+    types:
+      - published 
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Set up Python
+        uses: actions/setup-python@v5
+        with:
+          python-version: "3.9"
+
+      - name: Install Dependencies
+        run: |
+          python -m pip install --upgrade pip
+          python -m pip install setuptools wheel twine
+
+      - name: Build a binary wheel and a source tarball
+        run: |
+          python setup.py sdist bdist_wheel
+      
+      - name: Upload distributions
+        uses: actions/upload-artifact@v4
+        with:
+          name: "distributions-for-${{ github.event.release.tag_name }}"
+          path: dist/
+
+  publish-to-pypi:
+    name: Publish to PyPI
+    needs: build
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Download distributions
+        uses: actions/download-artifact@v4
+        with:
+          name: "distributions-for-${{ github.event.release.tag_name }}"
+          path: dist/
+
+      - name: Publish to PyPI
+        uses: pypa/gh-action-pypi-publish@release/v1
+        with:
+          username: __token__
+          repository-url: https://pypi.org/legacy/
+          password: ${{ secrets.PYPI_API_TOKEN }}
+