diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 06d44de..064680a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -35,16 +35,16 @@ jobs: ) $timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss' if ($Level -eq "ERROR") { - Write-Error "$timestamp [ERROR] - $Message" + Write-Host "$timestamp [ERROR] - $Message" -ForegroundColor Red } else { - Write-Host "$timestamp [$Level] - $Message" + Write-Host "$timestamp [$Level] - $Message" } } Set-ExecutionPolicy Bypass -Scope Process -Force [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 - $installs = @( + $deps = @( # @{ Name = 'Chocolatey'; Url = 'https://chocolatey.org/install.ps1'; Hash = $null; # Action = { & './install.ps1' }}, # @{ Name = 'Visual Studio 2022 Build Tools (aarch64)'; Hash = $null; Url = $null; @@ -63,38 +63,40 @@ jobs: Action = { & './Git-2.48.0-rc2-arm64.exe' /VERYSILENT }} ) - $installs | ForEach-Object { - if ($_.Url -ne $null) { - Log "Downloading $($_.Name) from $($_.Url)..." - $install_file = Join-Path '${{ github.workspace }}' (Split-Path $_.Url -Leaf) - Invoke-WebRequest -Uri $_.Url -OutFile $install_file + $deps | ForEach-Object { + $dep = $_ + if ($dep.Url -ne $null) { + Log "Downloading $($dep.Name) from $($dep.Url)..." + $install_file = Join-Path '${{ github.workspace }}' (Split-Path $dep.Url -Leaf) + Invoke-WebRequest -Uri $dep.Url -OutFile $install_file } - if ($_.Hash -ne $null) { - $expected_hash = if ($_.Hash -like "*.sha256") { - $hash_file = Join-Path '${{ github.workspace }}' (Split-Path $_.Hash -Leaf) - Invoke-WebRequest -Uri $_.Hash -OutFile $hash_file + if ($dep.Hash -ne $null) { + $expected_hash = if ($dep.Hash -like "*.sha256") { + $hash_file = Join-Path '${{ github.workspace }}' (Split-Path $dep.Hash -Leaf) + Invoke-WebRequest -Uri $dep.Hash -OutFile $hash_file (Get-Content -Path $hash_file).Trim() } else { - $_.Hash + $dep.Hash } $downloaded_hash = (Get-FileHash -Path $install_file -Algorithm SHA256).Hash if ($downloaded_hash -eq $expected_hash) { Log "Hash verified successfully." } else { - Log "Hash mismatch for $($_.Name). Expected: $expected_hash, Got: $downloaded_hash" -Level "ERROR" + Log "Hash mismatch for $($dep.Name). Expected: $expected_hash, Got: $downloaded_hash" -Level "ERROR" } } else { Log "No hash specified, skipping verification." } - Log "Starting installation of $($_.Name)..." + Log "Starting installation of $($dep.Name)..." try { - & $_.Action - Log "$($_.Name) installation completed." + & $dep.Action + Log "$($dep.Name) installation completed." } catch { - Log "Failed to install $($_.Name)" -Level "ERROR" + Log "An error occurred while installing $($dep.Name): $_" "ERROR" + Log "Error Details: $($_.Exception.Message)" "ERROR" } }