feat(scoop): use installer instead of raw binaries

This commit is contained in:
Jan De Dobbeleer 2022-10-19 12:49:26 +02:00 committed by Jan De Dobbeleer
parent a94ce52f98
commit 30f44f46d2
4 changed files with 71 additions and 51 deletions

View file

@ -79,4 +79,16 @@ jobs:
ref: 'main',
inputs: {"version": process.env.GITHUB_REF.replace('refs/tags/v', '')}
})
- name: Notify Scoop Build 🤙
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0
with:
github-token: ${{ secrets.GH_PAT }}
script: |
await github.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', {
owner: 'jandedobbeleer',
repo: '${{ github.event.repository.name }}',
workflow_id: 'scoop.yml',
ref: 'main',
inputs: {"version": process.env.GITHUB_REF.replace('refs/tags/v', '')}
})

View file

@ -1,7 +1,10 @@
name: Scoop
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'The latest version'
required: true
jobs:
publish:
@ -34,13 +37,9 @@ jobs:
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
for (let file of await fs.readdir('./packages/scoop/dist')) {
console.log('uploading', file);
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: ${{ steps.get_release.outputs.id }},
name: file,
data: await fs.readFile(`./packages/scoop/dist/${file}`)
});
}
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: ${{ steps.get_release.outputs.id }},
name: "oh-my-posh.json",
data: await fs.readFile('./packages/scoop/dist/oh-my-posh.json')
});

View file

@ -5,29 +5,26 @@ Param
$Version
)
New-Item -Path "." -Name "package/bin" -ItemType Directory
function Get-HashForArchitecture {
param (
[parameter(Mandatory = $true)]
[string]
$Architecture,
[parameter(Mandatory = $true)]
[string]
$Version
)
$hash = (new-object Net.WebClient).DownloadString("https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v$Version/install-$Architecture.exe.sha256")
return $hash.Trim()
}
New-Item -Path "." -Name "dist" -ItemType "directory"
Copy-Item -Path "../../themes" -Destination "./package" -Recurse
# Download the files and pack them
@{name = 'posh-windows-amd64.exe'; outName = 'oh-my-posh.exe' } | ForEach-Object -Process {
$download = "https://github.com/jandedobbeleer/oh-my-posh/releases/download/v$Version/$($_.name)"
Invoke-WebRequest $download -Out "./package/bin/$($_.outName)"
}
$HashAmd64 = Get-HashForArchitecture -Architecture 'amd64' -Version $Version
$Hash386 = Get-HashForArchitecture -Architecture '386' -Version $Version
$zipDestination = "./dist/posh-windows-amd64.7z"
$compress = @{
Path = "./package/*"
CompressionLevel = "Fastest"
DestinationPath = $zipDestination
}
Compress-Archive @compress
$zipHash = Get-FileHash $zipDestination -Algorithm SHA256
$content = Get-Content '.\oh-my-posh.json' -Raw
$content = $content.Replace('<VERSION>', $Version)
$content = $content.Replace('<HASH>', $zipHash.Hash)
$content = $content.Replace('<HASH-AMD64>', $HashAmd64)
$content = $content.Replace('<HASH-386>', $Hash386)
$content | Out-File -Encoding 'UTF8' './dist/oh-my-posh.json'
$zipHash.Hash | Out-File -Encoding 'UTF8' './dist/posh-windows-amd64.7z.sha256'
Remove-Item ./package/ -Recurse

View file

@ -3,34 +3,46 @@
"description": "A prompt theme engine for any shell",
"homepage": "https://ohmyposh.dev",
"license": {
"identifier": "MIT",
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/COPYING"
"identifier": "MIT",
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/COPYING"
},
"architecture": {
"64bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/posh-windows-amd64.7z",
"hash": "<HASH>"
}
"64bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-amd64.exe",
"hash": "<HASH-AMD64>"
},
"32bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-386.exe",
"hash": "<HASH-386>"
}
},
"env_add_path": "bin",
"env_set": {
"POSH_THEMES_PATH": "$dir\\themes"
"installer": {
"args": [
"/CURRENTUSER",
"/VERYSILENT"
]
},
"checkver": {
"github": "https://github.com/JanDeDobbeleer/oh-my-posh"
"github": "https://github.com/JanDeDobbeleer/oh-my-posh"
},
"post_install": [
"Write-Host 'Thanks for installing Oh My Posh.'",
"Write-Host 'Have a look at https://ohmyposh.dev for detailed instructions for your shell.'"
"Write-Host 'Thanks for installing Oh My Posh.'",
"Write-Host 'Have a look at https://ohmyposh.dev for detailed instructions for your shell.'"
],
"autoupdate": {
"architecture": {
"64bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v$version/posh-windows-amd64.7z",
"hash": {
"url": "$url.sha256"
}
}
"architecture": {
"64bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-amd64.exe",
"hash": {
"url": "$url.sha256"
}
},
"32bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-386.exe",
"hash": {
"url": "$url.sha256"
}
}
}
}
}