Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacrlevin committed Dec 27, 2023
1 parent 5985300 commit da8ad57
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/Deploy_Desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
DOTNET_NOLOGO: true
BuildConfiguration: Release
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GitHubReleaseUrl: https://github.com/isaacrlevin/presencelight/releases/download/Desktop-
Win10RID: net8.0-windows10.0.19041

steps:
Expand Down Expand Up @@ -106,7 +105,6 @@ jobs:
DOTNET_NOLOGO: true
BuildConfiguration: Release
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GitHubReleaseUrl: https://github.com/isaacrlevin/presencelight/releases/download/Desktop-
Win10RID: net8.0-windows10.0.19041

steps:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/Deploy_Web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
DOTNET_NOLOGO: true
BuildConfiguration: Release
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GitHubReleaseUrl: https://github.com/isaacrlevin/presencelight/releases/download/Web-

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -104,7 +103,6 @@ jobs:
DOTNET_NOLOGO: true
BuildConfiguration: Release
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GitHubReleaseUrl: https://github.com/isaacrlevin/presencelight/releases/download/Web-

steps:

Expand Down
59 changes: 41 additions & 18 deletions Build/scripts/hash-files.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,63 @@ Param
$Version
)

$GitHubReleaseUrl = "https://github.com/isaacrlevin/presencelight/releases/download/Desktop-"
# Get the latest release from GitHub
$github = Invoke-RestMethod -uri "https://api.github.com/repos/isaacrlevin/presencelight/releases"

Write-Host "Version: ${Version}"
Write-Host "Url: ${GitHubReleaseUrl}"
$targetRelease = $github | Where-Object -Property name -match "Desktop-v$Version" | Select-Object -First 1


# Hash the Zip Files
mkdir .\Download
$fileNames = (, "x86", "x64", "win-arm64")

# Get the Hashes from the GitHub Release and save them to files
$hashUrls = $targetRelease | Select-Object -ExpandProperty assets -First 1 | Where-Object -Property name -match '.*?.zip.sha256' | Select-Object -ExpandProperty browser_download_url

Invoke-WebRequest -Uri "${GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-x86.zip.sha256" -OutFile ".\Download\x86-zip.sha256"
Invoke-WebRequest -Uri "${GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-x64.zip.sha256" -OutFile ".\Download\x64-zip.sha256"
Invoke-WebRequest -Uri "${GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-win.arm64.zip.sha256" -OutFile ".\Download\win-arm64-zip.sha256"
foreach ($url in $hashUrls) {
foreach ($fileName in $fileNames) {
if ($url -like "*$fileName*") {
$filePath = ".\Download\$fileName.zip.sha256"
Invoke-WebRequest -Uri $url -OutFile $filePath
break
}
}
}

$hash86 = get-content ".\Download\x86-zip.sha256"
$hash64 = get-content ".\Download\x64-zip.sha256"
$hashARM = get-content ".\Download\win-arm64-zip.sha256"

# Update ChocolateyInstall.ps1
# Update ChocolateyInstall.ps1 with Hashes
$installFile = Get-Content -path ".\Chocolatey\tools\ChocolateyInstall.ps1" -Raw
$installFile = $installFile -replace '{ReplaceCheckSumARM}', $hashARM
$installFile = $installFile -replace '{ReplaceCheckSumx86}', $hash86
$installFile = $installFile -replace '{ReplaceCheckSumx64}', $hash64
$installFile = $installFile -replace '{ARMLink}' , "${GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-win-arm64.zip"
$installFile = $installFile -replace '{x86Link}' , "$GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-x86.zip"
$installFile = $installFile -replace '{x64Link}' , "${GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-x64.zip"
$installFile | Set-Content -Path ".\Chocolatey\tools\ChocolateyInstall.ps1"

# Update Verification.txt
# Update Verification.txt with Hashes
$verificationFile = Get-Content -path ".\Chocolatey\tools\Verification.txt"
$verificationFile = $verificationFile -replace '{ARMLink}' , "${GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-win-arm64.zip"
$verificationFile = $verificationFile -replace '{x64Link}' , "${GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-x64.zip"
$verificationFile = $verificationFile -replace '{x86Link}' , "${GitHubReleaseUrl}v${Version}/PresenceLight.${Version}-x86.zip"
$verificationFile = $verificationFile -replace '{HASHx64}', $hash64
$verificationFile = $verificationFile -replace '{HASHx86}', $hash86
$verificationFile = $verificationFile -replace '{HASHARM}', $hashARM
$verificationFile | Set-Content -Path ".\Chocolatey\tools\Verification.txt"

# Get the Download Urls for the Zip files and update ChocolateyInstall.ps1 and Verification.txt with Urls
$zipUrls = $targetRelease | Select-Object -ExpandProperty assets | Where-Object { $_.name -like '*.zip' } | Select-Object -ExpandProperty browser_download_url

foreach ($url in $zipUrls) {
if ($url -like "*x64*") {
$installFile = $installFile -replace '{x64Link}' , $url
$verificationFile = $verificationFile -replace '{x64Link}' , $url
}
if ($url -like "*x86*") {
$installFile = $installFile -replace '{x86Link}' , $url
$verificationFile = $verificationFile -replace '{x86Link}' , $url
}
if ($url -like "*arm64*") {
$installFile = $installFile -replace '{ARMLink}' , $url
$verificationFile = $verificationFile -replace '{ARMLink}' , $url
}
}

# Save the updated files
$verificationFile | Set-Content -Path ".\Chocolatey\tools\Verification.txt"
$installFile | Set-Content -Path ".\Chocolatey\tools\ChocolateyInstall.ps1"


5 changes: 4 additions & 1 deletion Build/winget/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ function Get-Hash {
[string]
$Version
)
$hash = (new-object Net.WebClient).DownloadString("https://github.com/isaacrlevin/presencelight/releases/download/Desktop-v$Version/PresenceLight.Package_$Version.0_x64_x86_ARM64.appxbundle.sha256")
$github = Invoke-RestMethod -uri "https://api.github.com/repos/microsoft/devhome/releases"
$targetRelease = $github | Where-Object -Property name -match "Desktop-v$Version" | Select-Object -First 1
$hashUrl = $targetRelease | Select-Object -ExpandProperty assets -First 1 | Where-Object -Property name -match '.*?.appxbundle.sha256' | Select-Object -ExpandProperty browser_download_url
$hash = (new-object Net.WebClient).DownloadString($hashUrl)
return $hash
}

Expand Down

0 comments on commit da8ad57

Please sign in to comment.