Skip to content

Commit

Permalink
🏃
Browse files Browse the repository at this point in the history
  • Loading branch information
hlaueriksson committed Jun 30, 2024
1 parent a097087 commit 3ad9f2a
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/GEmojiSharp.PowerToysRun/deploy.bat

This file was deleted.

67 changes: 67 additions & 0 deletions src/GEmojiSharp.PowerToysRun/deploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<#PSScriptInfo
.VERSION 0.0.0
.GUID 04ee4032-b6da-48fa-a89f-553b6dd0b611
.AUTHOR Henrik Lau Eriksson
.COMPANYNAME
.COPYRIGHT
.TAGS PowerToys Run Plugins Deploy
.LICENSEURI
.PROJECTURI https://github.com/hlaueriksson/GEmojiSharp
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>

<#
.Synopsis
Deploys the plugin to PowerToys Run.
.Description
Copies the plugin to the PowerToys Run Plugins folder:
- %LocalAppData%\Microsoft\PowerToys\PowerToys Run\Plugins
.Parameter Platform
Platform: ARM64 | x64
.Example
.\deploy.ps1
.Link
https://github.com/hlaueriksson/GEmojiSharp
#>
param (
[ValidateSet("ARM64", "x64")]
[string]$platform = "x64"
)

#Requires -RunAsAdministrator

Stop-Process -Name "PowerToys" -Force -ErrorAction SilentlyContinue

dotnet build -c Release /p:TF_BUILD=true /p:Platform=$platform

Write-Output "Platform: $platform"

$libs = Get-ChildItem -Path .\libs -File -Recurse

$name = ((Split-Path -Path $PWD -Leaf).Split(".")[0]) # -1 last

Write-Output "Deploy: $name"

Remove-Item -LiteralPath "$env:LOCALAPPDATA\Microsoft\PowerToys\PowerToys Run\Plugins\$name" -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path ".\bin\$platform\Release\net8.0-windows" -Destination "$env:LOCALAPPDATA\Microsoft\PowerToys\PowerToys Run\Plugins\$name" -Recurse -Force -Exclude $libs

$machinePath = "C:\Program Files\PowerToys\PowerToys.exe"
$userPath = "$env:LOCALAPPDATA\PowerToys\PowerToys.exe"

if (Test-Path $machinePath) {
Start-Process -FilePath $machinePath
}
elseif (Test-Path $userPath) {
Start-Process -FilePath $userPath
}
else {
Write-Error "Unable to start PowerToys"
}
7 changes: 0 additions & 7 deletions src/GEmojiSharp.PowerToysRun/pack.bat

This file was deleted.

68 changes: 68 additions & 0 deletions src/GEmojiSharp.PowerToysRun/pack.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<#PSScriptInfo
.VERSION 0.0.0
.GUID a5a44179-e1e5-4ddd-9e0a-d6653eb69d9f
.AUTHOR Henrik Lau Eriksson
.COMPANYNAME
.COPYRIGHT
.TAGS PowerToys Run Plugins Pack
.LICENSEURI
.PROJECTURI https://github.com/hlaueriksson/GEmojiSharp
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>

<#
.Synopsis
Packs the plugin into release archive.
.Description
Builds the project in Release configuration,
copies the output files into plugin folder,
packs the plugin folder into release archive.
.Example
.\pack.ps1
.Link
https://github.com/hlaueriksson/GEmojiSharp
#>

# Clean
Get-ChildItem -Path "." -Directory -Include "bin", "obj" -Recurse | Remove-Item -Recurse -Force

# Version
[xml]$props = Get-Content -Path "*.csproj"
$version = "$($props.Project.PropertyGroup.Version)".Trim()
Write-Output "Version: $version"

# Platforms
$platforms = "$($props.Project.PropertyGroup.Platforms)".Trim() -split ";"

$libs = Get-ChildItem -Path .\libs -File -Recurse

foreach ($platform in $platforms)
{
Write-Output "Platform: $platform"

# Build
dotnet build -c Release /p:TF_BUILD=true /p:Platform=$platform

if (!$?) {
# Build FAILED.
Exit $LastExitCode
}

$name = ((Split-Path -Path $PWD -Leaf).Split(".")[0]) # -1 last

Write-Output "Pack: $name"

$output = ".\bin\$platform\Release\net8.0-windows\"
$destination = ".\bin\$platform\$name"
$zip = ".\bin\$platform\$name-$version-$($platform.ToLower()).zip"

Copy-Item -Path $output -Destination $destination -Recurse -Exclude $libs
Compress-Archive -Path $destination -DestinationPath $zip
}
91 changes: 91 additions & 0 deletions src/GEmojiSharp.PowerToysRun/release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<#PSScriptInfo
.VERSION 0.0.0
.GUID 01b1a89c-3a39-40e5-ae5b-d85bce48815f
.AUTHOR Henrik Lau Eriksson
.COMPANYNAME
.COPYRIGHT
.TAGS PowerToys Run Plugins Release
.LICENSEURI
.PROJECTURI https://github.com/hlaueriksson/GEmojiSharp
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>

<#
.Synopsis
Generate release notes snippets for the plugin.
.Description
Gathers information about the plugin and generates a markdown file with release notes snippets.
.Example
.\release.ps1
.Link
https://github.com/hlaueriksson/GEmojiSharp
#>

# Version
[xml]$props = Get-Content -Path "*.csproj"
$version = "$($props.Project.PropertyGroup.Version)".Trim()

# Platforms
$platforms = "$($props.Project.PropertyGroup.Platforms)".Trim() -split ";"

# Output
$result = "release-$version.md"

$projectUri = "https://github.com/hlaueriksson/GEmojiSharp"
$name = ((Split-Path -Path $PWD -Leaf).Split(".")[0]) # -1 last
$files = Get-ChildItem -Path . -File -Include "$name-$version*.zip" -Recurse

function Write-Line {
param (
[string]$line
)

$line | Add-Content -Path $result
}

function Get-Platform {
param (
[string]$filename
)

if ($filename -Match $platforms[0]) {
$platforms[0]
}
else {
$platforms[1]
}
}

Set-Content -Path $result -Value ""

Write-Line "## $name"
Write-Line ""
Write-Line "| Platform | Filename | Downloads"
Write-Line "| --- | --- | ---"
foreach ($file in $files) {
$zip = $file.Name
$platform = Get-Platform $zip
$url = "$projectUri/releases/download/v$version/$zip"
$badge = "https://img.shields.io/github/downloads/$($projectUri.Replace('https://github.com/', ''))/v$version/$zip"

Write-Line "| ``$platform`` | [$zip]($url) | [![$zip]($badge)]($url)"
}
Write-Line ""

Write-Line "## Installer Hashes"
Write-Line ""
Write-Line "| Filename | SHA256 Hash"
Write-Line "| --- | ---"
foreach ($file in $files) {
$zip = $file.Name
$hash = Get-FileHash $file -Algorithm SHA256 | Select-Object -ExpandProperty Hash

Write-Line "| ``$zip`` | ``$hash``"
}

0 comments on commit 3ad9f2a

Please sign in to comment.