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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 135 additions and 0 deletions

View File

@ -323,6 +323,21 @@ jobs:
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
./wingetcreate.exe update Starship.Starship -s -v $version -u $env:URL_64 $env:URL_32 -t ${{ secrets.GH_PAT }} ./wingetcreate.exe update Starship.Starship -s -v $version -u $env:URL_64 $env:URL_32 -t ${{ secrets.GH_PAT }}
choco_update:
name: Update Chocolatey Package
runs-on: windows-latest
needs: [release_please, github_build, upload_artifacts]
if: ${{ needs.release_please.outputs.release_created == 'true' }}
steps:
- name: Setup | Checkout
uses: actions/checkout@v3
- name: Setup | Artifacts
uses: actions/download-artifact@v3
- run: pwsh ./install/windows/choco/update.ps1
env:
STARSHIP_VERSION: ${{ needs.release_please.outputs.tag_name }}
PUSH_TOKEN: ${{ secrets.CHOCO_TOKEN }}
merge_crowdin_pr: merge_crowdin_pr:
name: Merge Crowdin PR name: Merge Crowdin PR
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -227,6 +227,20 @@ jobs:
command: wix command: wix
args: --dbg-build -v --nocapture -I install/windows/main.wxs args: --dbg-build -v --nocapture -I install/windows/main.wxs
- name: Build | Chocolatey Package [Windows]
continue-on-error: true
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
# Build package
pwsh ./install/windows/choco/update.ps1
env:
STARSHIP_VERSION: v1.2.3
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
if: github.repository == 'starship/starship' if: github.repository == 'starship/starship'

View File

@ -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)'"

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>

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"
}