Guts / qgis-deployment-cli

Cross-platform (but focused on Windows) CLI to perform deployment operations: profiles, plugins, etc.
https://guts.github.io/qgis-deployment-cli/
Apache License 2.0
14 stars 2 forks source link

[Feature Request]: Get installed QGIS versions #273

Open Guts opened 1 year ago

Guts commented 1 year ago

Context

When creating shortcuts, QDT needs to know the location of the QGIS executable to point to.

Currently, this is done by defining the QDT_QGIS_EXE_PATH environment variable, then fallbacking to searching with which or then a hard-coded value corresponding to the default path of the latest LTR official msi installer.

Description

Add a new job to find a QGIS installed version to use:

Expected logic

  1. retrieve published versions of QGIS with dates and type (LTR, normal...) calling the Github API to list tags on qgis/qgis
  2. integrate this in the form of a sub-command (qdt check-installed-qgis) for example, which outputs a structured file (with associated JSON schema)
    • this file is embedded into the packaging during the CI (for offline use)
    • this file is published in the documentation (this may be useful to others)
    • if not, dynamic calls can be made from the internal code
  3. the sub-command compares the published and installed versions:
    • predefined environment variable (to allow admins to specify the version officially supported by the IS)
    • registry (winreg) for Windows
    • known paths: C:\OSGeo4W64, etc.
    • :warning: manage access rights errors, in particular the listing on %PROGRAMFILES%: execution in non-admin mode by default
    • for linux, there's less effort to be made a priori, which is sufficient in most cases

Sample job configuration:

Not contractual.

- name: Find installed QGIS
  uses: qgis-installation-finder
  with:
    versions_priority:
      - !ENV["QDT_QGIS_PREFERRED_VERSION", "ltr"]
      - 3.28
      - 3.30
    if_not_found: error

Sample structured list

Not contractual.

{
    "updated": "2023-05-29 12:35:00",
    "published_versions": [
        {
            "major": "3",
            "minor": "28",
            "potential_ltr": true,
            "supported_until": "2024-02-10 00:00:00",
            "patches": [
                {
                    "patch": "6",
                    "published": "2023-05-29 01:00:00",
                    "type": "ltr"
                },
                {
                    "patch": "5",
                    "published": "2023-04-29 01:00:00",
                    "type": "ltr"
                },
                [...]
                {
                    "patch": "0",
                    "published": "2022-10-14 01:00:00",
                    "type": "regular"
                }
            ]
        },
        {
            "major": "3",
            "minor": "30",
            "potential_ltr": false,
            "supported_until": "2023-08-10 00:00:00",
            "patches": [
                {
                    "patch": "2",
                    "published": "2023-05-29 01:00:00",
                    "type": "regular"
                }
            ]
        }
    ]
}

Related links

Use Cases

In Windows, there are often multiple versions installed. It could help to avoid requiring an environment variable to be set

Impacted jobs:

Visuals

No response

Before submitting

Guts commented 4 months ago

Partly implemented by @jmkerloch in #464 and released in https://github.com/Guts/qgis-deployment-cli/releases/tag/0.33.0