feat: winget support

This commit is contained in:
Jan De Dobbeleer 2021-01-29 19:50:11 +01:00 committed by Jan De Dobbeleer
parent 8ef355db4c
commit c8ef9edc77
6 changed files with 215 additions and 3 deletions

View file

@ -237,6 +237,8 @@ jobs:
needs: [release, artifacts]
if: ${{ needs.release.outputs.skipped == 'false' }}
runs-on: windows-latest
outputs:
hash: ${{ steps.hash.outputs.hash_inno }}
defaults:
run:
shell: pwsh
@ -246,6 +248,11 @@ jobs:
uses: actions/checkout@v2
- name: Build installer
run: ./build.ps1 -Version ${{ needs.release.outputs.version }}
- name: Output Hash
id: hash
run: |
$hash = Get-Content -Path Output/install.exe.sha256
Write-Output "::set-output name=hash_inno::$($hash)"
- name: Upload Inno Installer
id: upload-inno-installer
uses: actions/upload-release-asset@v1
@ -266,3 +273,18 @@ jobs:
asset_path: ${{ github.workspace }}/packages/inno/Output/install.exe.sha256
asset_name: install.exe.sha256
asset_content_type: text/plain
winget:
needs: [release, inno]
if: ${{ needs.release.outputs.skipped == 'false' }}
runs-on: windows-latest
defaults:
run:
shell: pwsh
working-directory: ${{ github.workspace }}/packages/winget
env:
WINGETCREATE_TOKEN: ${{ secrets.WINGETCREATE_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create manifest and submit PR
run: ./build.ps1 -Version ${{ needs.release.outputs.version }} -Hash ${{ needs.inno.outputs.hash }} -Token $env:WINGETCREATE_TOKEN

View file

@ -16,6 +16,33 @@ While Oh my Posh works on the standard terminal, we advise using the [Windows Te
### Installation
<Tabs
defaultValue="winget"
groupId="install"
values={[
{ label: 'winget', value: 'winget', },
{ label: 'scoop', value: 'scoop', },
]
}>
<TabItem value="winget">
```powershell
winget install JanDeDobbeleer.OhMyPosh
```
This installs a couple of things:
- `oh-my-posh.exe` - Windows executable, added to your `$PATH`
- `oh-my-posh-wsl` - Linux executable, added to your `$PATH` for use in the WSL
- `themes` - The latest Oh my Posh themes
If you want to use a standard theme, you can find them in `~\AppData\Local\Programs\oh-my-posh\themes\`,
referencing them as such
will always keep them compatible with the binary when updating Oh my Posh.
</TabItem>
<TabItem value="scoop">
```powershell
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json
```
@ -30,12 +57,27 @@ If you want to use a standard theme, you can find them in `~\scoop\apps\oh-my-po
referencing them as such
will always keep them compatible with the binary when updating Oh my Posh.
</TabItem>
</Tabs>
For the `$PATH` to reload, a reboot is advised.
### Usage
#### Preview the themes
<Tabs
defaultValue="winget"
groupId="install"
values={[
{ label: 'winget', value: 'winget', },
{ label: 'scoop', value: 'scoop', },
]
}>
<TabItem value="winget">
```powershell
Get-ChildItem -Path "$(scoop prefix oh-my-posh)/themes/*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
Get-ChildItem -Path "~\AppData\Local\Programs\oh-my-posh\themes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
$esc = [char]27
Write-Host ""
Write-Host "$esc[1m$($_.BaseName)$esc[0m"
@ -45,18 +87,75 @@ Get-ChildItem -Path "$(scoop prefix oh-my-posh)/themes/*" -Include '*.omp.json'
}
```
</TabItem>
<TabItem value="scoop">
```powershell
Get-ChildItem -Path "$(scoop prefix oh-my-posh)\themes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
$esc = [char]27
Write-Host ""
Write-Host "$esc[1m$($_.BaseName)$esc[0m"
Write-Host ""
oh-my-posh --config $($_.FullName) --pwd $PWD
Write-Host ""
}
```
</TabItem>
</Tabs>
#### Update
<Tabs
defaultValue="winget"
groupId="install"
values={[
{ label: 'winget', value: 'winget', },
{ label: 'scoop', value: 'scoop', },
]
}>
<TabItem value="winget">
```powershell
winget upgrade JanDeDobbeleer.OhMyPosh
```
</TabItem>
<TabItem value="scoop">
```powershell
scoop update oh-my-posh
```
</TabItem>
</Tabs>
### Replace your existing prompt
You can find the themes scoop installs inside the `"$(scoop prefix oh-my-posh)/themes/"` folder.
To use `jandedobbeleer.omp.json` for example, you can refer to it using `"$(scoop prefix oh-my-posh)/themes/jandedobbeleer.omp.json"`
<Tabs
defaultValue="winget"
groupId="install"
values={[
{ label: 'winget', value: 'winget', },
{ label: 'scoop', value: 'scoop', },
]
}>
<TabItem value="winget">
You can find the themes scoop installs inside the `~\AppData\Local\Programs\oh-my-posh\themes\` folder.
To use `jandedobbeleer.omp.json` for example, you can refer to it using `~\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json"`
when setting the prompt using the `--config` flag.
</TabItem>
<TabItem value="scoop">
You can find the themes scoop installs inside the `"$(scoop prefix oh-my-posh)\themes\"` folder.
To use `jandedobbeleer.omp.json` for example, you can refer to it using `"$(scoop prefix oh-my-posh)\themes\jandedobbeleer.omp.json"`
when setting the prompt using the `--config` flag.
</TabItem>
</Tabs>
The guides below use an imaginary theme called `mytheme.omp.json`, so make sure to replace that with your own, or one of the
included themes.

View file

@ -0,0 +1,15 @@
PackageIdentifier: JanDeDobbeleer.OhMyPosh
PackageVersion: <VERSION>
InstallModes:
- "silent"
Installers:
- Architecture: x64
InstallerType: inno
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install.exe
InstallerSha256: <HASH>
- Architecture: x86
InstallerType: inno
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install.exe
InstallerSha256: <HASH>
ManifestType: "installer"
ManifestVersion: 1.0.0

View file

@ -0,0 +1,22 @@
PackageIdentifier: JanDeDobbeleer.OhMyPosh
PackageVersion: <VERSION>
PackageLocale: en-US
Publisher: Jan De Dobbeleer
PackageName: Oh My Posh
License: GPL
ShortDescription: Prompt theme engine for any shell
Tags:
- "Console"
- "Command-Line"
- "Shell"
- "Command-Prompt"
- "PowerShell"
- "WSL"
- "Developer-Tools"
- "Utilities"
- "cli"
- "cmd"
- "ps"
- "terminal"
ManifestType: defaultLocale
ManifestVersion: 1.0.0

View file

@ -0,0 +1,5 @@
PackageIdentifier: JanDeDobbeleer.OhMyPosh
PackageVersion: <VERSION>
DefaultLocale: en-US
ManifestType: version
ManifestVersion: 1.0.0

49
packages/winget/build.ps1 Normal file
View file

@ -0,0 +1,49 @@
Param
(
[parameter(Mandatory = $true)]
[string]
$Version,
[parameter(Mandatory = $true)]
[string]
$Hash,
[parameter(Mandatory = $false)]
[string]
$Token
)
function Set-Version {
param (
[parameter(Mandatory = $true)]
[string]
$FileName,
[parameter(Mandatory = $true)]
[string]
$Version,
[parameter(Mandatory = $true)]
[string]
$Hash
)
$content = Get-Content $FileName -Raw
$content = $content.Replace('<VERSION>', $Version)
$content = $content.Replace('<HASH>', $Hash)
$content | Out-File -Encoding 'UTF8' "./$Version/$FileName"
}
New-Item -Path $PWD -Name $Version -ItemType "directory"
# Get all files inside the folder and adjust the version/hash
Get-ChildItem '*.yaml' | ForEach-Object -Process {
Set-Version -FileName $_.Name -Version $Version -Hash $hash
}
if (-not $Token) {
return
}
# Get the latest wingetcreate exe
# Replace with the following once https://github.com/microsoft/winget-create/issues/38 is resolved:
# Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
Invoke-WebRequest 'https://github.com/JanDeDobbeleer/winget-create/releases/latest/download/wingetcreate.zip' -OutFile wingetcreate.zip
Expand-Archive -LiteralPath wingetcreate.zip -DestinationPath wingetcreate
$wingetcreate = Resolve-Path -Path wingetcreate
$env:Path += ";$($wingetcreate.Path)"
# Create the PR
WingetCreateCLI.exe submit --token $Token $Version