Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(autohotkey) Fix AutoHotkey version retrieval #2599

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions automatic/autohotkey.install/update.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Import-Module Chocolatey-AU

$releases = 'https://autohotkey.com/download/2.0'
$v1Version = '1.1.36.02'
$v1Filename = "AutoHotkey_$($v1Version)_setup.exe"

Expand Down Expand Up @@ -44,8 +43,9 @@ function global:au_BeforeUpdate {
}

function global:au_GetLatest {
$version = Invoke-WebRequest -Uri "$releases\version.txt" -UseBasicParsing | ForEach-Object Content
robmoss2k marked this conversation as resolved.
Show resolved Hide resolved
$url = "https://github.com/AutoHotkey/AutoHotkey/releases/download/v$($version)/AutoHotkey_$($version)_setup.exe"
$releaseInformation = Invoke-RestMethod -Uri 'https://api.github.com/repos/AutoHotkey/AutoHotKey/releases'
$version = $releaseInformation[0].tag_name -replace 'v'
$url = ($releaseInformation[0].assets | Where-Object -Property name -Like '*.exe').browser_download_url
@{
Version = $version
URL = $url
Expand Down
26 changes: 9 additions & 17 deletions automatic/autohotkey.portable/update.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Import-Module Chocolatey-AU

$releases = 'https://autohotkey.com/download'

function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
Expand All @@ -27,22 +25,16 @@ function global:au_BeforeUpdate {
}

function global:au_GetLatest {
$version_page = Invoke-WebRequest -Uri $releases -UseBasicParsing

$urls = $version_page.Links | Where-Object href -match "^[\d\.]+\/$" | Where-Object href -NotMatch "1\.0" | ForEach-Object href

$version_page = Invoke-RestMethod -Uri 'https://api.github.com/repos/AutoHotkey/AutoHotKey/releases'
Write-Output "Got $($version_page.Count) versions"
$streams = @{}
$urls | ForEach-Object {
$releasesUrl = "$releases/$_"
$versionWithHash = Invoke-WebRequest -Uri "$releasesUrl/version.txt" -UseBasicParsing | ForEach-Object Content
$version = $versionWithHash -replace '(\d+.\d+-\w+)-\w+', '$1'
$version = $version -replace '(-\w+)\.', '$1'
if (!$version) { $version = $versionWithHash }

$url = "$releasesUrl/AutoHotkey_${versionWithHash}.zip"

$key = $releasesUrl -split '\/' | Select-Object -last 1 -Skip 1
if (!$streams.ContainsKey($key)) {
$version_page | Where-Object -Property tag_name -Like 'v2.*' | ForEach-Object {
$key = $_.tag_name
$version = $key -replace 'v'
Write-Output "Processing version $($version)"
if ($version -like '1.*') { continue }
$url = ($_.assets | Where-Object -Property name -Like '*.zip').browser_download_url
if ($null -ne $url -and !$streams.ContainsKey($key)) {
$streams.Add($key, @{
Version = $version
URL = $url
Expand Down