Skip to content

Commit c8ef9ed

Browse files
feat: winget support
1 parent 8ef355d commit c8ef9ed

File tree

6 files changed

+215
-3
lines changed

6 files changed

+215
-3
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ jobs:
237237
needs: [release, artifacts]
238238
if: ${{ needs.release.outputs.skipped == 'false' }}
239239
runs-on: windows-latest
240+
outputs:
241+
hash: ${{ steps.hash.outputs.hash_inno }}
240242
defaults:
241243
run:
242244
shell: pwsh
@@ -246,6 +248,11 @@ jobs:
246248
uses: actions/checkout@v2
247249
- name: Build installer
248250
run: ./build.ps1 -Version ${{ needs.release.outputs.version }}
251+
- name: Output Hash
252+
id: hash
253+
run: |
254+
$hash = Get-Content -Path Output/install.exe.sha256
255+
Write-Output "::set-output name=hash_inno::$($hash)"
249256
- name: Upload Inno Installer
250257
id: upload-inno-installer
251258
uses: actions/upload-release-asset@v1
@@ -266,3 +273,18 @@ jobs:
266273
asset_path: ${{ github.workspace }}/packages/inno/Output/install.exe.sha256
267274
asset_name: install.exe.sha256
268275
asset_content_type: text/plain
276+
winget:
277+
needs: [release, inno]
278+
if: ${{ needs.release.outputs.skipped == 'false' }}
279+
runs-on: windows-latest
280+
defaults:
281+
run:
282+
shell: pwsh
283+
working-directory: ${{ github.workspace }}/packages/winget
284+
env:
285+
WINGETCREATE_TOKEN: ${{ secrets.WINGETCREATE_TOKEN }}
286+
steps:
287+
- name: Checkout code
288+
uses: actions/checkout@v2
289+
- name: Create manifest and submit PR
290+
run: ./build.ps1 -Version ${{ needs.release.outputs.version }} -Hash ${{ needs.inno.outputs.hash }} -Token $env:WINGETCREATE_TOKEN

