From dd64ef86eebe4f0034dc5afd8a14a181afa42ffd Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Mon, 10 May 2021 10:10:35 +0700 Subject: [PATCH] Update documentation --- .github/dependabot.yml | 14 +++++ .github/workflows/release.yml | 28 +++------- README.md | 96 ++++++++++++++++++++++++++++++++++- dependabot.yml | 14 ----- qgis_plugin_repo/merger.py | 3 +- 5 files changed, 116 insertions(+), 39 deletions(-) create mode 100644 .github/dependabot.yml delete mode 100644 dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..63b864e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + + - package-ecosystem: pip + directory: "/requirements" + schedule: + interval: monthly + time: "04:00" + timezone: Europe/Paris + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 511db1c..40e6c89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,6 @@ on: - master env: - # PROJECT_FOLDER: "qgis_plugin_repo" PYTHON_VERSION: 3.8 jobs: @@ -80,24 +79,9 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} allowUpdates: true artifacts: "dist/*.tar.gz" - # tag_name: ${{ github.ref }} - # release_name: ${{ github.ref }} - # body_path: release.md - -# - name: Deploy to PyPI -# uses: pypa/gh-action-pypi-publish@master -# with: -# user: __token__ -# password: ${{ secrets.PYPI_API_TOKEN }} - -# -# - name: Upload Release Asset -# id: upload-release-asset -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps -# asset_path: ./my-artifact.zip -# asset_name: my-artifact.zip -# asset_content_type: application/zip + + - name: Deploy to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/README.md b/README.md index 29ab8d7..a5ca4c2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,99 @@ -# QGIS-Plugin-Repo-Merge +# QGIS-Plugin-Repo + +[![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/) + +## Presentation Merge some QGIS plugin repository together ```bash -qgis-plugin-repo-merge all_plugins.xml https://path/to/plugins_to_add.xml +qgis-plugin-repo merge output_qgis_plugin_ci.xml all_plugins.xml +qgis-plugin-repo merge https://path/to/plugins_to_add.xml all_plugins.xml +``` + +The file `all_plugins.xml` will be edited, according to the plugin name, plugin +version and its experimental flag or not. In an XML file, the plugin can have +two versions : one experimental and the other one not. + +Additionally, you can read an XML file : +```bash +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. + +In the plugin repository, after [QGIS-Plugin-CI](https://github.com/opengisch/qgis-plugin-ci) : +```yml + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@v1 + with: + token: ${{ secrets.TOKEN }} + repository: organisation/repository + event-type: merge-plugins + client-payload: '{"name": "NAME_OF_PLUGIN", "version": "${{ env.RELEASE_VERSION }}", "url": "URL_OF_LATEST.xml"}' +``` + +In the main repository with a `docs/plugins.xml` to edit : +```yaml +name: 🔀 Plugin repository + +on: + repository_dispatch: + types: [merge-plugins] + +jobs: + merge: + runs-on: ubuntu-latest + steps: + - run: > + echo ${{ github.event.client_payload.name }} + echo ${{ github.event.client_payload.version }} + echo ${{ github.event.client_payload.url }} + + - name: Get source code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python 3.8 + uses: actions/setup-python@v2.2.1 + with: + python-version: 3.8 + + - name: Install qgis-plugin-repo + run: pip3 install qgis-plugin-repo + + - 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 + +``` + +### Tests + +```bash +python -m unittest ``` diff --git a/dependabot.yml b/dependabot.yml deleted file mode 100644 index 17ebe18..0000000 --- a/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -updates: - -# - package-ecosystem: pip -# directory: "/requirements" -# schedule: -# interval: monthly -# time: "04:00" -# timezone: Europe/Paris - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "monthly" diff --git a/qgis_plugin_repo/merger.py b/qgis_plugin_repo/merger.py index 58867b2..af9a8f4 100644 --- a/qgis_plugin_repo/merger.py +++ b/qgis_plugin_repo/merger.py @@ -141,6 +141,7 @@ def merge(self): self.output_parser.remove(element) print(f"Adding new version {plugin.name} {plugin.experimental} {plugin.version}") - self.output_parser.append(self.plugin_element(self.input_parser, plugin.name, plugin.experimental)) + self.output_parser.append( + self.plugin_element(self.input_parser, plugin.name, plugin.experimental)) self.output_tree.write(self.destination.absolute())