Explorar o código

Use Latest Release on GitHub Helper for checking for updates of AWS IAM Authenticator

Douglas Thrift hai 2 meses
pai
achega
ec65c878f8
Modificáronse 2 ficheiros con 6 adicións e 5 borrados
  1. 2 0
      .github/workflows/au.yml
  2. 4 5
      automatic/aws-iam-authenticator/update.ps1

+ 2 - 0
.github/workflows/au.yml

@@ -34,6 +34,8 @@ jobs:
         run: |
           git clone -q https://github.com/majkinetor/au.git $Env:TEMP/au
           . "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version
+      - name: Install Latest Release on GitHub Helper
+        run: choco install largh --yes
       - name: Check update for packages
         run: |
           $ErrorActionPreference = 'Continue'

+ 4 - 5
automatic/aws-iam-authenticator/update.ps1

@@ -1,12 +1,11 @@
 Import-Module au
 
-$latest_release = 'https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/latest'
+$repo = 'https://github.com/kubernetes-sigs/aws-iam-authenticator'
 
 function global:au_GetLatest {
-  $download_page = Invoke-WebRequest -Uri $latest_release -UseBasicParsing
-  $regex = '^.+/aws-iam-authenticator_(\d+\.\d+\.\d+)_windows_amd64\.exe$'
-  $url64 = "https://github.com$($download_page.Links | Where-Object href -Match $regex | Select-Object -First 1 -ExpandProperty href)"
-  $version = $url64 -replace $regex, '$1'
+  $release = Get-LatestReleaseOnGitHub -URL $repo -AccessToken $env:github_api_key
+  $version = $release.Tag.trim('v.')
+  $url64 = $release.Assets | Where-Object { $_.FileName -like '*_windows_amd64.exe' } | Select-Object -First 1 -ExpandProperty URL
   return @{ Version = $version; URL64 = $url64 }
 }