Skip to content

Commit

Permalink
Update the CI and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Jun 10, 2021
1 parent 09f9e94 commit 7393837
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 45 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run tests and release
name: 🧪 Tests

on:
push:
Expand Down Expand Up @@ -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:
Expand Down
37 changes: 15 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
```
43 changes: 43 additions & 0 deletions qgis_plugin_repo/__about__.py
Original file line number Diff line number Diff line change
@@ -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(".")
]
)
File renamed without changes.
55 changes: 37 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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]
),
Expand Down

0 comments on commit 7393837

Please sign in to comment.