From b240486e77f97cd0a0cb1223546cac832405c46f Mon Sep 17 00:00:00 2001 From: Mike Madeja Date: Fri, 13 Jun 2025 02:06:19 -0500 Subject: [PATCH 1/3] updated release yml --- .github/workflows/CreateRelease.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CreateRelease.yml b/.github/workflows/CreateRelease.yml index 41bf8b2..4628f6c 100644 --- a/.github/workflows/CreateRelease.yml +++ b/.github/workflows/CreateRelease.yml @@ -3,14 +3,14 @@ permissions: contents: write on: - push: + pull_request: + types: [closed] branches: - main jobs: release: - # Only run if merge PR message includes 'develop' - if: startsWith(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'develop') + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && github.event.pull_request.head.ref == 'develop' runs-on: ubuntu-latest steps: @@ -61,4 +61,4 @@ jobs: name: "Release ${{ steps.bump.outputs.new_tag }}" files: output/release.zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f0e3bbafd3576f7ac0b0831d9273574acdd71d20 Mon Sep 17 00:00:00 2001 From: Mike Madeja Date: Sun, 15 Jun 2025 21:29:11 -0500 Subject: [PATCH 2/3] debugging --- .github/workflows/CreateRelease.yml | 2 +- .github/workflows/PSScriptAnalyzer.yml | 6 ++--- PiHoleShell/PiHoleShell.psd1 | 24 +++++++++++++++++++ {module => PiHoleShell}/PiHoleShell.psm1 | 0 .../functions/auth/Authentication.ps1 | 0 .../functions/configuration/Config.ps1 | 0 .../functions/dns/DnsControl.ps1 | 0 .../functions/groups/GroupManagement.ps1 | 0 .../functions/misc/Misc.ps1 | 0 .../functions/stats/Metrics.ps1 | 0 10 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 PiHoleShell/PiHoleShell.psd1 rename {module => PiHoleShell}/PiHoleShell.psm1 (100%) rename {module => PiHoleShell}/functions/auth/Authentication.ps1 (100%) rename {module => PiHoleShell}/functions/configuration/Config.ps1 (100%) rename {module => PiHoleShell}/functions/dns/DnsControl.ps1 (100%) rename {module => PiHoleShell}/functions/groups/GroupManagement.ps1 (100%) rename {module => PiHoleShell}/functions/misc/Misc.ps1 (100%) rename {module => PiHoleShell}/functions/stats/Metrics.ps1 (100%) diff --git a/.github/workflows/CreateRelease.yml b/.github/workflows/CreateRelease.yml index 4628f6c..61f990c 100644 --- a/.github/workflows/CreateRelease.yml +++ b/.github/workflows/CreateRelease.yml @@ -52,7 +52,7 @@ jobs: run: | mkdir -p output ls - zip -r output/release.zip module + zip -r output/release.zip PiHoleShell - name: Create GitHub Release uses: softprops/action-gh-release@v1 diff --git a/.github/workflows/PSScriptAnalyzer.yml b/.github/workflows/PSScriptAnalyzer.yml index 3d7ae24..ab99519 100644 --- a/.github/workflows/PSScriptAnalyzer.yml +++ b/.github/workflows/PSScriptAnalyzer.yml @@ -30,11 +30,11 @@ jobs: run: | (Get-ChildItem -Recurse).FullName Install-Module -Name PSScriptAnalyzer -Confirm:$true -Force - if (Test-Path -Path "C:\a\PiHoleShell\PiHoleShell\module") { - Invoke-ScriptAnalyzer -Path C:\a\PiHoleShell\PiHoleShell\module -Recurse -EnableExit + if (Test-Path -Path "C:\a\PiHoleShell\PiHoleShell\PiHoleShell") { + Invoke-ScriptAnalyzer -Path C:\a\PiHoleShell\PiHoleShell\PiHoleShell -Recurse -EnableExit } else { - Invoke-ScriptAnalyzer -Path D:\a\PiHoleShell\PiHoleShell\module -Recurse -EnableExit + Invoke-ScriptAnalyzer -Path D:\a\PiHoleShell\PiHoleShell\PiHoleShell -Recurse -EnableExit } \ No newline at end of file diff --git a/PiHoleShell/PiHoleShell.psd1 b/PiHoleShell/PiHoleShell.psd1 new file mode 100644 index 0000000..a7dadc4 --- /dev/null +++ b/PiHoleShell/PiHoleShell.psd1 @@ -0,0 +1,24 @@ +@{ + RootModule = 'PiHoleShell.psm1' + ModuleVersion = '0.0.0' + GUID = 'b3cecc78-fe8f-49c6-9015-3d66ef5d49cb' + Author = 'Mike Madeja' + Description = 'A module to interact with PiHole API' + CompatiblePSEditions = @('Core') # PowerShell 7+ only + + PowerShellVersion = '7.0' + + FunctionsToExport = @('Hello-World') + CmdletsToExport = @() + VariablesToExport = @() + AliasesToExport = @() + + PrivateData = @{ + PSData = @{ + Tags = @('Sample', 'HelloWorld', 'PowerShell7') + LicenseUri = 'https://opensource.org/licenses/MIT' + ProjectUri = 'https://github.com/yourname/MyModule' + ReleaseNotes = 'Initial release targeting PowerShell 7+' + } + } +} \ No newline at end of file diff --git a/module/PiHoleShell.psm1 b/PiHoleShell/PiHoleShell.psm1 similarity index 100% rename from module/PiHoleShell.psm1 rename to PiHoleShell/PiHoleShell.psm1 diff --git a/module/functions/auth/Authentication.ps1 b/PiHoleShell/functions/auth/Authentication.ps1 similarity index 100% rename from module/functions/auth/Authentication.ps1 rename to PiHoleShell/functions/auth/Authentication.ps1 diff --git a/module/functions/configuration/Config.ps1 b/PiHoleShell/functions/configuration/Config.ps1 similarity index 100% rename from module/functions/configuration/Config.ps1 rename to PiHoleShell/functions/configuration/Config.ps1 diff --git a/module/functions/dns/DnsControl.ps1 b/PiHoleShell/functions/dns/DnsControl.ps1 similarity index 100% rename from module/functions/dns/DnsControl.ps1 rename to PiHoleShell/functions/dns/DnsControl.ps1 diff --git a/module/functions/groups/GroupManagement.ps1 b/PiHoleShell/functions/groups/GroupManagement.ps1 similarity index 100% rename from module/functions/groups/GroupManagement.ps1 rename to PiHoleShell/functions/groups/GroupManagement.ps1 diff --git a/module/functions/misc/Misc.ps1 b/PiHoleShell/functions/misc/Misc.ps1 similarity index 100% rename from module/functions/misc/Misc.ps1 rename to PiHoleShell/functions/misc/Misc.ps1 diff --git a/module/functions/stats/Metrics.ps1 b/PiHoleShell/functions/stats/Metrics.ps1 similarity index 100% rename from module/functions/stats/Metrics.ps1 rename to PiHoleShell/functions/stats/Metrics.ps1 From e38dc70ca78470ea1157e5eecc03fa9519de4d13 Mon Sep 17 00:00:00 2001 From: Mike Madeja Date: Sun, 15 Jun 2025 21:52:22 -0500 Subject: [PATCH 3/3] updated to be more like a module --- PiHoleShell/PiHoleShell.psd1 | 8 ++++---- PiHoleShell/PiHoleShell.psm1 | 9 ++++----- PiHoleShell/{functions/misc => Private}/Misc.ps1 | 0 .../{functions/auth => Public}/Authentication.ps1 | 4 +--- .../{functions/configuration => Public}/Config.ps1 | 4 +--- PiHoleShell/{functions/dns => Public}/DnsControl.ps1 | 4 +--- .../{functions/groups => Public}/GroupManagement.ps1 | 4 +--- PiHoleShell/{functions/stats => Public}/Metrics.ps1 | 0 8 files changed, 12 insertions(+), 21 deletions(-) rename PiHoleShell/{functions/misc => Private}/Misc.ps1 (100%) rename PiHoleShell/{functions/auth => Public}/Authentication.ps1 (98%) rename PiHoleShell/{functions/configuration => Public}/Config.ps1 (96%) rename PiHoleShell/{functions/dns => Public}/DnsControl.ps1 (98%) rename PiHoleShell/{functions/groups => Public}/GroupManagement.ps1 (99%) rename PiHoleShell/{functions/stats => Public}/Metrics.ps1 (100%) diff --git a/PiHoleShell/PiHoleShell.psd1 b/PiHoleShell/PiHoleShell.psd1 index a7dadc4..d48b9ad 100644 --- a/PiHoleShell/PiHoleShell.psd1 +++ b/PiHoleShell/PiHoleShell.psd1 @@ -8,16 +8,16 @@ PowerShellVersion = '7.0' - FunctionsToExport = @('Hello-World') + FunctionsToExport = @('Get-PiHoleGroup', 'New-PiHoleGroup', 'Update-PiHoleGroup', 'Remove-PiHoleGroup', 'Get-PiHoleDnsBlockingStatus', 'Set-PiHoleDnsBlocking', 'Get-PiHoleConfig', 'Get-PiHoleCurrentAuthSession', 'Remove-PiHoleAuthSession') CmdletsToExport = @() VariablesToExport = @() AliasesToExport = @() PrivateData = @{ PSData = @{ - Tags = @('Sample', 'HelloWorld', 'PowerShell7') - LicenseUri = 'https://opensource.org/licenses/MIT' - ProjectUri = 'https://github.com/yourname/MyModule' + Tags = @('PiHole', 'PowerShell7') + LicenseUri = 'https://github.com/mikemadeja/PiHoleShell/blob/main/LICENSE' + ProjectUri = 'https://github.com/mikemadeja/PiHoleShell' ReleaseNotes = 'Initial release targeting PowerShell 7+' } } diff --git a/PiHoleShell/PiHoleShell.psm1 b/PiHoleShell/PiHoleShell.psm1 index 2729d5e..9e83669 100644 --- a/PiHoleShell/PiHoleShell.psm1 +++ b/PiHoleShell/PiHoleShell.psm1 @@ -1,7 +1,6 @@ -if (-not $PSVersionTable -or $PSVersionTable.PSVersion.Major -lt 7) { - Write-Error "This script requires PowerShell 7 or higher. Current version: $($PSVersionTable.PSVersion)" - exit 1 +if ($PSVersionTable.PSEdition -ne 'Core') { + throw "PiHoleShell module only supports PowerShell Core 7+. You are using $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)." } -# Import all the commands -Get-ChildItem $PSScriptRoot\functions\*.ps1 -Recurse | ForEach-Object { . $_.FullName } \ No newline at end of file +Get-ChildItem $PSScriptRoot\Private\*.ps1 -Recurse | ForEach-Object { . $_.FullName } +Get-ChildItem $PSScriptRoot\Public\*.ps1 -Recurse | ForEach-Object { . $_.FullName } \ No newline at end of file diff --git a/PiHoleShell/functions/misc/Misc.ps1 b/PiHoleShell/Private/Misc.ps1 similarity index 100% rename from PiHoleShell/functions/misc/Misc.ps1 rename to PiHoleShell/Private/Misc.ps1 diff --git a/PiHoleShell/functions/auth/Authentication.ps1 b/PiHoleShell/Public/Authentication.ps1 similarity index 98% rename from PiHoleShell/functions/auth/Authentication.ps1 rename to PiHoleShell/Public/Authentication.ps1 index 8dc0807..6eb1263 100644 --- a/PiHoleShell/functions/auth/Authentication.ps1 +++ b/PiHoleShell/Public/Authentication.ps1 @@ -185,6 +185,4 @@ Get-PiHoleCurrentAuthSession -PiHoleServer "http://pihole.domain.com:8080" -Pass Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl } } -} - -Export-ModuleMember -Function Get-PiHoleCurrentAuthSession, Remove-PiHoleAuthSession \ No newline at end of file +} \ No newline at end of file diff --git a/PiHoleShell/functions/configuration/Config.ps1 b/PiHoleShell/Public/Config.ps1 similarity index 96% rename from PiHoleShell/functions/configuration/Config.ps1 rename to PiHoleShell/Public/Config.ps1 index 81fd60f..07462f8 100644 --- a/PiHoleShell/functions/configuration/Config.ps1 +++ b/PiHoleShell/Public/Config.ps1 @@ -44,6 +44,4 @@ https://TODO Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl } } -} - -Export-ModuleMember -Function Get-PiHoleConfig \ No newline at end of file +} \ No newline at end of file diff --git a/PiHoleShell/functions/dns/DnsControl.ps1 b/PiHoleShell/Public/DnsControl.ps1 similarity index 98% rename from PiHoleShell/functions/dns/DnsControl.ps1 rename to PiHoleShell/Public/DnsControl.ps1 index 3372dee..cca20bf 100644 --- a/PiHoleShell/functions/dns/DnsControl.ps1 +++ b/PiHoleShell/Public/DnsControl.ps1 @@ -149,6 +149,4 @@ Set-PiHoleDnsBlocking -PiHoleServer "http://pihole.domain.com:8080" -Password "f Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl } } -} - -Export-ModuleMember -Function Get-PiHoleDnsBlockingStatus, Set-PiHoleDnsBlocking \ No newline at end of file +} \ No newline at end of file diff --git a/PiHoleShell/functions/groups/GroupManagement.ps1 b/PiHoleShell/Public/GroupManagement.ps1 similarity index 99% rename from PiHoleShell/functions/groups/GroupManagement.ps1 rename to PiHoleShell/Public/GroupManagement.ps1 index 785b0ed..8d9a52d 100644 --- a/PiHoleShell/functions/groups/GroupManagement.ps1 +++ b/PiHoleShell/Public/GroupManagement.ps1 @@ -337,6 +337,4 @@ https://TODO Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl } } -} - -Export-ModuleMember -Function Get-PiHoleGroup, New-PiHoleGroup, Update-PiHoleGroup, Remove-PiHoleGroup \ No newline at end of file +} \ No newline at end of file diff --git a/PiHoleShell/functions/stats/Metrics.ps1 b/PiHoleShell/Public/Metrics.ps1 similarity index 100% rename from PiHoleShell/functions/stats/Metrics.ps1 rename to PiHoleShell/Public/Metrics.ps1