From 684645683ccd9dd68d1c7c789cd3914a725c0640 Mon Sep 17 00:00:00 2001 From: Vladimir <18351400+en9inerd@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:11:17 -0400 Subject: [PATCH] fix: fix ga workflow --- .github/workflows/publish_release.yml | 40 +++++++++++++++++++++++++-- pyproject.toml | 7 ++++- setup.cfg | 3 -- tgeraser/__main__.py | 2 +- tgeraser/core.py | 11 ++++++-- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index b2cb0e1..3d8a5a0 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -9,14 +9,48 @@ jobs: release: runs-on: ubuntu-latest concurrency: release + permissions: + id-token: write + contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + + # This action uses Python Semantic Release v8 - name: Python Semantic Release - uses: relekang/python-semantic-release@master + id: release + uses: python-semantic-release/python-semantic-release@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build a binary wheel and a source tarball + run: python3 -m build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + # NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true. + # See https://github.com/actions/runner/issues/1173 + if: steps.release.outputs.released == 'true' + + - name: Publish package distributions to GitHub Releases + uses: python-semantic-release/upload-to-gh-release@main + if: steps.release.outputs.released == 'true' with: github_token: ${{ secrets.GITHUB_TOKEN }} - pypi_token: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 07de284..76b1e69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,8 @@ [build-system] requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" + +[tool.semantic_release] +version_variables = [ + "tgeraser/__version__.py:VERSION", +] diff --git a/setup.cfg b/setup.cfg index cfcd09b..1c7e14a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,6 +36,3 @@ exclude = tests [options.entry_points] console_scripts = tgeraser = tgeraser.core:entry - -[semantic_release] -version_variable = tgeraser/__version__.py:VERSION diff --git a/tgeraser/__main__.py b/tgeraser/__main__.py index cfea484..1efeedb 100644 --- a/tgeraser/__main__.py +++ b/tgeraser/__main__.py @@ -6,4 +6,4 @@ from . import core if __name__ == "__main__": - asyncio.run(core.entry()) + asyncio.run(core.main()) diff --git a/tgeraser/core.py b/tgeraser/core.py index ae10faa..eaf77f3 100644 --- a/tgeraser/core.py +++ b/tgeraser/core.py @@ -39,7 +39,7 @@ from .utils import cast_to_int, get_credentials -async def entry() -> None: +async def main() -> None: """ Entry function """ @@ -105,5 +105,12 @@ async def entry() -> None: raise TgEraserException(err) from err +def entry() -> None: + """ + Entry point function + """ + asyncio.run(main()) + + if __name__ == "__main__": - asyncio.run(entry()) + entry()