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

View file

@ -5,29 +5,26 @@ Param
$Version $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" New-Item -Path "." -Name "dist" -ItemType "directory"
Copy-Item -Path "../../themes" -Destination "./package" -Recurse
# Download the files and pack them $HashAmd64 = Get-HashForArchitecture -Architecture 'amd64' -Version $Version
@{name = 'posh-windows-amd64.exe'; outName = 'oh-my-posh.exe' } | ForEach-Object -Process { $Hash386 = Get-HashForArchitecture -Architecture '386' -Version $Version
$download = "https://github.com/jandedobbeleer/oh-my-posh/releases/download/v$Version/$($_.name)"
Invoke-WebRequest $download -Out "./package/bin/$($_.outName)"
}
$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 = Get-Content '.\oh-my-posh.json' -Raw
$content = $content.Replace('<VERSION>', $Version) $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' $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", "description": "A prompt theme engine for any shell",
"homepage": "https://ohmyposh.dev", "homepage": "https://ohmyposh.dev",
"license": { "license": {
"identifier": "MIT", "identifier": "MIT",
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/COPYING" "url": "https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/COPYING"
}, },
"architecture": { "architecture": {
"64bit": { "64bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/posh-windows-amd64.7z", "url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-amd64.exe",
"hash": "<HASH>" "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", "installer": {
"env_set": { "args": [
"POSH_THEMES_PATH": "$dir\\themes" "/CURRENTUSER",
"/VERYSILENT"
]
}, },
"checkver": { "checkver": {
"github": "https://github.com/JanDeDobbeleer/oh-my-posh" "github": "https://github.com/JanDeDobbeleer/oh-my-posh"
}, },
"post_install": [ "post_install": [
"Write-Host 'Thanks for installing Oh My Posh.'", "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 'Have a look at https://ohmyposh.dev for detailed instructions for your shell.'"
], ],
"autoupdate": { "autoupdate": {
"architecture": { "architecture": {
"64bit": { "64bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v$version/posh-windows-amd64.7z", "url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-amd64.exe",
"hash": { "hash": {
"url": "$url.sha256" "url": "$url.sha256"
} }
} },
"32bit": {
"url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-386.exe",
"hash": {
"url": "$url.sha256"
}
} }
}
} }
} }