Skip to content

Commit

Permalink
implemented searching for the filename specified in the settings.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsPilgaard committed Sep 2, 2022
1 parent bfebdb7 commit 5af0387
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions modpack-uploader.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,21 @@ function Get-GitHubRelease {
$file
)

$releases = "https://api.github.com/repos/$repo/releases"
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases"

Write-Host "Determining latest release of $repo"
$tag = (Invoke-WebRequest -Uri $releases -UseBasicParsing | ConvertFrom-Json)[0].tag_name
$matchingRelease = $response.assets -match $file
if ($matchingRelease) {
$downloadUrl = $matchingRelease.browser_download_url

Remove-Item $file -ErrorAction SilentlyContinue

$download = "https://github.com/$repo/releases/download/$tag/$file"
Write-Host "Dowloading $file..."

Write-Host "Dowloading..."
Invoke-WebRequest $download -Out $file
Invoke-RestMethod $downloadUrl -Out $file
}
else {
Write-Error "Found no files matching '$file' in the repository '$repo'"
}
}

function Test-ForDependencies {
Expand Down

0 comments on commit 5af0387

Please sign in to comment.