QGIS/.github/workflows/check-user-reported-qgis-version.yml
dependabot[bot] 8db817fc99
Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-02 10:31:38 +00:00

107 lines
4.4 KiB
YAML

name: Check if user is running the latest version of QGIS
on:
issues:
types: [opened]
env:
# Extract issue body
ISSUE_BODY: ${{ github.event.issue.body }}
jobs:
check_version_reported:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Get version details
run: |
python ./scripts/get_latest_qgis_versions.py --release="stable" --github_token=${{ secrets.GITHUB_TOKEN }} >> $GITHUB_ENV
- name: Write comment
uses: actions/github-script@v7
with:
script: |
const {ISSUE_BODY, QGIS_VERSION_LTR_PATCH, QGIS_VERSION_STABLE_PATCH} = process.env // Latest released version identified using get_latest_qgis_versions
compareSemanticVersions = (version1, version2) => {
// Returns -1 if version1 < version2
// Returns 1 if version1 > version2
// Returns 0 if version1 = version2
// Assume parameters are string and follow the semantic version : major.minor.patch
var version1 = version1.split(".").map(x => parseInt(x))
var version2 = version2.split(".").map(x => parseInt(x))
//Major version
if ( version1[0] < version2[0] ){
return -1
}
else if ( version1[0] > version2[0] ) {
return 1
}
//Minor version2
if ( version1[1] < version2[1] ){
return -1
}
else if ( version1[1] > version2[1] ) {
return 1
}
//Patch version
if ( version1[2] < version2[2] ){
return -1
}
else if ( version1[2] > version2[2] ) {
return 1
}
return 0
}
// Match qgis version reported e.g : "3.40.0-Bratislava"
// More example here : https://regex101.com/r/jvHJAf/2
var regex = /QGIS [Vv]ersion(?:: | \| )(\d)\.(\d{2})\.(\d*)-[A-Z][a-z]+/
var m = ISSUE_BODY.match(regex)
if ( !m ){
console.log("Debug: No version identified in the body")
return
}
major_version = m[1]
minor_version = m[2]
patch_version = m[3]
user_version = `${major_version}.${minor_version}.${patch_version}`
if ( compareSemanticVersions(user_version, QGIS_VERSION_LTR_PATCH) === -1 ) {
console.log("Debug: Suggest user to try latest LTR release")
let comment = `Thanks for reporting, however it looks like you are using an older version of QGIS (version ${user_version}) instead of latest (Version ${QGIS_VERSION_LTR_PATCH}). Your bug could already be resolved in the latest version. \nIt takes a lot of human effort to triage all the bugs in a project like QGIS, could you please retry with the latest version first?`
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
}
else if ( compareSemanticVersions(user_version, QGIS_VERSION_LTR_PATCH) === 0 ) {
console.log("Debug: user is already running latest LTR version")
}
else if ( compareSemanticVersions(user_version, QGIS_VERSION_STABLE_PATCH) === -1 ) {
console.log("Debug: Suggest user to try latest release")
let comment = `Thanks for reporting, however it looks like you are using an older version of QGIS (version ${user_version}) instead of latest (Version ${QGIS_VERSION_STABLE_PATCH}). Your bug could already be resolved in the latest version. \nIt takes a lot of human effort to triage all the bugs in a project like QGIS, could you please retry with the latest version first?`
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
}
else {
console.log("Debug: pass, the user is running a supported version so do nothing")
}