Created
November 6, 2023 10:43
-
-
Save gsw945/7a201bfb53f8a783b41258d125423e49 to your computer and use it in GitHub Desktop.
pocketpy-branchs&sha256.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[Parameter(Mandatory=$true)][string]$BaseDir | |
) | |
# remove end Directory Separator Char | |
$BaseDir = $BaseDir.Trim('"', "'").TrimEnd([IO.Path]::DirectorySeparatorChar) | |
Write-Host "BaseDir: [${BaseDir}]" | |
Set-Location -Path $BaseDir | |
$ApiUrl = 'https://api.github.com/repos/blueloveTH/pocketpy/releases' | |
if (-not (Test-Path -Path "./blueloveTH-pocketpy-releases.json" -PathType Leaf)) { | |
Invoke-webRequest -Uri $ApiUrl -OutFile 'blueloveTH-pocketpy-releases.json' -Proxy 'socks5://127.0.0.1:7890' | |
# test proxy | |
# Invoke-RestMethod -Uri 'https://checkip.amazonaws.com/' | |
# Invoke-RestMethod -Uri 'https://checkip.amazonaws.com/' -Proxy 'socks5://127.0.0.1:7890' | |
} else { | |
$cacheFolder = './cache' | |
$releases = (Get-Content -Path './blueloveTH-pocketpy-releases.json' -Encoding utf8 | ConvertFrom-Json) | |
$releases | ForEach-Object { | |
$Version = $_.name | |
# Write-Host "-----$($Version)-----" | |
$targetFolder = [System.IO.Path]::GetFullPath((Join-Path $cacheFolder $Version)) | |
[System.IO.Directory]::CreateDirectory($targetFolder) | |
$_.assets | ForEach-Object { | |
if (@('main.cpp', 'pocketpy.h').Contains($_.name)) { | |
$FileUrl = $_.browser_download_url | |
$FileName = $_.name | |
$FileTarget = (Join-Path $targetFolder $FileName) | |
# Write-Host " $($FileName)" | |
if (-not (Test-Path -Path $FileTarget -PathType Leaf)) { | |
Invoke-webRequest -Uri $FileUrl -OutFile $FileTarget -Proxy 'socks5://127.0.0.1:7890' | |
} else { | |
$sha256 = (Get-FileHash -Algorithm SHA256 $FileTarget).Hash.ToLower() | |
# Write-Host " $($sha256)" | |
if ('pocketpy.h' -eq $FileName) { | |
Write-Host "add_versions(`"$($Version)`", `"$($sha256)`")" | |
} | |
} | |
} | |
} | Out-Null | |
} | Out-Null | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call pwsh -NoProfile -ExecutionPolicy Bypass -File "%~dp0pocketpy-branchs-sha256.ps1" -BaseDir '%~dp0' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note for upgrade pocketpy version