diff --git a/.github/workflows/CreateRelease.yml b/.github/workflows/CreateRelease.yml index 41bf8b2..61f990c 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: @@ -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 @@ -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 }} 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..d48b9ad --- /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 = @('Get-PiHoleGroup', 'New-PiHoleGroup', 'Update-PiHoleGroup', 'Remove-PiHoleGroup', 'Get-PiHoleDnsBlockingStatus', 'Set-PiHoleDnsBlocking', 'Get-PiHoleConfig', 'Get-PiHoleCurrentAuthSession', 'Remove-PiHoleAuthSession') + CmdletsToExport = @() + VariablesToExport = @() + AliasesToExport = @() + + PrivateData = @{ + PSData = @{ + Tags = @('PiHole', 'PowerShell7') + LicenseUri = 'https://github.com/mikemadeja/PiHoleShell/blob/main/LICENSE' + ProjectUri = 'https://github.com/mikemadeja/PiHoleShell' + ReleaseNotes = 'Initial release targeting PowerShell 7+' + } + } +} \ No newline at end of file diff --git a/PiHoleShell/PiHoleShell.psm1 b/PiHoleShell/PiHoleShell.psm1 new file mode 100644 index 0000000..9e83669 --- /dev/null +++ b/PiHoleShell/PiHoleShell.psm1 @@ -0,0 +1,6 @@ +if ($PSVersionTable.PSEdition -ne 'Core') { + throw "PiHoleShell module only supports PowerShell Core 7+. You are using $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)." +} + +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/module/functions/misc/Misc.ps1 b/PiHoleShell/Private/Misc.ps1 similarity index 100% rename from module/functions/misc/Misc.ps1 rename to PiHoleShell/Private/Misc.ps1 diff --git a/module/functions/auth/Authentication.ps1 b/PiHoleShell/Public/Authentication.ps1 similarity index 98% rename from module/functions/auth/Authentication.ps1 rename to PiHoleShell/Public/Authentication.ps1 index 8dc0807..6eb1263 100644 --- a/module/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/module/functions/configuration/Config.ps1 b/PiHoleShell/Public/Config.ps1 similarity index 96% rename from module/functions/configuration/Config.ps1 rename to PiHoleShell/Public/Config.ps1 index 81fd60f..07462f8 100644 --- a/module/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/module/functions/dns/DnsControl.ps1 b/PiHoleShell/Public/DnsControl.ps1 similarity index 98% rename from module/functions/dns/DnsControl.ps1 rename to PiHoleShell/Public/DnsControl.ps1 index 3372dee..cca20bf 100644 --- a/module/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/module/functions/groups/GroupManagement.ps1 b/PiHoleShell/Public/GroupManagement.ps1 similarity index 99% rename from module/functions/groups/GroupManagement.ps1 rename to PiHoleShell/Public/GroupManagement.ps1 index 785b0ed..8d9a52d 100644 --- a/module/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/module/functions/stats/Metrics.ps1 b/PiHoleShell/Public/Metrics.ps1 similarity index 100% rename from module/functions/stats/Metrics.ps1 rename to PiHoleShell/Public/Metrics.ps1 diff --git a/module/PiHoleShell.psm1 b/module/PiHoleShell.psm1 deleted file mode 100644 index 2729d5e..0000000 --- a/module/PiHoleShell.psm1 +++ /dev/null @@ -1,7 +0,0 @@ -if (-not $PSVersionTable -or $PSVersionTable.PSVersion.Major -lt 7) { - Write-Error "This script requires PowerShell 7 or higher. Current version: $($PSVersionTable.PSVersion)" - exit 1 -} - -# Import all the commands -Get-ChildItem $PSScriptRoot\functions\*.ps1 -Recurse | ForEach-Object { . $_.FullName } \ No newline at end of file