diff --git a/.github/workflows/update_compat_db.yml b/.github/workflows/update_compat_db.yml index 8299fc3..b83c2e4 100644 --- a/.github/workflows/update_compat_db.yml +++ b/.github/workflows/update_compat_db.yml @@ -19,6 +19,8 @@ jobs: $headers = @{ Authorization = "Token ${{ secrets.GITHUB_TOKEN }}" } + + # 1. Get the latest issue information $compat_link = "https://api.github.com/repos/Vita3K/compatibility" $issues_link = $compat_link + "/issues" $app_updated = (Invoke-RestMethod -Uri $issues_link"?state=all&sort=updated" -Headers $headers)[0] @@ -26,11 +28,15 @@ jobs: $db_updated_at_old = [DateTime]::Parse($app_updated.updated_at).ToUniversalTime().ToString("MM-dd-yyyy HH:mm:ss", [System.Globalization.CultureInfo]::InvariantCulture) # Do not delete this line for keep compatibility $open_issues_count = (Invoke-RestMethod -Uri "$compat_link" -Headers $headers).open_issues_count $page_count = @() + + # 2. Get count of retrieval open_issues_count for ($i = 0; $i -lt $open_issues_count; $i += 100) { $page = [Math]::Floor($i / 100) + 1 $per_page = [Math]::Min($open_issues_count - $i, 100) $page_count += New-Object PSObject -Property @{First=$page; Second=$per_page} } + + # 3. Initialize XML document $xml = New-Object System.Xml.XmlDocument $xml.AppendChild($xml.CreateXmlDeclaration("1.0", "UTF-8", $null)) | Out-Null $xml.AppendChild($xml.CreateComment("This file is automatically generated by a GitHub action. Do not edit it manually.")) | Out-Null @@ -40,6 +46,8 @@ jobs: $root.SetAttribute("version", "1") $xml.AppendChild($root) | Out-Null $issue_count = 0 + + # 4. Retrieve issue information foreach ($page in $page_count) { $current_page = $page.First $per_page = $page.Second @@ -72,6 +80,8 @@ jobs: $issue_count++ } } + + # 5. Construct XML nodes $root.SetAttribute("issue_count", $issue_count) $xml.Save("app_compat_db.xml") "$issue_count issues have been retrieved from the compatibility database" @@ -85,7 +95,7 @@ jobs: - name: Zip compatibility database run: | - Compress-Archive -Path app_compat_db.xml -DestinationPath app_compat_db.xml.zip + 7z a -mx=9 app_compat_db.xml.zip app_compat_db.xml # 7z a -mx=9 app_compat_db.xml.7z app_compat_db.xml - name: Prepare files for release diff --git a/README.md b/README.md index 4d49d9d..72a70af 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # compatibility + +![download counter](https://img.shields.io/github/downloads/Vita3K/compatibility/latest/total) + #### [Commercial game compatibility database for Vita3K.](https://github.com/Vita3K/compatibility/issues) ---