Skip to content

Commit

Permalink
Merge pull request #96 from StartAutomating/EventfulDemos
Browse files Browse the repository at this point in the history
Eventful demos
  • Loading branch information
StartAutomating committed Oct 10, 2023
2 parents d87ffae + 54d515c commit d8e9de6
Show file tree
Hide file tree
Showing 65 changed files with 1,664 additions and 967 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/BuildShowDemo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ jobs:
if: ${{ success() }}
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: GitLogger
uses: GitLogging/GitLoggerAction@main
id: GitLogger
Expand Down Expand Up @@ -604,6 +604,12 @@ jobs:
id: ShowDemo
- name: UseHelpOut
uses: StartAutomating/HelpOut@master
- name: PSA
uses: StartAutomating/PSA@main
id: PSA
on:
push:
pull_request:
env:
AT_PROTOCOL_APP_PASSWORD: ${{ secrets.AT_PROTOCOL_APP_PASSWORD }}
AT_PROTOCOL_HANDLE: mrpowershell.bsky.social
17 changes: 17 additions & 0 deletions .github/workflows/SendPSA.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

name: show-demo-psa
on:
workflow_dispatch:
jobs:
SendPSA:
runs-on: ubuntu-latest
if: ${{ success() }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: PSA
uses: StartAutomating/PSA@main
id: PSA
env:
AT_PROTOCOL_APP_PASSWORD: ${{ secrets.AT_PROTOCOL_APP_PASSWORD }}
AT_PROTOCOL_HANDLE: mrpowershell.bsky.social
16 changes: 16 additions & 0 deletions Assets/ShowDemo-animated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions Assets/ShowDemo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/ShowDemo@1080p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
steps = @(
@{
name = 'Check out repository'
uses = 'actions/checkout@v2'
uses = 'actions/checkout@v3'
},
@{
name = 'GitLogger'
Expand Down Expand Up @@ -44,6 +44,11 @@
uses = './'
id = 'ShowDemo'
},
'RunHelpOut'
'RunHelpOut',
@{
name = 'PSA'
uses = 'StartAutomating/PSA@main'
id = 'PSA'
}
)
}
15 changes: 15 additions & 0 deletions Build/GitHub/Jobs/SendPSA.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@{
"runs-on" = "ubuntu-latest"
if = '${{ success() }}'
steps = @(
@{
name = 'Check out repository'
uses = 'actions/checkout@v3'
},
@{
name = 'PSA'
uses = 'StartAutomating/PSA@main'
id = 'PSA'
}
)
}
5 changes: 4 additions & 1 deletion Build/ShowDemo.GitHubAction.PSDevOps.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#requires -Module PSDevOps
#requires -Module ShowDemo
Import-BuildStep -SourcePath (
Join-Path $PSScriptRoot 'GitHub'
) -BuildSystem GitHubWorkflow

Push-Location ($PSScriptRoot | Split-Path)
Import-BuildStep -ModuleName ShowDemo
New-GitHubAction -Name "DemoPowerShell" -Description @'
Make Demos of your PowerShell projects.
'@ -Action DemoPowerShell -Icon terminal -OutputPath .\action.yml
Expand Down
14 changes: 12 additions & 2 deletions Build/ShowDemo.GitHubWorkflow.PSDevOps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@
#requires -Module ShowDemo
#requires -Module GitPub

Import-BuildStep -Module ShowDemo
Import-BuildStep -SourcePath (
Join-Path $PSScriptRoot 'GitHub'
) -BuildSystem GitHubWorkflow

Push-Location ($PSScriptRoot | Split-Path)

New-GitHubWorkflow -Job PowerShellStaticAnalysis, TestPowerShellOnLinux, TagReleaseAndPublish, BuildShowDemo -OutputPath @'
.\.github\workflows\BuildShowDemo.yml
'@ -Name "Build, Test, and Release ShowDemo" -On Push, PullRequest
'@ -Name "Build, Test, and Release ShowDemo" -On Push, PullRequest -Env @{
"AT_PROTOCOL_HANDLE" = "mrpowershell.bsky.social"
"AT_PROTOCOL_APP_PASSWORD" = '${{ secrets.AT_PROTOCOL_APP_PASSWORD }}'
}

Import-BuildStep -ModuleName GitPub

New-GitHubWorkflow -On Demand -Job RunGitPub -Name GitPub -OutputPath @'
.\.github\workflows\GitPub.yml
'@

New-GitHubWorkflow -On Demand -Name 'show-demo-psa' -Job SendPSA -OutputPath .\.github\workflows\SendPSA.yml -Env @{
"AT_PROTOCOL_HANDLE" = "mrpowershell.bsky.social"
"AT_PROTOCOL_APP_PASSWORD" = '${{ secrets.AT_PROTOCOL_APP_PASSWORD }}'
}

Pop-Location

53 changes: 53 additions & 0 deletions Build/ShowDemo.PSA.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Any *.PSA.ps1 file will be run when PSA runs.

# A good thing to do at the start of this file is to connect.

Connect-BlueSky

# If $env:AT_PROTOCOL_HANDLE or $env:AT_PROTOCOL_EMAIL is set, it will be treated as the username
# If $env:AT_PROTOCOL_APP_PASSWORD is set, it will be treated as the App Password.
# _Never_ use your actual BlueSky password

# Once we're connected, we can do anything our app password allows.

# However, you _might_ want to output some information first, so that you can see you're connected.

Get-BskyActorProfile -Actor $env:AT_PROTOCOL_HANDLE -Cache | Out-Host

# To ensure you're not going to send a skeet on every checkin, it's a good idea to ask what GitHub is up to

# There will be a variable, $GitHubEvent, that contains information about the event.