docs/docs/install-windows.mdx

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,33 @@ While Oh my Posh works on the standard terminal, we advise using the [Windows Te
1616

1717
### Installation
1818

19+
<Tabs
20+
defaultValue="winget"
21+
groupId="install"
22+
values={[
23+
{ label: 'winget', value: 'winget', },
24+
{ label: 'scoop', value: 'scoop', },
25+
]
26+
}>
27+
<TabItem value="winget">
28+
29+
```powershell
30+
winget install JanDeDobbeleer.OhMyPosh
31+
```
32+
33+
This installs a couple of things:
34+
35+
- `oh-my-posh.exe` - Windows executable, added to your `$PATH`
36+
- `oh-my-posh-wsl` - Linux executable, added to your `$PATH` for use in the WSL
37+
- `themes` - The latest Oh my Posh themes
38+
39+
If you want to use a standard theme, you can find them in `~\AppData\Local\Programs\oh-my-posh\themes\`,
40+
referencing them as such
41+
will always keep them compatible with the binary when updating Oh my Posh.
42+
43+
</TabItem>
44+
<TabItem value="scoop">
45+
1946
```powershell
2047
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json
2148
```
@@ -30,12 +57,27 @@ If you want to use a standard theme, you can find them in `~\scoop\apps\oh-my-po
3057
referencing them as such
3158
will always keep them compatible with the binary when updating Oh my Posh.
3259

60+
</TabItem>
61+
</Tabs>
62+
63+
For the `$PATH` to reload, a reboot is advised.
64+
3365
### Usage
3466

3567
#### Preview the themes
3668

69+
<Tabs
70+
defaultValue="winget"
71+
groupId="install"
72+
values={[
73+
{ label: 'winget', value: 'winget', },
74+
{ label: 'scoop', value: 'scoop', },
75+
]
76+
}>
77+
<TabItem value="winget">
78+
3779
```powershell
38-
Get-ChildItem -Path "$(scoop prefix oh-my-posh)/themes/*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
80+
Get-ChildItem -Path "~\AppData\Local\Programs\oh-my-posh\themes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
3981
$esc = [char]27
4082
Write-Host ""
4183
Write-Host "$esc[1m$($_.BaseName)$esc[0m"
@@ -45,18 +87,75 @@ Get-ChildItem -Path "$(scoop prefix oh-my-posh)/themes/*" -Include '*.omp.json'
4587
}
4688
```
4789

90+
</TabItem>
91+
<TabItem value="scoop">
92+
93+
```powershell
94+
Get-ChildItem -Path "$(scoop prefix oh-my-posh)\themes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
95+
$esc = [char]27
96+
Write-Host ""
97+
Write-Host "$esc[1m$($_.BaseName)$esc[0m"
98+
Write-Host ""
99+
oh-my-posh --config $($_.FullName) --pwd $PWD
100+
Write-Host ""
101+
}
102+
```
103+
104+
</TabItem>
105+
</Tabs>
106+
48107
#### Update
49108

109+
<Tabs
110+
defaultValue="winget"
111+
groupId="install"
112+
values={[
113+
{ label: 'winget', value: 'winget', },
114+
{ label: 'scoop', value: 'scoop', },
115+
]
116+
}>
117+
<TabItem value="winget">
118+
119+
```powershell
120+
winget upgrade JanDeDobbeleer.OhMyPosh
121+
```
122+
123+
</TabItem>
124+
<TabItem value="scoop">
125+
50126
```powershell
51127
scoop update oh-my-posh
52128
```
53129

130+
</TabItem>
131+
</Tabs>
132+
54133
### Replace your existing prompt
55134

56-
You can find the themes scoop installs inside the `"$(scoop prefix oh-my-posh)/themes/"` folder.
57-
To use `jandedobbeleer.omp.json` for example, you can refer to it using `"$(scoop prefix oh-my-posh)/themes/jandedobbeleer.omp.json"`
135+
<Tabs
136+
defaultValue="winget"
137+
groupId="install"
138+
values={[
139+
{ label: 'winget', value: 'winget', },
140+
{ label: 'scoop', value: 'scoop', },
141+
]
142+
}>
143+
<TabItem value="winget">
144+
145+
You can find the themes scoop installs inside the `~\AppData\Local\Programs\oh-my-posh\themes\` folder.
146+
To use `jandedobbeleer.omp.json` for example, you can refer to it using `~\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json"`
58147
when setting the prompt using the `--config` flag.
59148

149+
</TabItem>
150+
<TabItem value="scoop">
151+
152+
You can find the themes scoop installs inside the `"$(scoop prefix oh-my-posh)\themes\"` folder.
153+
To use `jandedobbeleer.omp.json` for example, you can refer to it using `"$(scoop prefix oh-my-posh)\themes\jandedobbeleer.omp.json"`
154+
when setting the prompt using the `--config` flag.
155+
156+
</TabItem>
157+
</Tabs>
158+
60159
The guides below use an imaginary theme called `mytheme.omp.json`, so make sure to replace that with your own, or one of the
61160
included themes.
62161

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
PackageIdentifier: JanDeDobbeleer.OhMyPosh
2+
PackageVersion: <VERSION>
3+
InstallModes:
4+
- "silent"
5+
Installers:
6+
- Architecture: x64
7+
InstallerType: inno
8+
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install.exe
9+
InstallerSha256: <HASH>
10+
- Architecture: x86
11+
InstallerType: inno
12+
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install.exe
13+
InstallerSha256: <HASH>
14+
ManifestType: "installer"
15+
ManifestVersion: 1.0.0
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PackageIdentifier: JanDeDobbeleer.OhMyPosh
2+
PackageVersion: <VERSION>
3+
PackageLocale: en-US
4+
Publisher: Jan De Dobbeleer
5+
PackageName: Oh My Posh
6+
License: GPL
7+
ShortDescription: Prompt theme engine for any shell
8+
Tags:
9+
- "Console"
10+
- "Command-Line"
11+
- "Shell"
12+
- "Command-Prompt"
13+
- "PowerShell"
14+
- "WSL"
15+
- "Developer-Tools"
16+
- "Utilities"
17+
- "cli"
18+
- "cmd"
19+
- "ps"
20+
- "terminal"
21+
ManifestType: defaultLocale
22+
ManifestVersion: 1.0.0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PackageIdentifier: JanDeDobbeleer.OhMyPosh
2+
PackageVersion: <VERSION>
3+
DefaultLocale: en-US
4+
ManifestType: version
5+
ManifestVersion: 1.0.0

packages/winget/build.ps1

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
Param
3+
(
4+
[parameter(Mandatory = $true)]
5+
[string]
6+
$Version,
7+
[parameter(Mandatory = $true)]
8+
[string]
9+
$Hash,
10+
[parameter(Mandatory = $false)]
11+
[string]
12+
$Token
13+
)
14+
15+
function Set-Version {
16+
param (
17+
[parameter(Mandatory = $true)]
18+
[string]
19+
$FileName,
20+
[parameter(Mandatory = $true)]
21+
[string]
22+
$Version,
23+
[parameter(Mandatory = $true)]
24+
[string]
25+
$Hash
26+
)
27+
$content = Get-Content $FileName -Raw
28+
$content = $content.Replace('<VERSION>', $Version)
29+
$content = $content.Replace('<HASH>', $Hash)
30+
$content | Out-File -Encoding 'UTF8' "./$Version/$FileName"
31+
}
32+
33+
New-Item -Path $PWD -Name $Version -ItemType "directory"
34+
# Get all files inside the folder and adjust the version/hash
35+
Get-ChildItem '*.yaml' | ForEach-Object -Process {
36+
Set-Version -FileName $_.Name -Version $Version -Hash $hash
37+
}
38+
if (-not $Token) {
39+
return
40+
}
41+
# Get the latest wingetcreate exe
42+
# Replace with the following once https://github.com/microsoft/winget-create/issues/38 is resolved:
43+
# Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
44+
Invoke-WebRequest 'https://github.com/JanDeDobbeleer/winget-create/releases/latest/download/wingetcreate.zip' -OutFile wingetcreate.zip
45+
Expand-Archive -LiteralPath wingetcreate.zip -DestinationPath wingetcreate
46+
$wingetcreate = Resolve-Path -Path wingetcreate
47+
$env:Path += ";$($wingetcreate.Path)"
48+
# Create the PR
49+
WingetCreateCLI.exe submit --token $Token $Version

0 commit comments

Comments
 (0)