From 6dbc3bcec4fc326a3af8a6502891f3856e6de36a Mon Sep 17 00:00:00 2001 From: "Dhruv Kanojia (Xonshiz)" Date: Sun, 10 Apr 2022 13:33:37 +0530 Subject: [PATCH] Moving from TravisCI to GitHub Actions TravisCI has been buddy and slow for quite some time now. It's time to switch to GitHub Actions. This PR contains 3 configs: - Checks the code every time a PR is raised. - Builds & releases distributables. - Packages and uploads to PyPI. Removing "Current Version :" text when printing `version` info because it's easier to use it as a release tag that way. --- .github/workflows/python-package.yml | 43 ++++++++++ .github/workflows/python-pr-check.yml | 37 +++++++++ .github/workflows/python-release.yml | 115 ++++++++++++++++++++++++++ comic_dl/comic_dl.py | 2 +- setup.py | 13 ++- 5 files changed, 202 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/python-package.yml create mode 100644 .github/workflows/python-pr-check.yml create mode 100644 .github/workflows/python-release.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..5c2032b --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,43 @@ +name: Publish Python distributions to PyPI and TestPyPI + +on: + push: + branches: [ master, main ] + + # Don't trigger if it's just a documentation update + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - '**.sh' + - 'docs/**' + - 'Dockerfile' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Initialize Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + cache: 'pip' + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Build Dist + run: | + python setup.py sdist + - name: Release On Main PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.MAIN_PYPI }} + skip_existing: true + verbose: true + print_hash: true \ No newline at end of file diff --git a/.github/workflows/python-pr-check.yml b/.github/workflows/python-pr-check.yml new file mode 100644 index 0000000..3611806 --- /dev/null +++ b/.github/workflows/python-pr-check.yml @@ -0,0 +1,37 @@ +name: Checking Pull Request + +on: + pull_request: + # Don't trigger if it's just a documentation/docker update. + # We have separate build for checking docker updates. + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - '**.sh' + - 'docs/**' + - 'Dockerfile' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' +jobs: + linux_job: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Stup Python + uses: actions/setup-python@v3 + with: + python-version: 3.9 + cache: 'pip' + - name: Install Dependencies + run: | + pip install -r requirements.txt + pip install pyinstaller + - name: Run CLI App + run: | + python cli.py --version + pyinstaller --onefile --hidden-import=queue "cli.py" -n "comic_dl_linux" + chmod +x dist/comic_dl_linux + dist/comic_dl_linux --version \ No newline at end of file diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml new file mode 100644 index 0000000..b3ab502 --- /dev/null +++ b/.github/workflows/python-release.yml @@ -0,0 +1,115 @@ +name: Building & Creating Distributables + +on: + push: + branches: [ master, main ] + + # Don't trigger if it's just a documentation update + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - '**.sh' + - 'docs/**' + - 'Dockerfile' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' + +jobs: + linux_job: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Initialize Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + cache: 'pip' + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pyinstaller + - name: Build Dist + run: | + python cli.py --version + pyinstaller --onefile --hidden-import=queue "cli.py" -n "comic_dl_linux" + chmod +x dist/comic_dl_linux + dist/comic_dl_linux --version + - name: Generate Release Tag + id: tag + run: | + echo "::set-output name=release_tag::$(dist/comic_dl_linux --version)" + echo Current Version ${{ steps.tag.outputs.release_tag }}. + - name: GH Release + uses: softprops/action-gh-release@v0.1.14 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.release_tag }} + files: dist/comic_dl_linux + windows_job: + runs-on: windows-latest + steps: + - uses: actions/checkout@v1 + - name: Initialize Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + cache: 'pip' + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pyinstaller + - name: Build Dist + run: | + python cli.py --version + pyinstaller --onefile --hidden-import=queue "cli.py" -n "comic_dl.exe" + dist/comic_dl.exe --version + - name: Generate Release Tag + id: tag + run: | + echo "::set-output name=release_tag::$(dist/comic_dl.exe --version)" + echo Current Version ${{ steps.tag.outputs.release_tag }}. + - name: GH Release + uses: softprops/action-gh-release@v0.1.14 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.release_tag }} + files: dist/comic_dl.exe + mac_os_job: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - name: Initialize Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + cache: 'pip' + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pyinstaller + - name: Build Dist + run: | + python cli.py --version + pyinstaller --onefile --hidden-import=queue "cli.py" -n "comic_dl_osx" + chmod +x dist/comic_dl_osx + dist/comic_dl_osx --version + - name: Generate Release Tag + id: tag + run: | + echo "::set-output name=release_tag::$(dist/comic_dl_osx --version)" + echo Current Version ${{ steps.tag.outputs.release_tag }}. + - name: GH Release + uses: softprops/action-gh-release@v0.1.14 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.release_tag }} + files: dist/comic_dl_osx \ No newline at end of file diff --git a/comic_dl/comic_dl.py b/comic_dl/comic_dl.py index d141723..263349a 100644 --- a/comic_dl/comic_dl.py +++ b/comic_dl/comic_dl.py @@ -309,5 +309,5 @@ def __init__(self, argv): @staticmethod def version(): - print("Current Version : %s" % __version__) + print(__version__) diff --git a/setup.py b/setup.py index 77a56fb..3cdecae 100644 --- a/setup.py +++ b/setup.py @@ -2,16 +2,13 @@ from comic_dl import __version__ -readme = open('ReadMe.md').read() -history = open('Changelog.md').read() - setuptools.setup( name='comic_dl', version=__version__.__version__, description='Comic-dl is a command line tool to download Comics and Manga from various Manga and Comic sites easily.', - long_description=readme + '\n\n' + history, + long_description='Comic-dl is a command line tool to download Comics and Manga from various Manga and Comic sites easily.', author='Xonshiz', - author_email='xonshiz@psychoticelites.com', + author_email='xonshiz@gmail.com', url='https://github.com/Xonshiz/comic-dl', packages=setuptools.find_packages(), keywords=['comic-dl', 'cli', 'comic downloader', 'manga downloader', 'mangafox', 'batoto', 'kissmanga', @@ -22,13 +19,15 @@ 'Intended Audience :: End Users/Desktop', 'License :: Public Domain', 'Natural Language :: English', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Operating System :: OS Independent', 'Topic :: Multimedia :: Graphics' ],