diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 363efe2..5f95346 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Run tests and release +name: 🧪 Tests on: push: @@ -64,15 +64,12 @@ jobs: VERSION=${GITHUB_REF:-0.0.0} VERSION=${VERSION##*/} sed -i "s/__VERSION__/${VERSION}/g" setup.py + sed -i "s/__VERSION__/${VERSION}/g" qgis_plugin_repo/__about__.py - name: Build package run: | python setup.py sdist - - name: Debug - run: | - ls -al dist - - name: Create release on GitHub uses: ncipollo/release-action@v1.8.6 with: diff --git a/README.md b/README.md index a5ca4c2..cdcfc50 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # QGIS-Plugin-Repo +[![🧪 Tests](https://github.com/3liz/qgis-plugin-repo/actions/workflows/release.yml/badge.svg)](https://github.com/3liz/qgis-plugin-repo/actions/workflows/release.yml) [![PyPi version badge](https://badgen.net/pypi/v/qgis-plugin-repo)](https://pypi.org/project/qgis-plugin-repo/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/qgis-plugin-repo)](https://pypi.org/project/qgis-plugin-repo/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/qgis-plugin-repo)](https://pypi.org/project/qgis-plugin-repo/) @@ -24,7 +25,7 @@ qgis-plugin-repo read https://plugins.qgis.org/plugins/plugins.xml?qgis=3.10 ## GitHub Actions -The main puprose of this tool is to run on CI. +The main purpose of this tool is to run on CI. In the plugin repository, after [QGIS-Plugin-CI](https://github.com/opengisch/qgis-plugin-ci) : ```yml @@ -37,6 +38,9 @@ In the plugin repository, after [QGIS-Plugin-CI](https://github.com/opengisch/qg client-payload: '{"name": "NAME_OF_PLUGIN", "version": "${{ env.RELEASE_VERSION }}", "url": "URL_OF_LATEST.xml"}' ``` +**Note** that QGIS-Plugin-CI `package` or `release` must be been called with `--create-plugin-repo` because this +tool will use the XML file generated. + In the main repository with a `docs/plugins.xml` to edit : ```yaml name: 🔀 Plugin repository @@ -58,9 +62,10 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 + token: ${{ secrets.BOT_HUB_TOKEN }} # Important to launch CI on a commit from a bot - name: Set up Python 3.8 - uses: actions/setup-python@v2.2.1 + uses: actions/setup-python@v2.2.2 with: python-version: 3.8 @@ -70,30 +75,18 @@ jobs: - name: Merge run: qgis-plugin-repo merge ${{ github.event.client_payload.url }} docs/plugins.xml - - name: Git identity - run: | - git config --global user.email "${{ secrets.BOT_MAIL }}" - git config --global user.name "${{ secrets.BOT_NAME }}" - - - name: Check for changes - run: | - if git diff --exit-code; then - echo "changes_exist=false" >> $GITHUB_ENV - else - echo "changes_exist=true" >> $GITHUB_ENV - fi - - - name: Commit and push - if: env.changes_exist == 'true' - run: | - git add -u - git commit -m "Publish QGIS Plugin ${{ github.event.client_payload.name }} ${{ github.event.client_payload.version }}" - git push --force https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git HEAD:versions - + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Publish QGIS Plugin ${{ github.event.client_payload.name }} ${{ github.event.client_payload.version }}" + commit_user_name: ${{ secrets.BOT_NAME }} + commit_user_email: ${{ secrets.BOT_MAIL }} + commit_author: ${{ secrets.BOT_NAME }} ``` ### Tests ```bash +cd tests python -m unittest ``` diff --git a/qgis_plugin_repo/__about__.py b/qgis_plugin_repo/__about__.py new file mode 100644 index 0000000..68b8fde --- /dev/null +++ b/qgis_plugin_repo/__about__.py @@ -0,0 +1,43 @@ +""" +Metadata about the package to easily retrieve information about it. +See: https://packaging.python.org/guides/single-sourcing-package-version/ +""" + +from datetime import date + +__all__ = [ + "__author__", + "__copyright__", + "__email__", + "__license__", + "__summary__", + "__title__", + "__title_clean__", + "__uri__", + "__version__", + "__version_info__", +] + +__author__ = "Étienne Trimaille" +__copyright__ = "2021 - {0}, {1}".format(date.today().year, __author__) +__email__ = "etrimaille@3liz.com" +__license__ = "GNU General Public License v3.0" +__summary__ = "Tool for merging XML files from QGIS-Plugin-CI." +__title__ = "QGIS Plugin Repo" +__title_clean__ = "".join(e for e in __title__ if e.isalnum()) +__uri__ = "https://github.com/3liz/qgis-plugin-repo" + +# This string might be updated on CI on runtime with a proper semantic version name with X.Y.Z +__version__ = "__VERSION__" + +if "." not in __version__: + # If __version__ is still not a proper semantic versioning with X.Y.Z + # let's hardcode 0.0.0 + __version__ = "0.0.0" + +__version_info__ = tuple( + [ + int(num) if num.isdigit() else num + for num in __version__.replace("-", ".", 1).split(".") + ] +) diff --git a/qgis_plugin_repo/cli.py b/qgis_plugin_repo/__main__.py similarity index 100% rename from qgis_plugin_repo/cli.py rename to qgis_plugin_repo/__main__.py diff --git a/setup.py b/setup.py index 1a2667e..452ee1a 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,12 @@ -import os import sys +from pathlib import Path from setuptools import setup -__copyright__ = 'Copyright 2021, 3Liz' -__license__ = 'GPL version 3' -__email__ = 'info@3liz.org' +from qgis_plugin_repo import __about__ python_min_version = (3, 7) -if os.getenv('CI') == 'true': - VERSION = "__VERSION__" -else: - VERSION = "0.0.0" - if sys.version_info < python_min_version: sys.exit( "qgis-plugin-repo requires at least Python version {vmaj}.{vmin}.\n" @@ -22,25 +15,51 @@ ) ) +# This string might be updated on CI on runtime with a proper semantic version name with X.Y.Z +VERSION = "__VERSION__" + +if "." not in VERSION: + # If VERSION is still not a proper semantic versioning with X.Y.Z + # let's hardcode 0.0.0 + VERSION = "0.0.0" + +read_me = Path(__file__).parent.joinpath("README.md").read_text() + setup( name="qgis-plugin-repo", + author=__about__.__author__, + author_email=__about__.__email__, + description=__about__.__summary__, packages=["qgis_plugin_repo"], - entry_points={"console_scripts": ["qgis-plugin-repo = qgis_plugin_repo.cli:main"]}, + long_description=read_me, + long_description_content_type="text/markdown", + url=__about__.__uri__, + entry_points={"console_scripts": ["qgis-plugin-repo = qgis_plugin_repo.__main__:main"]}, version=VERSION, - description="Manipulate a QGIS Plugin repository.", - author="Etienne Trimaille", - author_email="etrimaille@3liz.com", - # url="https://github.com/opengisch/qgis-plugin-ci", - # download_url="https://github.com/opengisch/qgis-plugin-ci/archive/{}.tar.gz".format(VERSION), + project_urls={ + "Docs": __about__.__uri__, + "Bug Reports": "{}issues/".format(__about__.__uri__), + "Source": __about__.__uri__, + }, + download_url="https://github.com/3liz/qgis-plugin-repo/archive/{}.tar.gz".format( + VERSION + ), keywords=["QGIS"], classifiers=[ - "Topic :: Scientific/Engineering :: GIS", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Development Status :: 5 - Production/Stable", "Intended Audience :: System Administrators", + "Intended Audience :: Developers", "Intended Audience :: Information Technology", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Scientific/Engineering :: GIS", ], install_requires=["requests"], - # extra_require=dict(tests=['pytest']), python_requires=">={vmaj}.{vmin}".format( vmaj=python_min_version[0], vmin=python_min_version[1] ),