feat(release): add chocolatey publishing (#4637)

* feat(release): add chocolatey publishing

* change variable forwarding
This commit is contained in:
David Knaack
2022-11-25 17:19:03 +01:00
committed by GitHub
parent c221c43caa
commit df37e8d40c
5 changed files with 135 additions and 0 deletions
@@ -0,0 +1,22 @@
$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)'"
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>starship</id>
<title>Starship</title>
<version>0.0.0.1</version>
<authors>Starship Contributors</authors>
<owners>davidkna,saanuregh</owners>
<summary>The cross-shell prompt for astronauts</summary>
<description>
Starship is the minimal, blazing fast, and extremely customizable prompt for any shell!
Shows the information you need, while staying sleek and minimal.
</description>
<packageSourceUrl>https://github.com/starship/starship/tree/master/install/windows/choco</packageSourceUrl>
<projectUrl>https://starship.rs</projectUrl>
<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>
<licenseUrl>https://github.com/starship/starship/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes></releaseNotes>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
+57
View File
@@ -0,0 +1,57 @@
#!/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
$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"
$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
if (!(Test-Path "./tools")) {
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
choco pack ./starship.nuspec
if ($null -ne $Env:PUSH_TOKEN) {
choco push starship.$versionNumber.nupkg --key $ENV:PUSH_TOKEN
}
else {
Write-Host "No API key provided, skipping push"
}