Skip to content

Commit

Permalink
feat: add Cask
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Oct 1, 2023
1 parent 97d1fe8 commit 989e44f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
13 changes: 13 additions & 0 deletions Casks/oh-my-posh.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cask "oh-my-posh" do
desc "Prompt theme engine for any shell"
homepage "https://ohmyposh.dev"
arch arm: "arm64", intel: "amd64"
version "18.10.3"
url "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v#{version}/posh-darwin-#{arch}"
sha256 arm: "2b479e969633e5a63e24457b9640b6768b26b6af759c6cea8d70d15be78b2d53",
intel: "eb37626bb15fb95a102d651ce1b82025966a0c56b774a0c7d2e79d7c4466ed86"
name "oh-my-posh"
binary "posh-darwin-#{arch}", target: "oh-my-posh"
auto_updates true
end

39 changes: 33 additions & 6 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,39 @@ param (
$Version
)

Invoke-Webrequest "https://github.com/JanDeDobbeleer/oh-my-posh/archive/v$Version.tar.gz" -OutFile "v$Version.tar.gz"
$fileHash = Get-FileHash -Algorithm SHA256 -Path "v$Version.tar.gz"
$hash = $fileHash.Hash.ToLower()
Remove-Item -Path "v$Version.tar.gz"
$content = Get-Content './oh-my-posh.txt' -Raw
function Get-RemoteFileHash {
param (
[Parameter()]
[string]
$File
)

$fileName = Split-Path $File -Leaf
Write-Information "Downloading $File to $fileName"
Invoke-Webrequest $File -OutFile $fileName
$fileHash = Get-FileHash -Algorithm SHA256 -Path $fileName
$hash = $fileHash.Hash.ToLower()
Write-Information "Hash of $fileName is $hash"
Remove-Item -Path $fileName

return $hash
}

Write-Information "Building version $Version"
Write-Information "Updating formula"
$zipHash = Get-RemoteFileHash -File "https://github.com/JanDeDobbeleer/oh-my-posh/archive/v$Version.tar.gz"
$content = Get-Content './formula.rb' -Raw
$content = $content.Replace('<VERSION>', $Version)
$content = $content.Replace('<DATE>', (Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ" -AsUTC))
$content = $content.Replace('<SHA256>', $hash)
$content = $content.Replace('<SHA256>', $zipHash)
$content | Out-File -Encoding 'UTF8' '../oh-my-posh.rb'
Write-Information "Updated formula"

Write-Information "Updating cask"
$armHash = Get-RemoteFileHash -File "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v$Version/posh-darwin-arm64"
$intelHash = Get-RemoteFileHash -File "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v$Version/posh-darwin-amd64"
$content = Get-Content './cask.rb' -Raw
$content = $content.Replace('<VERSION>', $Version)
$content = $content.Replace('<SHA256-ARM>', $armHash)
$content = $content.Replace('<SHA256-INTEL>', $intelHash)
$content | Out-File -Encoding 'UTF8' '../Casks/oh-my-posh.rb'
12 changes: 12 additions & 0 deletions build/cask.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cask "oh-my-posh" do
desc "Prompt theme engine for any shell"
homepage "https://ohmyposh.dev"
arch arm: "arm64", intel: "amd64"
version "<VERSION>"
url "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v#{version}/posh-darwin-#{arch}"
sha256 arm: "<SHA256-ARM>",
intel: "<SHA256-INTEL>"
name "oh-my-posh"
binary "posh-darwin-#{arch}", target: "oh-my-posh"
auto_updates true
end
File renamed without changes.

0 comments on commit 989e44f

Please sign in to comment.