From 500081e999ccb3bcf39099fc40c626da64401846 Mon Sep 17 00:00:00 2001 From: Aliwoto Date: Tue, 24 Dec 2024 21:19:01 +0330 Subject: [PATCH] Add PyPi release github workflow. Signed-off-by: Aliwoto --- .github/workflows/pypi_release.yml | 67 ++++++++++++++++++++++++++++++ setup.py | 10 ++--- 2 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pypi_release.yml diff --git a/.github/workflows/pypi_release.yml b/.github/workflows/pypi_release.yml new file mode 100644 index 0000000000..2cfe684bbc --- /dev/null +++ b/.github/workflows/pypi_release.yml @@ -0,0 +1,67 @@ +on: + push: + branches: [ Production ] + +permissions: write-all + +jobs: + build-n-publish: + name: Build and publish to PyPI + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Build source and wheel distributions + run: | + python -m pip install --upgrade build twine + python -m build + make venv + make api + twine check --strict dist/Kurigram* + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + - name: Set the Version + run: | + grep_result=$(grep version pyrogram/__init__.py) + prefix="__version__ = \"" + suffix="\"" + final_value=${grep_result#"$prefix"} + final_value=${final_value%"$suffix"} + echo "CURRENT_LIB_VERSION=$(echo 'v'$final_value)" >> $GITHUB_ENV + - name: Create GitHub Release + id: create_release + uses: elgohr/Github-Release-Action@v5 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag: ${{ env.CURRENT_LIB_VERSION }} + title: ${{ env.CURRENT_LIB_VERSION }} + # draft: false + prerelease: false + + - name: Get Asset name + run: | + export PKG=$(ls dist/ | grep tar) + set -- $PKG + echo "name=$1" >> $GITHUB_ENV + - name: Upload Release Asset (sdist) to GitHub + id: upload-release-asset + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # upload_url: ${{ steps.create_release.outputs.upload_url }} + tag_name: ${{ env.CURRENT_LIB_VERSION }} + files: dist/${{ env.name }} + # asset_name: ${{ env.name }} + # asset_content_type: application/zip \ No newline at end of file diff --git a/setup.py b/setup.py index 52477e37d9..b6d16a3dd7 100644 --- a/setup.py +++ b/setup.py @@ -38,13 +38,13 @@ errors_compiler.start() setup( - name="Pyrogram", + name="Kurigram", version=version, description="Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots", long_description=readme, long_description_content_type="text/markdown", - url="https://github.com/pyrogram", - download_url="https://github.com/pyrogram/pyrogram/releases/latest", + url="https://github.com/KurimuzonAkuma/pyrogram", + download_url="https://github.com/KurimuzonAkuma/pyrogram/releases/latest", author="Dan", author_email="dan@pyrogram.org", license="LGPLv3", @@ -74,9 +74,9 @@ ], keywords="telegram chat messenger mtproto api client library python", project_urls={ - "Tracker": "https://github.com/pyrogram/pyrogram/issues", + "Tracker": "https://github.com/KurimuzonAkuma/pyrogram/issues", "Community": "https://t.me/pyrogram", - "Source": "https://github.com/pyrogram/pyrogram", + "Source": "https://github.com/KurimuzonAkuma/pyrogram", "Documentation": "https://docs.pyrogram.org", }, python_requires="~=3.8",