2022-11-25 17:19:03 +01:00
|
|
|
|
#!/usr/bin/env pwsh
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
Set-StrictMode -Version 3.0
|
|
|
|
|
|
|
|
|
|
if ($null -eq $ENV:STARSHIP_VERSION) {
|
|
|
|
|
Write-Host "Version is required"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$version = "$ENV:STARSHIP_VERSION"
|
|
|
|
|
$versionNumber = $version.TrimStart("v")
|
|
|
|
|
|
|
|
|
|
[xml]$nuspec_file = Get-Content -Path ./install/windows/choco/starship.nuspec
|
|
|
|
|
$nuspec_file.package.metadata.version = $versionNumber
|
|
|
|
|
|
|
|
|
|
$changelog = (Get-Content -Path ./CHANGELOG.md | Out-String)
|
|
|
|
|
$nuspec_file.package.metadata.releaseNotes = $changelog
|
|
|
|
|
|
2023-02-28 06:03:32 +01:00
|
|
|
|
# Create variant nuspec files
|
|
|
|
|
$nuspec_file.package.metadata.id = "starship.portable"
|
|
|
|
|
$nuspec_file.Save("./starship.portable.nuspec")
|
|
|
|
|
|
|
|
|
|
$nuspec_file.package.metadata.id = "starship.install"
|
|
|
|
|
$nuspec_file.Save("./starship.install.nuspec")
|
|
|
|
|
|
|
|
|
|
# Have metapackage depend on starship.install
|
|
|
|
|
$nuspec_file.package.metadata.id = "starship"
|
2023-04-12 20:38:33 +02:00
|
|
|
|
|
|
|
|
|
$deps = $nuspec_file.createelement("dependencies")
|
2023-02-28 06:03:32 +01:00
|
|
|
|
$dep = $nuspec_file.createelement("dependency")
|
|
|
|
|
$dep.SetAttribute("id", "starship.install")
|
|
|
|
|
$dep.SetAttribute("version", "[$versionNumber]")
|
2023-04-12 20:38:33 +02:00
|
|
|
|
$deps.AppendChild($dep)
|
|
|
|
|
$nuspec_file.package.metadata.AppendChild($deps)
|
2022-11-25 17:19:03 +01:00
|
|
|
|
$nuspec_file.Save("./starship.nuspec")
|
|
|
|
|
|
|
|
|
|
$url_x86_64_zip = "https://github.com/starship/starship/releases/download/$version/starship-x86_64-pc-windows-msvc.zip"
|
|
|
|
|
$url_i686_zip = "https://github.com/starship/starship/releases/download/$version/starship-i686-pc-windows-msvc.zip"
|
2023-02-28 06:03:32 +01:00
|
|
|
|
$url_x86_64_msi = "https://github.com/starship/starship/releases/download/$version/starship-x86_64-pc-windows-msvc.msi"
|
|
|
|
|
$url_i686_msi = "https://github.com/starship/starship/releases/download/$version/starship-i686-pc-windows-msvc.msi"
|
2022-11-25 17:19:03 +01:00
|
|
|
|
|
2023-02-28 06:03:32 +01:00
|
|
|
|
$checksum_x86_64_zip = Get-FileHash -Algorithm SHA256 -Path "./starship-x86_64-pc-windows-msvc.zip/starship-x86_64-pc-windows-msvc.zip" | Select-Object -ExpandProperty Hash
|
|
|
|
|
$checksum_i686_zip = Get-FileHash -Algorithm SHA256 -Path "./starship-i686-pc-windows-msvc.zip/starship-i686-pc-windows-msvc.zip" | Select-Object -ExpandProperty Hash
|
|
|
|
|
$checksum_x86_64_msi = Get-FileHash -Algorithm SHA256 -Path "./starship-x86_64-pc-windows-msvc.msi/starship-x86_64-pc-windows-msvc.msi" | Select-Object -ExpandProperty Hash
|
|
|
|
|
$checksum_i686_msi = Get-FileHash -Algorithm SHA256 -Path "./starship-i686-pc-windows-msvc.msi/starship-i686-pc-windows-msvc.msi" | Select-Object -ExpandProperty Hash
|
2022-11-25 17:19:03 +01:00
|
|
|
|
|
2023-02-28 06:03:32 +01:00
|
|
|
|
if (Test-Path "./tools") {
|
|
|
|
|
Remove-Item -Path "./tools" -Recurse -Force
|
2022-11-25 17:19:03 +01:00
|
|
|
|
}
|
2023-02-28 06:03:32 +01:00
|
|
|
|
New-Item -ItemType Directory -Path "./tools"
|
2022-11-25 17:19:03 +01:00
|
|
|
|
|
2023-02-28 06:03:32 +01:00
|
|
|
|
# Pack the metapackage as-is without install script
|
2022-11-25 17:19:03 +01:00
|
|
|
|
choco pack ./starship.nuspec
|
|
|
|
|
|
2023-02-28 06:03:32 +01:00
|
|
|
|
foreach ($install_type in @('portable', 'install')) {
|
|
|
|
|
Get-Content ./install/windows/choco/chocolateyInstall.$install_type.ps1 | ForEach-Object {
|
|
|
|
|
if ($_ -match '^\$url_x86_64_zip = (.*)') {
|
|
|
|
|
"`$url_x86_64_zip = '$url_x86_64_zip'"
|
|
|
|
|
}
|
|
|
|
|
elseif ($_ -match '^\$url_i686_zip = (.*)') {
|
|
|
|
|
"`$url_i686_zip = '$url_i686_zip'"
|
|
|
|
|
}
|
|
|
|
|
elseif ($_ -match '^\$url_x86_64_msi = (.*)') {
|
|
|
|
|
"`$url_x86_64_msi = '$url_x86_64_msi'"
|
|
|
|
|
}
|
|
|
|
|
elseif ($_ -match '^\$url_i686_msi = (.*)') {
|
|
|
|
|
"`$url_i686_msi = '$url_i686_msi'"
|
|
|
|
|
}
|
|
|
|
|
elseif ($_ -match '^\$checksum_x86_64_zip = (.*)') {
|
|
|
|
|
"`$checksum_x86_64_zip = '$checksum_x86_64_zip'"
|
|
|
|
|
}
|
|
|
|
|
elseif ($_ -match '^\$checksum_i686_zip = (.*)') {
|
|
|
|
|
"`$checksum_i686_zip = '$checksum_i686_zip'"
|
|
|
|
|
}
|
|
|
|
|
elseif ($_ -match '^\$checksum_x86_64_msi = (.*)') {
|
|
|
|
|
"`$checksum_x86_64_msi = '$checksum_x86_64_msi'"
|
|
|
|
|
}
|
|
|
|
|
elseif ($_ -match '^\$checksum_i686_msi = (.*)') {
|
|
|
|
|
"`$checksum_i686_msi = '$checksum_i686_msi'"
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$_
|
|
|
|
|
}
|
|
|
|
|
} | Set-Content ./tools/chocolateyInstall.ps1
|
|
|
|
|
|
|
|
|
|
choco pack ./starship.$install_type.nuspec
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($null -ne $ENV:PUSH_TOKEN) {
|
|
|
|
|
choco push starship.portable.$versionNumber.nupkg --key $ENV:PUSH_TOKEN
|
|
|
|
|
choco push starship.install.$versionNumber.nupkg --key $ENV:PUSH_TOKEN
|
|
|
|
|
choco push starship.$versionNumber.nupkg --key $ENV:PUSH_TOKEN
|
2022-11-25 17:19:03 +01:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Write-Host "No API key provided, skipping push"
|
|
|
|
|
}
|