diff --git a/.github/workflows/OnIssue.yml b/.github/workflows/OnIssue.yml new file mode 100644 index 0000000..b593666 --- /dev/null +++ b/.github/workflows/OnIssue.yml @@ -0,0 +1,31 @@ + +name: OnIssueChanged +on: + issues: + workflow_dispatch: +jobs: + RunGitPub: + runs-on: ubuntu-latest + if: ${{ success() }} + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Use GitPub Action + uses: StartAutomating/GitPub@main + id: GitPub + with: + TargetBranch: edits-$([DateTime]::Now.ToString("r").Replace(":","-").Replace(" ", "")) + CommitMessage: Posting with GitPub [skip ci] + PublishParameters: | + { + "Get-GitPubIssue": { + "Repository": '${{github.repository}}' + }, + "Get-GitPubRelease": { + "Repository": '${{github.repository}}' + }, + "Publish-GitPubJekyll": { + "OutputPath": "docs/_posts" + } + } + diff --git a/.github/workflows/TestAndPublish.yml b/.github/workflows/TestAndPublish.yml index 2e3bc58..ae609d2 100644 --- a/.github/workflows/TestAndPublish.yml +++ b/.github/workflows/TestAndPublish.yml @@ -306,6 +306,8 @@ jobs: $Parameters.UserName = ${env:UserName} $Parameters.TagVersionFormat = ${env:TagVersionFormat} $Parameters.ReleaseNameFormat = ${env:ReleaseNameFormat} + $Parameters.ReleaseAsset = ${env:ReleaseAsset} + $Parameters.ReleaseAsset = $parameters.ReleaseAsset -split ';' -replace '^[''"]' -replace '[''"]$' foreach ($k in @($parameters.Keys)) { if ([String]::IsNullOrEmpty($parameters[$k])) { $parameters.Remove($k) @@ -331,7 +333,11 @@ jobs: # The release name format (default value: '$($imported.Name) $($imported.Version)') [string] - $ReleaseNameFormat = '$($imported.Name) $($imported.Version)' + $ReleaseNameFormat = '$($imported.Name) $($imported.Version)', + + # Any assets to attach to the release. Can be a wildcard or file name. + [string[]] + $ReleaseAsset ) @@ -381,7 +387,7 @@ jobs: } - Invoke-RestMethod -Uri $releasesURL -Method Post -Body ( + $releasedIt = Invoke-RestMethod -Uri $releasesURL -Method Post -Body ( [Ordered]@{ owner = '${{github.owner}}' repo = '${{github.repository}}' @@ -403,6 +409,53 @@ jobs: "Content-type" = "application/json" "Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}' } + + + if (-not $releasedIt) { + throw "Release failed" + } else { + $releasedIt | Out-Host + } + + $releaseUploadUrl = $releasedIt.upload_url -replace '\{.+$' + + if ($ReleaseAsset) { + $fileList = Get-ChildItem -Recurse + $filesToRelease = + @(:nextFile foreach ($file in $fileList) { + foreach ($relAsset in $ReleaseAsset) { + if ($relAsset -match '[\*\?]') { + if ($file.Name -like $relAsset) { + $file; continue nextFile + } + } elseif ($file.Name -eq $relAsset -or $file.FullName -eq $relAsset) { + $file; continue nextFile + } + } + }) + + $releasedFiles = @{} + foreach ($file in $filesToRelease) { + if ($releasedFiles[$file.Name]) { + Write-Warning "Already attached file $($file.Name)" + continue + } else { + $fileBytes = [IO.File]::ReadAllBytes($file.FullName) + $releasedFiles[$file.Name] = + Invoke-RestMethod -Uri "${releaseUploadUrl}?name=$($file.Name)" -Headers @{ + "Accept" = "application/vnd.github+json" + "ContentType" = "application/octet-stream" + "Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}' + } -Body $fileBytes + $releasedFiles[$file.Name] + } + } + + "Attached $($releasedFiles.Count) file(s) to release" | Out-Host + } + + + } @Parameters - name: PublishPowerShellGallery id: PublishPowerShellGallery @@ -410,6 +463,8 @@ jobs: run: | $Parameters = @{} $Parameters.ModulePath = ${env:ModulePath} + $Parameters.Exclude = ${env:Exclude} + $Parameters.Exclude = $parameters.Exclude -split ';' -replace '^[''"]' -replace '[''"]$' foreach ($k in @($parameters.Keys)) { if ([String]::IsNullOrEmpty($parameters[$k])) { $parameters.Remove($k) @@ -418,12 +473,20 @@ jobs: Write-Host "::debug:: PublishPowerShellGallery $(@(foreach ($p in $Parameters.GetEnumerator()) {'-' + $p.Key + ' ' + $p.Value}) -join ' ')" & {param( [string] - $ModulePath + $ModulePath, + + [string[]] + $Exclude = @('*.png', '*.mp4', '*.jpg','*.jpeg', '*.gif', 'docs[/\]*') ) + $gitHubEvent = if ($env:GITHUB_EVENT_PATH) { [IO.File]::ReadAllText($env:GITHUB_EVENT_PATH) | ConvertFrom-Json } else { $null } + if (-not $Exclude) { + $Exclude = @('*.png', '*.mp4', '*.jpg','*.jpeg', '*.gif','docs[/\]*') + } + @" ::group::GitHubEvent @@ -431,6 +494,12 @@ jobs: ::endgroup:: "@ | Out-Host + @" + ::group::PSBoundParameters + $($PSBoundParameters | ConvertTo-Json -Depth 100) + ::endgroup:: + "@ | Out-Host + if (-not ($gitHubEvent.head_commit.message -match "Merge Pull Request #(?\d+)") -and (-not $gitHubEvent.psobject.properties['inputs'])) { "::warning::Pull Request has not merged, skipping Gallery Publish" | Out-Host @@ -473,9 +542,24 @@ jobs: if (Test-Path $moduleGitPath) { Remove-Item -Recurse -Force $moduleGitPath } + + if ($Exclude) { + "::notice::Attempting to Exlcude $exclude" | Out-Host + Get-ChildItem $moduleTempPath -Recurse | + Where-Object { + foreach ($ex in $exclude) { + if ($_.FullName -like $ex) { + "::notice::Excluding $($_.FullName)" | Out-Host + return $true + } + } + } | + Remove-Item + } + Write-Host "Module Files:" Get-ChildItem $moduleTempPath -Recurse - Write-Host "Publishing $moduleName [$($imported.Version)] to Gallery" + Write-Host "Publishing $moduleName [$($imported.Version)] to Gallery" Publish-Module -Path $moduleTempPath -NuGetApiKey $gk if ($?) { Write-Host "Published to Gallery" @@ -495,8 +579,6 @@ jobs: uses: StartAutomating/PipeScript@main - name: UseEZOut uses: StartAutomating/EZOut@master - - name: UsePiecemeal - uses: StartAutomating/Piecemeal@main - name: UseHelpOut uses: StartAutomating/HelpOut@master diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a98e0d..05653f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 0.2.6: +* Set-NanoLeaf: + * Fixing -SaturationIncrement (#35) + * Adding -BrightnessIncrement (#34) + * Fixing -Hue/-Saturation/-Brightness behavior to allow increment parameters to work. (#36) + * Making Parameter Aliases consistent with Set-HueLight (#38) +* Now using [GitPub](https://github.com/StartAutomating/GitPub) to blog (#37). +--- + ## 0.2.5: * Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes #31) * Adding Rename-HueSensor (Fixes #26). diff --git a/Functions/NanoLeaf/Set-NanoLeaf.ps1 b/Functions/NanoLeaf/Set-NanoLeaf.ps1 index 3b00a9a..2c07861 100644 --- a/Functions/NanoLeaf/Set-NanoLeaf.ps1 +++ b/Functions/NanoLeaf/Set-NanoLeaf.ps1 @@ -61,6 +61,7 @@ [ComponentModel.AmbientValue({ [PSCustomObject]@{value=$_ % 360} })] + [Alias('H')] [int] $Hue, @@ -77,6 +78,7 @@ [ComponentModel.AmbientValue({ [PSCustomObject]@{value=[int][Math]::Round($_ * 100)} })] + [Alias('S')] [ValidateRange(0,1)] [double] $Saturation, @@ -84,7 +86,7 @@ # Increments the saturation of the NanoLeaf light color. [ComponentModel.DefaultBindingProperty('sat')] [ComponentModel.AmbientValue({ - [PSCustomObject]@{increment=[int][Math]::Round($_)} + [PSCustomObject]@{increment=[int][Math]::Round($_ * 100)} })] [int] $SaturationIncrement, @@ -94,9 +96,22 @@ # If provided with -Hue and -Saturation, sets the color of all panels. [Parameter(ValueFromPipelineByPropertyName)] [ValidateRange(0,1)] + [Alias('B','L','Luminance','.bri')] [double] $Brightness, + # The brightness increment. + # If no other parameters are provided, adjusts universal brightness. + [Parameter(ValueFromPipelineByPropertyName)] + [ComponentModel.DefaultBindingProperty('brightness')] + [ComponentModel.AmbientValue({ + [PSCustomObject]@{increment=[int][Math]::Round($_ * 100)} + })] + [Alias('LuminanceIncrement')] + [ValidateRange(-1,1)] + [double] + $BrightnessIncrement, + # If set, will change all panels on the nanoleaf to a given color temperature. [Parameter(ValueFromPipelineByPropertyName)] [ComponentModel.DefaultBindingProperty('ct')] @@ -336,8 +351,8 @@ } else { $sendData.brightness.duration = 0 } - } - + } + if ($on) { $sendData.on = @{value=$true} } @@ -345,25 +360,6 @@ $sendData.on = @{value=$false} } - #region Set HSB/HSL Color for all panels - if ($Hue -and $Saturation -and $Brightness) { - $hslData = @{ - write = [Ordered]@{ - command = 'display' - version = '1.0' - animType = "solid" - palette = @( - [Ordered]@{hue=$Hue%360;saturation=[int]($Saturation*100);brightness=[int]($Brightness*100)} - ) - colorType="HSB" - } - } | ConvertTo-Json -Depth 5 - - Send-NanoLeaf @ipAndToken -Command 'effects' -Data $hslData -Method PUT - return - } - #endregion Set HSB/HSL Color for all panels - $writeCommand = [Ordered]@{} if (-not $effectName) { $writeCommand.command = "display" diff --git a/GitHub/Jobs/RunGitPub.psd1 b/GitHub/Jobs/RunGitPub.psd1 new file mode 100644 index 0000000..01278fb --- /dev/null +++ b/GitHub/Jobs/RunGitPub.psd1 @@ -0,0 +1,32 @@ +@{ + "runs-on" = "ubuntu-latest" + if = '${{ success() }}' + steps = @( + @{ + name = 'Check out repository' + uses = 'actions/checkout@v2' + } + @{ + name = 'Use GitPub Action' + uses = 'StartAutomating/GitPub@main' + id = 'GitPub' + with = @{ + TargetBranch = 'edits-$([DateTime]::Now.ToString("r").Replace(":","-").Replace(" ", ""))' + CommitMessage = 'Posting with GitPub [skip ci]' + PublishParameters = @' +{ + "Get-GitPubIssue": { + "Repository": '${{github.repository}}' + }, + "Get-GitPubRelease": { + "Repository": '${{github.repository}}' + }, + "Publish-GitPubJekyll": { + "OutputPath": "docs/_posts" + } +} +'@ + } + } + ) +} \ No newline at end of file diff --git a/LightScript.GitHubWorkflow.psdevops.ps1 b/LightScript.GitHubWorkflow.psdevops.ps1 index 29152b0..957a3bc 100644 --- a/LightScript.GitHubWorkflow.psdevops.ps1 +++ b/LightScript.GitHubWorkflow.psdevops.ps1 @@ -1,13 +1,10 @@ #requires -Module PSDevOps Push-Location $PSScriptRoot - -New-GitHubWorkflow -Name "Analyze, Test, Tag, and Publish" -On Push, PullRequest, Demand -Job PowerShellStaticAnalysis, TestPowerShellOnLinux, TagReleaseAndPublish | +Import-BuildStep -Module LightScript +New-GitHubWorkflow -Name "Analyze, Test, Tag, and Publish" -On Push, PullRequest, Demand -Job PowerShellStaticAnalysis, TestPowerShellOnLinux, TagReleaseAndPublish, BuildModule | Set-Content .\.github\workflows\TestAndPublish.yml -Encoding UTF8 -PassThru -New-GitHubWorkflow -Name "Run HelpOut" -On Push -Job HelpOut | - Set-Content .\.github\workflows\UpdateDocs.yml -Encoding UTF8 -PassThru - -New-GitHubWorkflow -Name "Run EZOut" -On Push -Job RunEZOut | - Set-Content .\.github\workflows\RunEZOut.yml -Encoding UTF8 -PassThru +New-GitHubWorkflow -On Issue, Demand -Job RunGitPub -Name OnIssueChanged | + Set-Content (Join-Path $PSScriptRoot .github\workflows\OnIssue.yml) -Encoding UTF8 -PassThru Pop-Location \ No newline at end of file diff --git a/LightScript.psd1 b/LightScript.psd1 index 4c011cc..33d948d 100644 --- a/LightScript.psd1 +++ b/LightScript.psd1 @@ -1,5 +1,5 @@ @{ - ModuleVersion = '0.2.5' + ModuleVersion = '0.2.6' RootModule = 'LightScript.psm1' Description = 'Smarter Lighting with PowerShell' FormatsToProcess = 'LightScript.format.ps1xml' @@ -14,6 +14,15 @@ LicenseURI = 'https://github.com/StartAutomating/LightScript/blob/main/LICENSE' IconURI = 'https://github.com/StartAutomating/LightScript/blob/main/Assets/LightScript.png' ReleaseNotes = @' +## 0.2.6: +* Set-NanoLeaf: + * Fixing -SaturationIncrement (#35) + * Adding -BrightnessIncrement (#34) + * Fixing -Hue/-Saturation/-Brightness behavior to allow increment parameters to work. (#36) + * Making Parameter Aliases consistent with Set-HueLight (#38) +* Now using [GitPub](https://github.com/StartAutomating/GitPub) to blog (#37). +--- + ## 0.2.5: * Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes #31) * Adding Rename-HueSensor (Fixes #26). diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ce5094f..123a1ec 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,12 @@ +## 0.2.6: +* Set-NanoLeaf: + * Fixing -SaturationIncrement (#35) + * Adding -BrightnessIncrement (#34) + * Fixing -Hue/-Saturation/-Brightness behavior to allow increment parameters to work. (#36) + * Making Parameter Aliases consistent with Set-HueLight (#38) +* Now using [GitPub](https://github.com/StartAutomating/GitPub) to blog (#37). +--- + ## 0.2.5: * Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes #31) * Adding Rename-HueSensor (Fixes #26). diff --git a/docs/Set-NanoLeaf.md b/docs/Set-NanoLeaf.md index 61fef18..f53cdba 100644 --- a/docs/Set-NanoLeaf.md +++ b/docs/Set-NanoLeaf.md @@ -207,6 +207,24 @@ If provided with -Hue and -Saturation, sets the color of all panels. +--- +#### **BrightnessIncrement** + +The brightness increment. +If no other parameters are provided, adjusts universal brightness. + + + +> **Type**: ```[Double]``` + +> **Required**: false + +> **Position**: 6 + +> **PipelineInput**:true (ByPropertyName) + + + --- #### **ColorTemperature** @@ -218,7 +236,7 @@ If set, will change all panels on the nanoleaf to a given color temperature. > **Required**: false -> **Position**: 6 +> **Position**: 7 > **PipelineInput**:true (ByPropertyName) @@ -235,7 +253,7 @@ The name of the effect. > **Required**: false -> **Position**: 7 +> **Position**: 8 > **PipelineInput**:true (ByPropertyName) @@ -252,7 +270,7 @@ The duration to display. In most contexts, this will be rounded to the nearest > **Required**: false -> **Position**: 8 +> **Position**: 9 > **PipelineInput**:false @@ -287,7 +305,7 @@ The name of the effect plugin. > **Required**: false -> **Position**: 9 +> **Position**: 10 > **PipelineInput**:true (ByPropertyName) @@ -304,7 +322,7 @@ The palette used for an effect. > **Required**: false -> **Position**: 10 +> **Position**: 11 > **PipelineInput**:true (ByPropertyName) @@ -334,7 +352,7 @@ Valid Values: > **Required**: false -> **Position**: 11 +> **Position**: 12 > **PipelineInput**:true (ByPropertyName) @@ -351,7 +369,7 @@ The plugin UUID. > **Required**: false -> **Position**: 12 +> **Position**: 13 > **PipelineInput**:true (ByPropertyName) @@ -375,7 +393,7 @@ Valid Values: > **Required**: false -> **Position**: 13 +> **Position**: 14 > **PipelineInput**:true (ByPropertyName) @@ -395,7 +413,7 @@ Timespans will be ignored when sending colors via UDP. > **Required**: false -> **Position**: 14 +> **Position**: 15 > **PipelineInput**:true (ByPropertyName) @@ -425,7 +443,7 @@ Plugins can use any of the Nanoleaf-approved option types to further control how > **Required**: false -> **Position**: 15 +> **Position**: 16 > **PipelineInput**:true (ByPropertyName) @@ -476,7 +494,7 @@ The IP Address of the NanoLeaf. > **Required**: false -> **Position**: 16 +> **Position**: 17 > **PipelineInput**:true (ByPropertyName) @@ -493,7 +511,7 @@ The nanoleaf token > **Required**: false -> **Position**: 17 +> **Position**: 18 > **PipelineInput**:true (ByPropertyName) @@ -522,7 +540,7 @@ If the command sets a ```[ConfirmImpact("Medium")]``` which is lower than ```$co --- ### Syntax ```PowerShell -Set-NanoLeaf [-Off] [-On] [[-Hue] ] [[-HueIncrement] ] [[-Saturation] ] [[-SaturationIncrement] ] [[-Brightness] ] [[-ColorTemperature] ] [[-EffectName] ] [[-Duration] ] [-ExternalControl] [[-PluginName] ] [[-Palette] ] [[-EffectType] ] [[-PluginUuid] ] [[-PluginType] ] [[-Panel] ] [[-EffectOption] ] [-Loop] [-AsByteStream] [[-IPAddress] ] [[-NanoLeafToken] ] [-WhatIf] [-Confirm] [] +Set-NanoLeaf [-Off] [-On] [[-Hue] ] [[-HueIncrement] ] [[-Saturation] ] [[-SaturationIncrement] ] [[-Brightness] ] [[-BrightnessIncrement] ] [[-ColorTemperature] ] [[-EffectName] ] [[-Duration] ] [-ExternalControl] [[-PluginName] ] [[-Palette] ] [[-EffectType] ] [[-PluginUuid] ] [[-PluginType] ] [[-Panel] ] [[-EffectOption] ] [-Loop] [-AsByteStream] [[-IPAddress] ] [[-NanoLeafToken] ] [-WhatIf] [-Confirm] [] ``` --- diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..83650a3 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +permalink: pretty \ No newline at end of file