# A fairly common scenario is to perform an annoucement whenever a PR is merged.

$isMergeToMain =
($gitHubEvent.head_commit.message -match "Merge Pull Request #(?<PRNumber>\d+)") -and
$gitHubEvent.ref -eq 'refs/heads/main'

$importedModule = Import-Module .\ShowDemo.psd1 -Global -PassThru
$importedModule | Out-Host
$moduleAndVersion = "$($importedModule.Name) $($importedModule.Version)"

$isManuallyTriggered = $gitHubEvent.psobject.properties["inputs"]

if ($isMergeToMain -or $isManuallyTriggered) {

$fullMessage = @(
"Show off your scripts",
"Demo your PowerShell",
"Never typo during a talk again" | Get-Random

"$($ImportedModule.Name)"
) -join [Environment]::NewLine

$sendSplat = [Ordered]@{
Text = $fullMessage
}
if ($importedModule.PrivateData.PSData.ProjectURI) {
$sendSplat.WebCard = @{Url=$importedModule.PrivateData.PSData.ProjectURI}
$sendSplat.LinkPattern = @{$importedModule.Name=$importedModule.PrivateData.PSData.ProjectURI}
}

Send-AtProto @sendSplat
return
}
63 changes: 63 additions & 0 deletions Build/ShowDemo.PSSVG.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#requires -Module PSSVG
Push-Location ($psScriptRoot | Split-Path)
$powerShellChevron = Invoke-RestMethod https://pssvg.start-automating.com/Examples/PowerShellChevron.svg
$assetsPath = Join-Path $pwd Assets
$scaleMin = 1
$scaleMax = 1.02


$FontSplat = [Ordered]@{
FontFamily = "sans-serif"
}

= (1.0 + [Math]::Sqrt(5))/2

$AnimateSplat = [Ordered]@{
Dur = 60/128*8
AttributeName = 'font-size'
Values = "${scaleMin}em;${scaleMax}em;${scaleMin}em"
RepeatCount = 'indefinite'
}

$AnimateSplat2 = [Ordered]@{} + $AnimateSplat
$AnimateSplat2.Values = "${scaleMax}em;${scaleMin}em;${scaleMax}em"

if (-not (Test-path $assetsPath)) {
$null = New-Item -ItemType Directory -Path $assetsPath -Force
}


foreach ($variant in '','animated') {
svg @(
SVG.GoogleFont -FontName $FontName
svg.symbol -ViewBox $powerShellChevron.svg.viewBox -Content $powerShellChevron.svg.symbol.InnerXml -Id psChevron
$RectSplat = [Ordered]@{
Rx=30
Ry=(30 / )
Stroke="#4488ff"
StrokeWidth="1%"
Fill='transparent'
Width = 250
Height = 250 /
X = 25
Y = 25 /
}
SVG.rect @RectSplat

svg.use -href '#psChevron' -X '12.5%' -Y '-2%' -Width '12.5%' -Stroke '#4488ff' -Fill '#4488ff'
svg.text @(
svg.tspan "Show" -Children @(
if ($variant -match 'animated') {
SVG.animate @AnimateSplat
}
) -FontSize "${scaleMin}em"
svg.tspan "Demo" -Children @(
if ($variant -match 'animated') {
SVG.animate @AnimateSplat2 -Begin ($dur / 2)
}
) -FontSize "${scaleMin}em"
) -FontSize 32 -Fill '#4488ff' -X 50% -DominantBaseline 'middle' -TextAnchor 'middle' -Y 50% @FontSplat
) -ViewBox 300, ([Math]::Floor(300 / )) -OutputPath (Join-Path $assetsPath "ShowDemo$(if ($variant){"-$($variant)"}).svg")
}

Pop-Location
2 changes: 1 addition & 1 deletion Build/ShowDemo.ezout.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Push-Location $myRoot
$formatting = @(
# Add your own Write-FormatView here,
# or put them in a Formatting or Views directory
foreach ($potentialDirectory in 'Formatting','Views') {
foreach ($potentialDirectory in 'Formatting','Views','Types') {
Join-Path $myRoot $potentialDirectory |
Get-ChildItem -ea ignore |
Import-FormatView -FilePath {$_.Fullname}
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## ShowDemo 0.1.5:

* Demos are now more eventful (#66)
* Nearly every part of ShowDemo transmits PowerShell engine events
* These can be used for highly customized display of demos
* Refactoring all *-Demo commands to use a single -From parameter (#86)
* Added Logo (#90)
* Integrated PSA (#91)

---

## ShowDemo 0.1.4:
* ShowDemo - Adding Recommendations (Fixes #63)
Expand Down
9 changes: 5 additions & 4 deletions Commands/Export-Demo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
Export-Demo -DemoPath .\demo.ps1 -OutputPath .\demo.md
#>
param(
# The path to the demo file.
# The source of the demo. This can be a string, file, command, module, or path.
[Parameter(Mandatory,
ValueFromPipelineByPropertyName,
ParameterSetName='DemoFile')]
[Alias('FullName', 'DemoFile', 'File', 'Source')]
$DemoPath,
[Alias('DemoPath','DemoName','DemoText','DemoScript','FullName', 'DemoFile', 'File', 'Source')]
[PSObject]
$From,

# The output path. This is the location the demo will be saved to.
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
Expand Down Expand Up @@ -87,7 +88,7 @@

}
process {
$demoContents = Get-Demo -File $DemoPath
$demoContents = Get-Demo -From $From
if (-not $demoContents) { return }

if ($OutputPath -notmatch $extensionPattern) {
Expand Down
Loading

0 comments on commit d8e9de6

Please sign in to comment.