From fbe0fb09e4f46ca0aa484d471fab2d4d7ef8c097 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 26 Mar 2022 10:35:29 +0100 Subject: [PATCH 01/21] fixed formatting --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 079807e..7098f77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - - Added test reports to pester tests. ## [1.0.0] - 2022-03-13 From e190c9ee9a059308d645ce31794855dc02034f89 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 26 Mar 2022 10:44:01 +0100 Subject: [PATCH 02/21] fixed changelog linting errors --- .markdownlint.json | 6 ++++++ CHANGELOG.md | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 .markdownlint.json diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..36eb18a --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,6 @@ +{ + "default": true, + "MD024": { + "siblings_only": true + } +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7098f77..eca8b0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + ## [1.1.0] - 2022-03-19 ### Added From f49f571d80d6b9203ba1c85618102c2c42ea3d3f Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 26 Mar 2022 10:44:12 +0100 Subject: [PATCH 03/21] fixed spellcheck --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..80d6be7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cSpell.language": "en" +} \ No newline at end of file From f48f52443b2e26ecdf5b4afbce070bee3e10f4d2 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 26 Mar 2022 10:49:11 +0100 Subject: [PATCH 04/21] simplified markdown linting --- .markdownlint.json | 6 ------ CHANGELOG.md | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 .markdownlint.json diff --git a/.markdownlint.json b/.markdownlint.json deleted file mode 100644 index 36eb18a..0000000 --- a/.markdownlint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "default": true, - "MD024": { - "siblings_only": true - } -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index eca8b0e..9adca4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,3 +19,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - VSCode Tasks. - GitHub Action Workflows. + + From 83294cfdb6a8df8a1ab028e2b15061291507aa9d Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 26 Mar 2022 19:07:16 +0100 Subject: [PATCH 05/21] fixed vscode linux --- .vscode/settings.json | 5 ++++- CHANGELOG.md | 4 ++++ VsCode/tasks.json | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 80d6be7..793f4fb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "cSpell.language": "en" + "cSpell.language": "en", + "cSpell.words": [ + "pwsh" + ] } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 9adca4e..351ea3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- VsCode test task for linux environments. + ## [1.1.0] - 2022-03-19 ### Added diff --git a/VsCode/tasks.json b/VsCode/tasks.json index 751ece7..f95aa31 100644 --- a/VsCode/tasks.json +++ b/VsCode/tasks.json @@ -63,7 +63,7 @@ "type": "shell", "command": "Invoke-Pester", "options": { - "cwd": "test" + "cwd": "${workspaceFolder}/test" }, "problemMatcher": "$msCompile", "presentation": { @@ -71,6 +71,6 @@ "showReuseMessage": false }, "dependsOn": "Build" - }, + } ] } From 114d0fc27317733041cb7c1e73549062dafa6230 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sun, 27 Mar 2022 21:20:58 +0200 Subject: [PATCH 06/21] added funding info --- .github/FUNDING.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..2090df5 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [abbgrade] From 994e2013f0bdda5aa68e33363b0268a82e02be2c Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 23 Jul 2022 21:16:12 +0200 Subject: [PATCH 07/21] added module --- src/PsBuildTasks.psd1 | 132 ++++++++++++++++++++++++++++++++++++ src/PsBuildTasks.psm1 | 18 +++++ src/Public/Install-Task.ps1 | 23 +++++++ test/Install-Task.Tests.ps1 | 22 ++++++ test/Module.Tests.ps1 | 11 +++ 5 files changed, 206 insertions(+) create mode 100644 src/PsBuildTasks.psd1 create mode 100644 src/PsBuildTasks.psm1 create mode 100644 src/Public/Install-Task.ps1 create mode 100644 test/Install-Task.Tests.ps1 create mode 100644 test/Module.Tests.ps1 diff --git a/src/PsBuildTasks.psd1 b/src/PsBuildTasks.psd1 new file mode 100644 index 0000000..471dbca --- /dev/null +++ b/src/PsBuildTasks.psd1 @@ -0,0 +1,132 @@ +# +# Module manifest for module 'PsBuildTasks' +# +# Generated by: Steffen Kampmann +# +# Generated on: 23.07.2022 +# + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'PsBuildTasks.psm1' + +# Version number of this module. +ModuleVersion = '0.0.1' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = '6ca0d31a-df26-4d88-8e99-0fee9cdb0e3f' + +# Author of this module +Author = 'Steffen Kampmann' + +# Company or vendor of this module +CompanyName = '' + +# Copyright statement for this module +Copyright = '(c) Steffen Kampmann. All rights reserved.' + +# Description of the functionality provided by this module +# Description = '' + +# Minimum version of the PowerShell engine required by this module +# PowerShellVersion = '' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# ClrVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = '*' + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = 'Install-Task' + +# Variables to export from this module +VariablesToExport = '*' + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = '*' + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'sql-server' + + # A URL to the license for this module. + LicenseUri = 'https://github.com/abbgrade/PsBuildTasks/blob/master/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/abbgrade/PsBuildTasks' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +DefaultCommandPrefix = 'PsBuild' + +} + diff --git a/src/PsBuildTasks.psm1 b/src/PsBuildTasks.psm1 new file mode 100644 index 0000000..32a2339 --- /dev/null +++ b/src/PsBuildTasks.psm1 @@ -0,0 +1,18 @@ +foreach ( $folder in @('Internal', 'Public') ) { + $folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folder + if (Test-Path -Path $folderPath) { + Write-Verbose "Importing from $folder" + foreach ( $function in Get-ChildItem -Path $folderPath -Filter '*.ps1' ) { + Write-Verbose " Importing $( $function.BaseName )" + . $function.FullName + + switch ( $folder ) { + Public { + if ( ( Get-Command -Module $null | Where-Object { $_.Name -eq $function.BaseName } ) ) { + Export-ModuleMember -Function $function.BaseName + } + } + } + } + } +} diff --git a/src/Public/Install-Task.ps1 b/src/Public/Install-Task.ps1 new file mode 100644 index 0000000..6ffcd40 --- /dev/null +++ b/src/Public/Install-Task.ps1 @@ -0,0 +1,23 @@ +function Install-Task { + [CmdletBinding()] + param ( + [Parameter( Mandatory )] + [System.IO.DirectoryInfo] $Path, + + [Parameter( Mandatory )] + [ValidateSet('PowerShell-Matrix', 'Dotnet-Matrix')] + [string] $Task + ) + + $tasksDirectory = Join-Path $Path 'tasks' + + if ( -not ( Test-Path $tasksDirectory )) { + New-Item -ItemType Directory $tasksDirectory + } + + $taskFile = Join-Path $tasksDirectory 'PsBuild.Tasks.ps1' + + Invoke-WebRequest ` + -Uri "https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/tasks/$Task.Tasks.ps1" ` + -OutFile $taskFile +} \ No newline at end of file diff --git a/test/Install-Task.Tests.ps1 b/test/Install-Task.Tests.ps1 new file mode 100644 index 0000000..4f23fc9 --- /dev/null +++ b/test/Install-Task.Tests.ps1 @@ -0,0 +1,22 @@ +#Requires -Modules @{ ModuleName='Pester'; ModuleVersion='5.0.0' } + +Describe Install-Task { + + BeforeAll { + Import-Module $PSScriptRoot\..\src\PsBuildTasks.psd1 -Force -ErrorAction Stop -PassThru + } + + It exists { + Get-Command -Module PsBuildTasks -Name Install-PsBuildTask -ErrorAction Stop + } + + It PowerShell-Matrix { + Install-PsBuildTask -Path "TestDrive:\" -Task PowerShell-Matrix -ErrorAction Stop + "TestDrive:\tasks\PsBuild.Tasks.ps1" | Should -Exist + } + + It Dotnet-Matrix { + Install-PsBuildTask -Path "TestDrive:\" -Task Dotnet-Matrix -ErrorAction Stop + "TestDrive:\tasks\PsBuild.Tasks.ps1" | Should -Exist + } +} \ No newline at end of file diff --git a/test/Module.Tests.ps1 b/test/Module.Tests.ps1 new file mode 100644 index 0000000..a4672fd --- /dev/null +++ b/test/Module.Tests.ps1 @@ -0,0 +1,11 @@ +#Requires -Modules @{ ModuleName='Pester'; ModuleVersion='5.0.0' } + +Describe ModuleManifest { + It isValid { + $Manifest = Test-ModuleManifest -Path "$PSScriptRoot\..\src\PsBuildTasks.psd1" -ErrorAction Stop + $Manifest.RootModule | Should -Not -BeNullOrEmpty + $Manifest.Prefix | Should -Be 'PsBuild' + $Manifest | Should -Not -BeNullOrEmpty + $? | Should -Be $true + } +} \ No newline at end of file From 2595e2519ad7f3fede0762116a78d2f0cd9c6623 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 08:42:50 +0200 Subject: [PATCH 08/21] self apply tasks --- .build.ps1 | 5 ++ .github/workflows/build-validation.yml | 9 +++ .github/workflows/pre-release.yml | 13 +++++ .github/workflows/release.yml | 13 +++++ .gitignore | 1 + .vscode/tasks.json | 76 ++++++++++++++++++++++++++ tasks/Build.Tasks.ps1 | 73 +++++++++++++++++++++++++ 7 files changed, 190 insertions(+) create mode 100644 .build.ps1 create mode 100644 .github/workflows/build-validation.yml create mode 100644 .github/workflows/pre-release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100644 .vscode/tasks.json create mode 100644 tasks/Build.Tasks.ps1 diff --git a/.build.ps1 b/.build.ps1 new file mode 100644 index 0000000..cbbf7c3 --- /dev/null +++ b/.build.ps1 @@ -0,0 +1,5 @@ + +$ModuleName = 'PsBuildTasks' + +. $PSScriptRoot/tasks/PowerShell-Matrix.Tasks.ps1 +. $PSScriptRoot/tasks/Build.Tasks.ps1 diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml new file mode 100644 index 0000000..363e3f7 --- /dev/null +++ b/.github/workflows/build-validation.yml @@ -0,0 +1,9 @@ +on: + push: + branches: [ develop, bugfix/*, feature/*, release/* ] + pull_request: + branches: [ develop ] + +jobs: + build-validation: + uses: abbgrade/PsBuildTasks/.github/workflows/build-validation-matrix.yml@v1.1 diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000..381dc37 --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,13 @@ +on: + push: + branches: [ release/* ] + workflow_dispatch: + +jobs: + pre-release: + uses: abbgrade/PsBuildTasks/.github/workflows/pre-release-windows.yml@v1.1 + with: + module-name: PsBuildTasks + secrets: + ps-gallery-key: ${{ secrets.PS_GALLERY_KEY }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ff646e7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,13 @@ +on: + push: + branches: [ main ] + workflow_dispatch: + +jobs: + release: + uses: abbgrade/PsBuildTasks/.github/workflows/release-windows.yml@v1.1 + with: + module-name: PsBuildTasks + secrets: + ps-gallery-key: ${{ secrets.PS_GALLERY_KEY }} + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06d09f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +publish diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..751ece7 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,76 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "windows": { + "options": { + "shell": { + "executable": "pwsh.exe", + "args": [ + "-NoProfile", + "-ExecutionPolicy Bypass", + "-NonInteractive", + "-Command" + ] + } + } + }, + "linux": { + "options": { + "shell": { + "executable": "/usr/bin/pwsh", + "args": [ "-NoProfile", "-Command" ] + } + } + }, + "osx": { + "options": { + "shell": { + "executable": "/usr/local/bin/pwsh", + "args": [ "-NoProfile", "-Command" ] + } + } + }, + "tasks": [ + { + "label": "Build", + "type": "shell", + "group": "build", + "command": "Invoke-Build Build", + "problemMatcher": [] + }, + { + "label": "Clean", + "type": "shell", + "command": "Invoke-Build Clean", + "problemMatcher": [] + }, + { + "label": "Install", + "type": "shell", + "command": "Invoke-Build Install", + "problemMatcher": [] + }, + { + "label": "Update docs", + "type": "shell", + "command": "Invoke-Build UpdateDocs", + "problemMatcher": [] + }, + { + "label": "Test", + "group": "test", + "type": "shell", + "command": "Invoke-Pester", + "options": { + "cwd": "test" + }, + "problemMatcher": "$msCompile", + "presentation": { + "echo": false, + "showReuseMessage": false + }, + "dependsOn": "Build" + }, + ] +} diff --git a/tasks/Build.Tasks.ps1 b/tasks/Build.Tasks.ps1 new file mode 100644 index 0000000..5356f14 --- /dev/null +++ b/tasks/Build.Tasks.ps1 @@ -0,0 +1,73 @@ +requires ModuleName + +[System.IO.DirectoryInfo] $SourceDirectory = "$PsScriptRoot\..\src" +[System.IO.DirectoryInfo] $SourceManifest = "$SourceDirectory\$ModuleName.psd1" +[System.IO.DirectoryInfo] $PublishDirectory = "$PsScriptRoot\..\publish" +[System.IO.DirectoryInfo] $DocumentationDirectory = "$PsScriptRoot\..\docs" +[System.IO.DirectoryInfo] $ModulePublishDirectory = "$PublishDirectory\$ModuleName" + +# Synopsis: Remove all temporary files. +task Clean -Jobs { + remove $PublishDirectory, $DocumentationDirectory +} + +# Synopsis: Import the module. +task Import -Jobs { + Import-Module $SourceManifest -Force +} + +# Synopsis: Import platyPs. +task Import.platyPs -Jobs { + Import-Module platyPs +} + +# Synopsis: Initialize the documentation directory. +task Doc.Init.Directory -If { $DocumentationDirectory.Exists -eq $false} -Jobs { + New-Item $DocumentationDirectory -ItemType Directory +} + +# Synopsis: Initialize the documentation. +task Doc.Init -Jobs Import, Import.platyPs, Doc.Init.Directory, { + New-MarkdownHelp -Module $ModuleName -OutputFolder $DocumentationDirectory -Force:$ForceDocInit -ErrorAction Continue +} + +# Synopsis: Update the markdown documentation. +task Doc.Update -Jobs Import, Import.platyPs, Doc.Init, { + Update-MarkdownHelp -Path $DocumentationDirectory +} + +task PreparePublishDirectory -If ( -Not ( Test-Path $PublishDirectory )) -Jobs { + New-Item -Path $PublishDirectory -ItemType Directory | Out-Null +} + +# Synopsis: Set the prerelease in the manifest based on the build number. +task SetPrerelease -If $BuildNumber { + $Global:PreRelease = "alpha$( '{0:d4}' -f $BuildNumber )" + Update-ModuleManifest -Path $Global:Manifest -Prerelease $Global:PreRelease +} + +# Synopsis: Build the module. +task Build -Jobs Clean, Doc.Update, PreparePublishDirectory, { + Copy-Item -Path $SourceDirectory -Destination $ModulePublishDirectory -Recurse + [System.IO.FileInfo] $Global:Manifest = "$ModulePublishDirectory\$ModuleName.psd1" +}, SetPrerelease + +# Synopsis: Install the module. +task Install -Jobs Build, { + $info = Import-PowerShellDataFile $Global:Manifest + $version = ([System.Version] $info.ModuleVersion) + $defaultModulePath = $env:PsModulePath -split ';' | Select-Object -First 1 + Write-Verbose "install $ModuleName $version to $defaultModulePath" + $installPath = Join-Path $defaultModulePath $ModuleName $version.ToString() + New-Item -Type Directory $installPath -Force | Out-Null + Get-ChildItem $Global:Manifest.Directory | Copy-Item -Destination $installPath -Recurse -Force +} + +# Synopsis: Publish the module to PSGallery. +task Publish -Jobs Clean, Build, { + if ( -Not $Global:PreRelease ) { + assert ( $Configuration -eq 'Release' ) + Update-ModuleManifest -Path $Global:Manifest -Prerelease '' + } + Publish-Module -Path $Global:Manifest.Directory -NuGetApiKey $NuGetApiKey -Force:$ForcePublish +} From fb09aa3def8e5f49795ae80a4fd6f55a76600d48 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 08:43:04 +0200 Subject: [PATCH 09/21] added docs --- docs/Install-PsBuildTask.md | 72 +++++++++++++++++++++++++++++++++++++ src/Public/Install-Task.ps1 | 13 +++++++ 2 files changed, 85 insertions(+) create mode 100644 docs/Install-PsBuildTask.md diff --git a/docs/Install-PsBuildTask.md b/docs/Install-PsBuildTask.md new file mode 100644 index 0000000..d19f6b3 --- /dev/null +++ b/docs/Install-PsBuildTask.md @@ -0,0 +1,72 @@ +--- +external help file: PsBuildTasks-help.xml +Module Name: PsBuildTasks +online version: +schema: 2.0.0 +--- + +# Install-PsBuildTask + +## SYNOPSIS +Install PsBuildTasks task file. + +## SYNTAX + +``` +Install-PsBuildTask [-Path] [-Task] [] +``` + +## DESCRIPTION +Downloads a task file and saves it to the tasks directory. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Path +Path to the tasks directory. + +```yaml +Type: DirectoryInfo +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Task +Name of the task file to install. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/src/Public/Install-Task.ps1 b/src/Public/Install-Task.ps1 index 6ffcd40..97b2c12 100644 --- a/src/Public/Install-Task.ps1 +++ b/src/Public/Install-Task.ps1 @@ -1,9 +1,22 @@ function Install-Task { + + <# + + .SYNOPSIS + Install PsBuildTasks task file. + + .DESCRIPTION + Downloads a task file and saves it to the tasks directory. + + #> + [CmdletBinding()] param ( + # Path to the tasks directory. [Parameter( Mandatory )] [System.IO.DirectoryInfo] $Path, + # Name of the task file to install. [Parameter( Mandatory )] [ValidateSet('PowerShell-Matrix', 'Dotnet-Matrix')] [string] $Task From 5f1bfa704d63f1650ac9bf0ee70b0b40e1b3aa14 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 08:46:35 +0200 Subject: [PATCH 10/21] updated dependencies --- .build.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.build.ps1 b/.build.ps1 index cbbf7c3..37486f8 100644 --- a/.build.ps1 +++ b/.build.ps1 @@ -3,3 +3,7 @@ $ModuleName = 'PsBuildTasks' . $PSScriptRoot/tasks/PowerShell-Matrix.Tasks.ps1 . $PSScriptRoot/tasks/Build.Tasks.ps1 + +task InstallBuildDependencies {} +task InstallTestDependencies {} +task InstallReleaseDependencies {} \ No newline at end of file From c4c5c1f1cecfc20ee4dfbd4e4ede795da55385a6 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 08:48:27 +0200 Subject: [PATCH 11/21] updated build depenencies --- .build.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.build.ps1 b/.build.ps1 index 37486f8..4a0e38f 100644 --- a/.build.ps1 +++ b/.build.ps1 @@ -4,6 +4,8 @@ $ModuleName = 'PsBuildTasks' . $PSScriptRoot/tasks/PowerShell-Matrix.Tasks.ps1 . $PSScriptRoot/tasks/Build.Tasks.ps1 -task InstallBuildDependencies {} +task InstallBuildDependencies { + Install-Module platyPs -Scope CurrentUser +} task InstallTestDependencies {} task InstallReleaseDependencies {} \ No newline at end of file From 4838d4886c1f570379f7a6f1d37635e4331bb13e Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 08:58:05 +0200 Subject: [PATCH 12/21] updated version information --- CHANGELOG.md | 3 +++ src/PsBuildTasks.psd1 | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 335c8d6..80a15ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.0] - 2022-07-30 + ### Added - Update tasks. - GitHub Pages config. - Dependabot config. +- PowerShell module with install command. ### Fixed diff --git a/src/PsBuildTasks.psd1 b/src/PsBuildTasks.psd1 index 471dbca..4ae2668 100644 --- a/src/PsBuildTasks.psd1 +++ b/src/PsBuildTasks.psd1 @@ -12,7 +12,7 @@ RootModule = 'PsBuildTasks.psm1' # Version number of this module. -ModuleVersion = '0.0.1' +ModuleVersion = '1.2.0' # Supported PSEditions # CompatiblePSEditions = @() From 5e1dcdacb5813989ae58aa384186ddefc484bddb Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 09:01:34 +0200 Subject: [PATCH 13/21] added build number parameter --- .build.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.build.ps1 b/.build.ps1 index 4a0e38f..fbc735d 100644 --- a/.build.ps1 +++ b/.build.ps1 @@ -1,4 +1,10 @@ +[CmdletBinding()] +param ( + [Parameter()] + [int] $BuildNumber +) + $ModuleName = 'PsBuildTasks' . $PSScriptRoot/tasks/PowerShell-Matrix.Tasks.ps1 From 4d1bc3dc94da50cbf4deda8d9bfe86d7a280a000 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 09:07:57 +0200 Subject: [PATCH 14/21] updated manifest --- src/PsBuildTasks.psd1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PsBuildTasks.psd1 b/src/PsBuildTasks.psd1 index 4ae2668..c14d681 100644 --- a/src/PsBuildTasks.psd1 +++ b/src/PsBuildTasks.psd1 @@ -30,7 +30,7 @@ CompanyName = '' Copyright = '(c) Steffen Kampmann. All rights reserved.' # Description of the functionality provided by this module -# Description = '' +Description = 'Manage PsBuildTasks' # Minimum version of the PowerShell engine required by this module # PowerShellVersion = '' @@ -95,7 +95,7 @@ PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. - Tags = 'sql-server' + Tags = 'powershell', 'github', 'devops' # A URL to the license for this module. LicenseUri = 'https://github.com/abbgrade/PsBuildTasks/blob/master/LICENSE' From de22e8ed1e01632da7a46bbdd0d09fe0ea53ffb3 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 09:29:00 +0200 Subject: [PATCH 15/21] updated readme --- Readme.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Readme.md b/Readme.md index b6ab5e5..5bddfbb 100644 --- a/Readme.md +++ b/Readme.md @@ -7,6 +7,26 @@ This includes: - [InvokeBuild](https://github.com/nightroman/Invoke-Build) tasks. - [GitHub Actions](https://docs.github.com/en/actions) workflows. +## Getting Started + +There is a PowerShell module to manage PsBuildTasks and helps with it's installation. +Get it with `Install-Module -Name PsBuildTasks`. +The next step depends on your project. + +1. If your project is written in PowerShell or DotNet/C#. +2. If your project supports only Windows or is cross platform and requires matrix tests on Windows and Linux. + +There are container tasks that update multiple features of PsBuildTasks + +### PowerShell Matrix + +Go to the project root directory + +```powershell +Import-Module -Name PsBuildTasks +Install-PsBuildTask -Path ./tasks -Task PowerShell-Matrix +``` + ## InvokeBuild Tasks It provides the following tasks: From 52c0f2e908ecc1be180b2c36be3ec0845736e266 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 09:37:13 +0200 Subject: [PATCH 16/21] fix readme --- Readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 5bddfbb..eb039ef 100644 --- a/Readme.md +++ b/Readme.md @@ -24,7 +24,8 @@ Go to the project root directory ```powershell Import-Module -Name PsBuildTasks -Install-PsBuildTask -Path ./tasks -Task PowerShell-Matrix +Install-PsBuildTask -Path . -Task PowerShell-Matrix +Invoke-Build -File .\tasks\PsBuild.Tasks.ps1 -Task UpdatePsBuildTasks ``` ## InvokeBuild Tasks From fb0767a258df19fb95f75f5cd96e14cc43e37bf8 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 09:38:13 +0200 Subject: [PATCH 17/21] added directory creation --- CHANGELOG.md | 1 + tasks/PowerShell-Matrix.Tasks.ps1 | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80a15ec..9a2f946 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Dotnet-Matrix.Tasks does not fail in empty project. +- PowerShell-Matrix.Tasks does not fail in empty project. - Wrong file separators for linux. ## [1.1.0] - 2022-03-19 diff --git a/tasks/PowerShell-Matrix.Tasks.ps1 b/tasks/PowerShell-Matrix.Tasks.ps1 index 1fc9769..e1691c0 100644 --- a/tasks/PowerShell-Matrix.Tasks.ps1 +++ b/tasks/PowerShell-Matrix.Tasks.ps1 @@ -10,23 +10,29 @@ task UpdateBuildTasks { #region GitHub Actions task UpdateValidationWorkflow { + [System.IO.FileInfo] $file = "$PSScriptRoot/../.github/workflows/build-validation.yml" + New-Item -Type Directory $file.Directory -ErrorAction SilentlyContinue Invoke-WebRequest ` -Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/build-validation-matrix.yml' ` - -OutFile "$PSScriptRoot\..\.github\workflows\build-validation.yml" + -OutFile $file } task UpdatePreReleaseWorkflow { + [System.IO.FileInfo] $file = "$PSScriptRoot\..\.github\workflows\pre-release.yml" + New-Item -Type Directory $file.Directory -ErrorAction SilentlyContinue Invoke-WebRequest ` -Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/pre-release-windows.yml' | ForEach-Object { $_ -replace 'MyModuleName', $ModuleName } | - Out-File "$PSScriptRoot\..\.github\workflows\pre-release.yml" + Out-File $file -NoNewline } task UpdateReleaseWorkflow { + [System.IO.FileInfo] $file = "$PSScriptRoot\..\.github\workflows\release.yml" + New-Item -Type Directory $file.Directory -ErrorAction SilentlyContinue Invoke-WebRequest ` -Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/release-windows.yml' | ForEach-Object { $_ -replace 'MyModuleName', $ModuleName } | - Out-File "$PSScriptRoot\..\.github\workflows\release.yml" + Out-File $file -NoNewline } #endregion From 2e80cb3ac82228d94e2cbb5f1715c3204c76d643 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 09:46:31 +0200 Subject: [PATCH 18/21] added commit parameter --- docs/Install-PsBuildTask.md | 17 ++++++++++++++++- src/Public/Install-Task.ps1 | 8 ++++++-- test/Install-Task.Tests.ps1 | 10 ++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/docs/Install-PsBuildTask.md b/docs/Install-PsBuildTask.md index d19f6b3..972aca8 100644 --- a/docs/Install-PsBuildTask.md +++ b/docs/Install-PsBuildTask.md @@ -13,7 +13,7 @@ Install PsBuildTasks task file. ## SYNTAX ``` -Install-PsBuildTask [-Path] [-Task] [] +Install-PsBuildTask [-Path] [-Task] [[-Commit] ] [] ``` ## DESCRIPTION @@ -60,6 +60,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Commit +Specifies a revision by commit id. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: Main +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/src/Public/Install-Task.ps1 b/src/Public/Install-Task.ps1 index 97b2c12..4439120 100644 --- a/src/Public/Install-Task.ps1 +++ b/src/Public/Install-Task.ps1 @@ -19,7 +19,11 @@ function Install-Task { # Name of the task file to install. [Parameter( Mandatory )] [ValidateSet('PowerShell-Matrix', 'Dotnet-Matrix')] - [string] $Task + [string] $Task, + + # Specifies a revision by commit id. + [Parameter()] + [string] $Commit = 'main' ) $tasksDirectory = Join-Path $Path 'tasks' @@ -31,6 +35,6 @@ function Install-Task { $taskFile = Join-Path $tasksDirectory 'PsBuild.Tasks.ps1' Invoke-WebRequest ` - -Uri "https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/tasks/$Task.Tasks.ps1" ` + -Uri "https://raw.githubusercontent.com/abbgrade/PsBuildTasks/$Commit/tasks/$Task.Tasks.ps1" ` -OutFile $taskFile } \ No newline at end of file diff --git a/test/Install-Task.Tests.ps1 b/test/Install-Task.Tests.ps1 index 4f23fc9..2feedeb 100644 --- a/test/Install-Task.Tests.ps1 +++ b/test/Install-Task.Tests.ps1 @@ -19,4 +19,14 @@ Describe Install-Task { Install-PsBuildTask -Path "TestDrive:\" -Task Dotnet-Matrix -ErrorAction Stop "TestDrive:\tasks\PsBuild.Tasks.ps1" | Should -Exist } + + It PowerShell-Matrix-Commit { + Install-PsBuildTask -Path "TestDrive:\" -Task PowerShell-Matrix -Commit 'fb0767a258df19fb95f75f5cd96e14cc43e37bf8' -ErrorAction Stop + "TestDrive:\tasks\PsBuild.Tasks.ps1" | Should -Exist + } + + It Dotnet-Matrix { + Install-PsBuildTask-Commit -Path "TestDrive:\" -Task Dotnet-Matrix -Commit 'fb0767a258df19fb95f75f5cd96e14cc43e37bf8' -ErrorAction Stop + "TestDrive:\tasks\PsBuild.Tasks.ps1" | Should -Exist + } } \ No newline at end of file From b8363125bae2f1c83ca4bdfa97b190957d461ce8 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 09:56:37 +0200 Subject: [PATCH 19/21] fixed github pages installation --- tasks/PowerShell-Matrix.Tasks.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/PowerShell-Matrix.Tasks.ps1 b/tasks/PowerShell-Matrix.Tasks.ps1 index e1691c0..aa30070 100644 --- a/tasks/PowerShell-Matrix.Tasks.ps1 +++ b/tasks/PowerShell-Matrix.Tasks.ps1 @@ -39,6 +39,7 @@ task UpdateReleaseWorkflow { #region GitHub Pages task UpdateIndexPage { + New-Item -Type Directory "$PSScriptRoot\..\docs" -ErrorAction SilentlyContinue Invoke-WebRequest ` -Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/docs/index.md' ` -OutFile "$PSScriptRoot\..\docs\index.md" From 518cec505be2bc414efb867b98b5350c6da64e05 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 10:00:46 +0200 Subject: [PATCH 20/21] fixed task dependencies --- tasks/Dotnet-Matrix.Tasks.ps1 | 3 +++ tasks/PowerShell-Matrix.Tasks.ps1 | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tasks/Dotnet-Matrix.Tasks.ps1 b/tasks/Dotnet-Matrix.Tasks.ps1 index ad8db8f..98a60cc 100644 --- a/tasks/Dotnet-Matrix.Tasks.ps1 +++ b/tasks/Dotnet-Matrix.Tasks.ps1 @@ -18,6 +18,7 @@ task UpdateValidationWorkflow { } task UpdatePreReleaseWorkflow { + requires ModuleName [System.IO.FileInfo] $file = "$PSScriptRoot\..\.github\workflows\pre-release.yml" New-Item -Type Directory $file.Directory -ErrorAction SilentlyContinue Invoke-WebRequest ` @@ -27,6 +28,7 @@ task UpdatePreReleaseWorkflow { } task UpdateReleaseWorkflow { + requires ModuleName [System.IO.FileInfo] $file = "$PSScriptRoot\..\.github\workflows\release.yml" New-Item -Type Directory $file.Directory -ErrorAction SilentlyContinue Invoke-WebRequest ` @@ -52,6 +54,7 @@ task UpdateIndexPage { #region GitHub Dependabot task UpdateDependabotConfig { + requires ModuleName [System.IO.FileInfo] $file = "$PSScriptRoot\..\.github\dependabot.yml" New-Item -Type Directory $file.Directory -ErrorAction SilentlyContinue Invoke-WebRequest ` diff --git a/tasks/PowerShell-Matrix.Tasks.ps1 b/tasks/PowerShell-Matrix.Tasks.ps1 index aa30070..868409e 100644 --- a/tasks/PowerShell-Matrix.Tasks.ps1 +++ b/tasks/PowerShell-Matrix.Tasks.ps1 @@ -18,6 +18,7 @@ task UpdateValidationWorkflow { } task UpdatePreReleaseWorkflow { + requires ModuleName [System.IO.FileInfo] $file = "$PSScriptRoot\..\.github\workflows\pre-release.yml" New-Item -Type Directory $file.Directory -ErrorAction SilentlyContinue Invoke-WebRequest ` @@ -27,6 +28,7 @@ task UpdatePreReleaseWorkflow { } task UpdateReleaseWorkflow { + requires ModuleName [System.IO.FileInfo] $file = "$PSScriptRoot\..\.github\workflows\release.yml" New-Item -Type Directory $file.Directory -ErrorAction SilentlyContinue Invoke-WebRequest ` From c0d372cf340dfb3c916136cbc8dc582dc709bba9 Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Sat, 30 Jul 2022 10:03:07 +0200 Subject: [PATCH 21/21] updated example --- Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Readme.md b/Readme.md index eb039ef..4e417f7 100644 --- a/Readme.md +++ b/Readme.md @@ -25,6 +25,7 @@ Go to the project root directory ```powershell Import-Module -Name PsBuildTasks Install-PsBuildTask -Path . -Task PowerShell-Matrix +$ModuleName = 'MyModuleName' Invoke-Build -File .\tasks\PsBuild.Tasks.ps1 -Task UpdatePsBuildTasks ```