Skip to content

Instantly share code, notes, and snippets.

@Announcement
Created July 31, 2024 11:07
Show Gist options
  • Save Announcement/f2d2dbdab109bbaeb79684f5c4dcd7b7 to your computer and use it in GitHub Desktop.
Save Announcement/f2d2dbdab109bbaeb79684f5c4dcd7b7 to your computer and use it in GitHub Desktop.
package update scripts
gh -R aria2/aria2 release download -p '*win-64*'
# https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_windows-x64_bin.zip
# https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_windows-x64_bin.zip
# https://download.oracle.com/graalvm/22/latest/graalvm-jdk-22_windows-x64_bin.zip
# https://download.oracle.com/java/17/latest/jdk-17_windows-x64_bin.zip
# https://download.oracle.com/java/21/latest/jdk-21_windows-x64_bin.zip
# https://download.oracle.com/java/22/latest/jdk-22_windows-x64_bin.zip
# function Update-Java {
# [CmdletBinding()]
# param (
# [switch]$GraalVM,
# [ValidateSet(17,21,22)]
# [int]$version
# )
# begin {
# $root = $graalvm ? "graalvm/${version}/latest" : "java/${version}/latest"
# # $filename = "$($graalvm ? 'graalvm-' : '')jdk-${version}_windows-x64_bin.zip"
# $url = "https://download.oracle.com/$root/$($graalvm ? 'graalvm-' : '')jdk-${version}_windows-x64_bin.zip"
# }
# process {
# Invoke-WebRequest $url -Destination "$($graalvm ? 'graalvm' : 'jdk')-$version.zip"
# Expand-Archive "$($graalvm ? 'graalvm' : 'jdk')-$version.zip" -DestinationPath "$($graalvm ? 'graalvm' : 'jdk')/$version"
# }
# end {
# Remove-Item "$($graalvm ? 'graalvm' : 'jdk')-$version.zip"
# }
# }
# Update-Java 17
# Update-Java 21
# Update-Java 22
# Update-Java -GraalVM 17
# Update-Java -GraalVM 21
# Update-Java -GraalVM 22
# New-Item -ItemType Junction -Path "$env:APPDATA\Package\version\java\stable" -Value "$env:APPDATA\Package\version\java\jdk\17"
# New-Item -ItemType Junction -Path "$env:APPDATA\Package\version\java\latest" -Value "$env:APPDATA\Package\version\java\graalvm\21"
# # https://download.oracle.com/graalvm/22/latest/graalvm-jdk-22_windows-x64_bin.zip
# # https://download.oracle.com/java/22/latest/jdk-22_windows-x64_bin.zip
# # if (-not (Test-Path $env:APPDATA\Package\version\PowerShell\$powershellStable)) {
# # gh -R powershell/powershell release download "v$powershellStable" -p '*-win-x64.zip'
# # $powershellStableArchive = "*$powershellStable*.zip" | Resolve-Path
# # $powershellStableArchive | Expand-Archive -Destination $env:APPDATA\Package\version\PowerShell\$powershellStable
# # $powershellStableArchive | Remove-Item
# # if (Test-Path $env:APPDATA\Package\version\PowerShell\stable) {
# # Remove-Item $env:APPDATA\Package\version\PowerShell\stable
# # }
# # New-Item -ItemType Junction -Path "$env:APPDATA\Package\version\PowerShell\stable" -Value "$env:APPDATA\Package\version\PowerShell\$powershellStable"
# # }
# # if (-not (Test-Path $env:APPDATA\Package\version\PowerShell\$powershellLatest)) {
# # gh -R powershell/powershell release download "v$powershellLatest" -p '*-win-x64.zip'
# # $powershellLatestArchive = "*$powershellLatest*.zip" | Resolve-Path
# # $powershellLatestArchive | Expand-Archive -Destination $env:APPDATA\Package\version\PowerShell\$powershellLatest
# # $powershellLatestArchive | Remove-Item
# # if (Test-Path $env:APPDATA\Package\version\PowerShell\latest) {
# # Remove-Item $env:APPDATA\Package\version\PowerShell\latest
# # }
# # New-Item -ItemType Junction -Path "$env:APPDATA\Package\version\PowerShell\latest" -Value "$env:APPDATA\Package\version\PowerShell\$powershellLatest"
# # }
# # # $powershellLatest,$powershellStable=gh -R powershell/powershell release list --json createdAt,isPrerelease,tagName -q 'sort_by(.createdAt) | [map(select(.isPrerelease)),.] | .[].[-1].tagName[1:]'
# # # if (-not (Test-Path $env:APPDATA\Package\version\PowerShell\$powershellStable)) {
# # # gh -R powershell/powershell release download "v$powershellStable" -p '*-win-x64.zip'
# # # $powershellStableArchive = "*$powershellStable*.zip" | Resolve-Path
# # # $powershellStableArchive | Expand-Archive -Destination $env:APPDATA\Package\version\PowerShell\$powershellStable
# # # $powershellStableArchive | Remove-Item
# # # if (Test-Path $env:APPDATA\Package\version\PowerShell\stable) {
# # # Remove-Item $env:APPDATA\Package\version\PowerShell\stable
# # # }
# # # New-Item -ItemType Junction -Path "$env:APPDATA\Package\version\PowerShell\stable" -Value "$env:APPDATA\Package\version\PowerShell\$powershellStable"
# # # }
# # # if (-not (Test-Path $env:APPDATA\Package\version\PowerShell\$powershellLatest)) {
# # # gh -R powershell/powershell release download "v$powershellLatest" -p '*-win-x64.zip'
# # # $powershellLatestArchive = "*$powershellLatest*.zip" | Resolve-Path
# # # $powershellLatestArchive | Expand-Archive -Destination $env:APPDATA\Package\version\PowerShell\$powershellLatest
# # # $powershellLatestArchive | Remove-Item
# # # if (Test-Path $env:APPDATA\Package\version\PowerShell\latest) {
# # # Remove-Item $env:APPDATA\Package\version\PowerShell\latest
# # # }
# # # New-Item -ItemType Junction -Path "$env:APPDATA\Package\version\PowerShell\latest" -Value "$env:APPDATA\Package\version\PowerShell\$powershellLatest"
# # # }
$powershellLatest,$powershellStable=gh -R powershell/powershell release list --json createdAt,isPrerelease,tagName -q 'sort_by(.createdAt) | [map(select(.isPrerelease)),.] | .[].[-1].tagName[1:]'
if (-not (Test-Path $env:APPDATA\Package\version\PowerShell\$powershellStable)) {
gh -R powershell/powershell release download "v$powershellStable" -p '*-win-x64.zip'
$powershellStableArchive = "*$powershellStable*.zip" | Resolve-Path
$powershellStableArchive | Expand-Archive -Destination $env:APPDATA\Package\version\PowerShell\$powershellStable
$powershellStableArchive | Remove-Item
if (Test-Path $env:APPDATA\Package\version\PowerShell\stable) {
Remove-Item $env:APPDATA\Package\version\PowerShell\stable
}
New-Item -ItemType Junction -Path "$env:APPDATA\Package\version\PowerShell\stable" -Value "$env:APPDATA\Package\version\PowerShell\$powershellStable"
}
if (-not (Test-Path $env:APPDATA\Package\version\PowerShell\$powershellLatest)) {
gh -R powershell/powershell release download "v$powershellLatest" -p '*-win-x64.zip'
$powershellLatestArchive = "*$powershellLatest*.zip" | Resolve-Path
$powershellLatestArchive | Expand-Archive -Destination $env:APPDATA\Package\version\PowerShell\$powershellLatest
$powershellLatestArchive | Remove-Item
if (Test-Path $env:APPDATA\Package\version\PowerShell\latest) {
Remove-Item $env:APPDATA\Package\version\PowerShell\latest
}
New-Item -ItemType Junction -Path "$env:APPDATA\Package\version\PowerShell\latest" -Value "$env:APPDATA\Package\version\PowerShell\$powershellLatest"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment