summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Knaack <davidkna@users.noreply.github.com>2023-02-28 06:03:32 +0100
committerGitHub <noreply@github.com>2023-02-27 23:03:32 -0600
commitb55774d3a68b32c0ed17983adeb6355e75c65f6b (patch)
treeb1810eccbcbac4204fe38c077dbf168a8c5e3100
parente51f25572a0d5559a662437a01cd629863386f1e (diff)
feat(release): handle chocolatey starship.portable and starship.install pkg publishing (#4723)
Handles starship.install (MSI installer) and starship.portable and makes starship an empty meta-package that only depends on starship.install. MSI/installer packages seem to be preferred over zip-based installers on chocolatey. Proper virtual packages that allow choosing either a portable or install variant aren't implemented in chocolatey yet.
-rw-r--r--.github/workflows/workflow.yml10
-rw-r--r--install/windows/choco/chocolateyInstall.install.ps125
-rw-r--r--install/windows/choco/chocolateyInstall.portable.ps124
-rw-r--r--install/windows/choco/chocolateyInstall.ps122
-rw-r--r--install/windows/choco/starship.nuspec5
-rw-r--r--install/windows/choco/update.ps185
6 files changed, 120 insertions, 51 deletions
diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml
index 0f27774f7..8894faba2 100644
--- a/.github/workflows/workflow.yml
+++ b/.github/workflows/workflow.yml
@@ -230,10 +230,12 @@ jobs:
if: matrix.os == 'windows-latest' && matrix.rust == 'stable'
run: |
# Setup dummy release artifacts
- New-Item -ItemType Directory -Path ./starship-x86_64-pc-windows-msvc
- New-Item -ItemType Directory -Path ./starship-i686-pc-windows-msvc
- New-Item -ItemType File -Path ./starship-x86_64-pc-windows-msvc/starship-x86_64-pc-windows-msvc.zip
- New-Item -ItemType File -Path ./starship-i686-pc-windows-msvc/starship-i686-pc-windows-msvc.zip
+ foreach ($arch in @("aarch64", "i686", "x86_64")) {
+ foreach ($ext in @("zip", "msi")) {
+ New-Item -ItemType Directory -Path ./starship-$arch-pc-windows-msvc.$ext
+ New-Item -ItemType File -Path ./starship-$arch-pc-windows-msvc.$ext/starship-$arch-pc-windows-msvc.$ext
+ }
+ }
# Build package
pwsh ./install/windows/choco/update.ps1
env:
diff --git a/install/windows/choco/chocolateyInstall.install.ps1 b/install/windows/choco/chocolateyInstall.install.ps1
new file mode 100644
index 000000000..01dfb775c
--- /dev/null
+++ b/install/windows/choco/chocolateyInstall.install.ps1
@@ -0,0 +1,25 @@
+$ErrorActionPreference = 'Stop'
+
+$packageName = $env:ChocolateyPackageName
+
+$url_x86_64_msi = ''
+$url_i686_msi = ''
+$checksum_x86_64_msi = ''
+$checksum_i686_msi = ''
+
+$packageArgs = @{
+ packageName = $packageName
+ fileType = 'msi'
+ url = $url_i686_msi
+ url64bit = $url_x86_64_msi
+ checksum = $checksum_i686_msi
+ checksum64 = $checksum_x86_64_msi
+ checksumType = 'sha256'
+ softwareName = 'starship*'
+ silentArgs = "/qn /norestart /l*v `"$($env:TEMP)\$($packageName).$($env:chocolateyPackageVersion).MsiInstall.log`""
+ validExitCodes = @(0, 3010, 1641)
+}
+Install-ChocolateyPackage @packageArgs
+
+# Add to Profile
+Write-Host "Add the following to the end of ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 'Invoke-Expression (&starship init powershell)'"
diff --git a/install/windows/choco/chocolateyInstall.portable.ps1 b/install/windows/choco/chocolateyInstall.portable.ps1
new file mode 100644
index 000000000..21f0d9d5f
--- /dev/null
+++ b/install/windows/choco/chocolateyInstall.portable.ps1
@@ -0,0 +1,24 @@
+$ErrorActionPreference = 'Stop'
+
+$packageName = $env:ChocolateyPackageName
+
+$url_x86_64_zip = ''
+$url_i686_zip = ''
+$checksum_x86_64_zip = ''
+$checksum_i686_zip = ''
+
+$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
+$packageArgs = @{
+ packageName = $packageName
+ fileType = 'zip'
+ url = $url_i686_zip
+ url64bit = $url_x86_64_zip
+ checksum = $checksum_i686_zip
+ checksum64 = $checksum_x86_64_zip
+ checksumType = 'sha256'
+ unzipLocation = $toolsDir
+}
+Install-ChocolateyZipPackage @packageArgs
+
+# Add to Profile
+Write-Host "Add the following to the end of ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 'Invoke-Expression (&starship init powershell)'"
diff --git a/install/windows/choco/chocolateyInstall.ps1 b/install/windows/choco/chocolateyInstall.ps1
deleted file mode 100644
index a20e4deba..000000000
--- a/install/windows/choco/chocolateyInstall.ps1
+++ /dev/null
@@ -1,22 +0,0 @@
-$ErrorActionPreference = 'Stop'
-
-$packageName = 'starship'
-
-$url_x86_64_zip = ''
-$url_i686_zip = ''
-$checksum_x86_64_zip = ''
-$checksum_i686_zip = ''
-
-$checksumType = 'sha256'
-$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
-
-Install-ChocolateyZipPackage -PackageName "$packageName" `
- -Url "$url_i686_zip" `
- -Url64 "$url_x86_64_zip" `
- -UnzipLocation "$toolsDir" `
- -Checksum "$checksum_i686_zip" `
- -Checksum64 "$checksum_x86_64_zip" `
- -ChecksumType "$checksumType"
-
-# Add to Profile
-Write-Host "Add the following to the end of ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 'Invoke-Expression (&starship init powershell)'"
diff --git a/install/windows/choco/starship.nuspec b/install/windows/choco/starship.nuspec
index ddbb26947..b9473cf84 100644
--- a/install/windows/choco/starship.nuspec
+++ b/install/windows/choco/starship.nuspec
@@ -16,10 +16,13 @@
<projectSourceUrl>https://github.com/starship/starship</projectSourceUrl>
<iconUrl>https://starship.rs/icon.png</iconUrl>
<tags>powershell prompt starship pwsh</tags>
- <copyright>© 2022 Starship Contributors</copyright>
+ <copyright>© 2023 Starship Contributors</copyright>
<licenseUrl>https://github.com/starship/starship/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes></releaseNotes>
+ <dependencies>
+ <dependency id="chocolatey" version="0.9.9" />
+ </dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
diff --git a/install/windows/choco/update.ps1 b/install/windows/choco/update.ps1
index 539228554..66c2862f2 100644
--- a/install/windows/choco/update.ps1
+++ b/install/windows/choco/update.ps1
@@ -17,40 +17,77 @@ $nuspec_file.package.metadata.version = $versionNumber
$changelog = (Get-Content -Path ./CHANGELOG.md | Out-String)
$nuspec_file.package.metadata.releaseNotes = $changelog
+# 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"
+$dep = $nuspec_file.createelement("dependency")
+$dep.SetAttribute("id", "starship.install")
+$dep.SetAttribute("version", "[$versionNumber]")
+$nuspec_file.package.metadata.dependencies.AppendChild($dep)
$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"
+$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"
-$checksum_x86_64_zip = Get-FileHash -Algorithm SHA256 -Path "./starship-x86_64-pc-windows-msvc/starship-x86_64-pc-windows-msvc.zip" | Select-Object -ExpandProperty Hash
-$checksum_i686_zip = Get-FileHash -Algorithm SHA256 -Path "./starship-i686-pc-windows-msvc/starship-i686-pc-windows-msvc.zip" | Select-Object -ExpandProperty Hash
+$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
-if (!(Test-Path "./tools")) {
- New-Item -ItemType Directory -Path "./tools"
+if (Test-Path "./tools") {
+ Remove-Item -Path "./tools" -Recurse -Force
}
+New-Item -ItemType Directory -Path "./tools"
-Get-Content ./install/windows/choco/chocolateyInstall.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 '^\$checksum_x86_64_zip = (.*)') {
- "`$checksum_x86_64_zip = '$checksum_x86_64_zip'"
- }
- elseif ($_ -match '^\$checksum_i686_zip = (.*)') {
- "`$checksum_i686_zip = '$checksum_i686_zip'"
- }
- else {
- $_
- }
-} | Set-Content ./tools/chocolateyInstall.ps1
-
+# Pack the metapackage as-is without install script
choco pack ./starship.nuspec
-if ($null -ne $Env:PUSH_TOKEN) {
- choco push starship.$versionNumber.nupkg --key $ENV:PUSH_TOKEN
+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
}
else {
Write-Host "No API key provided, skipping push"