diff --git a/.github/workflows/github.yml b/.github/workflows/github.yml deleted file mode 100644 index 43bb7df4e..000000000 --- a/.github/workflows/github.yml +++ /dev/null @@ -1,277 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: PSKoans CI - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: - - main - tags: - - '*' - pull_request: - branches: - - main - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -env: - NupkgArtifactName: 'PSKoans.nupkg' - ModuleArtifactName: 'PSKoans' - PesterInfoFileName: 'PesterVersion.txt' - PesterInfoFilePath: '$GITHUB_WORKSPACE/PesterVersion.txt' - -jobs: - - create_changelog: - name: 'Upload Changelog' - - # Don't run this step for pull requests - if: ${{ github.head_ref == '' }} - runs-on: ubuntu-latest - - env: - FilePath: '$GITHUB_WORKSPACE/Changelog.md' - - steps: - - uses: actions/checkout@v2 - - - name: Generate Changelog - shell: pwsh - run: ./Build/New-Changelog.ps1 -Path "${{ env.FilePath }}" -ApiKey "${{ secrets.GITHUB_TOKEN }}" - - - name: Upload Changelog - uses: actions/upload-artifact@v2.2.3 - with: - name: Changelog.md - path: $FilePath - - build: - name: 'Build Module' - runs-on: ubuntu-latest - - env: - FileSystemDeploymentPath: '$GITHUB_WORKSPACE/Deploy/FileSystem' - BuiltModulePath: '$GITHUB_WORKSPACE/Deploy/PSKoans' - # This needs to be set by the script which creates the nupkg - NupkgPath: '' - - steps: - - uses: actions/checkout@v2 - - - name: Install Dependencies - shell: pwsh - run: | - $Params = @{ - Scope = 'CurrentUser' - Force = $true - } - - Write-Host "Installing Modules" - $Params.Name = @( 'PSDeploy', 'BuildHelpers', 'PlatyPS' ) - $Params | Out-String | Write-Host - Install-Module @Params - - $Params.Name = 'Pester' - $Params.SkipPublisherCheck = $true - $Params.MinimumVersion = $Params.MinimumVersion = (Get-Module -ListAvailable ./PSKoans).RequiredModules.Where{$_.Name -eq 'Pester'}.Version - $Params | Out-String | Write-Host - Install-Module @Params - - $Params.MinimumVersion | Set-Content -Path "${{ env.PesterInfoFilePath }}" - - $Params.Remove('SkipPublisherCheck') - $Params.Remove('MinimumVersion') - - $Params.Name = 'EZOut' - $Params.AllowClobber = $true - $Params | Out-String | Write-Host - Install-Module @Params - - - name: Setup Environment - shell: pwsh - run: ./Build/Initialize-Environment.ps1 - - - name: Build Module - shell: pwsh - run: ./Build/Build-Module.ps1 - - - name: Upload Module Artifact - uses: actions/upload-artifact@v2.2.3 - with: - name: $ModuleArtifactName - path: $BuiltModulePath - - - name: Upload Pester Version Artifact - uses: actions/upload-artifact@v2.2.3 - with: - name: $PesterInfoFileName - path: $PesterInfoFilePath - - - name: Generate Nupkg - shell: pwsh - run: | - ./Build/Register-FileSystemRepository.ps1 -Path '${{ env.FileSystemDeploymentPath }}' -Name 'FileSystem' - ./Deploy/Publish.ps1 -Key 'filesystem' -Path '${{ env.FileSystemDeploymentPath }}' -OutputDirectory '${{ env.FileSystemDeploymentPath }}' - - - name: Upload Nupkg Artifact - uses: actions/upload-artifact@v2.2.3 - with: - name: $NupkgArtifactName - path: $NupkgPath - - test: - name: "Test Module" - needs: build - - strategy: - matrix: - os: - - windows-latest - - macOS-latest - - ubuntu-latest - - runs-on: ${{ matrix.os }} - - env: - PackageDownloadPath: '$GITHUB_WORKSPACE/Module' - PSRepositoryName: 'FileSystem' - # The following variables MUST be set in Invoke-ModuleTests.ps1 - TestFile: '' - CodeCoverageFile: '' - ModuleFolders: '' - - steps: - - uses: actions/checkout@v2 - - - name: Install Dependencies - shell: pwsh - run: | - $Params = @{ - Scope = 'CurrentUser' - Force = $true - } - - Write-Host "Installing Modules" - $Params.Name = @( 'PSDeploy', 'BuildHelpers', 'PlatyPS' ) - $Params | Out-String | Write-Host - Install-Module @Params - - $Params.Name = 'Pester' - $Params.SkipPublisherCheck = $true - $Params.MinimumVersion = $Params.MinimumVersion = (Get-Module -ListAvailable ./PSKoans).RequiredModules.Where{$_.Name -eq 'Pester'}.Version - $Params | Out-String | Write-Host - Install-Module @Params - - $Params.Remove('SkipPublisherCheck') - $Params.Remove('MinimumVersion') - - $Params.Name = 'EZOut' - $Params.AllowClobber = $true - $Params | Out-String | Write-Host - Install-Module @Params - - - name: Setup Environment - shell: pwsh - run: ./Build/Initialize-Environment.ps1 - - - name: Register FileSystem Repository - shell: pwsh - run: ./Build/Register-FileSystemRepository.ps1 -Path '${{ env.PackageDownloadPath }}' -Name '${{ env.PSRepositoryName }}' - - - name: Download Module Nupkg - uses: actions/download-artifact@v2.0.9 - with: - name: $NupkgArtifactName - path: $PackageDownloadPath - - - name: Download Pester Version Information - uses: actions/download-artifact@v2.0.9 - with: - name: $PesterInfoFileName - path: $PesterInfoFilePath - - - name: Install Module from Nupkg - shell: pwsh - run: | - $pesterParams = @{ - Name = 'Pester' - MinimumVersion = Get-Content -Path "${{ env.PesterInfoFilePath }}" - ProviderName = 'NuGet' - Path = '${{ env.PackageDownloadPath }}' - Force = $true - Source = 'PSGallery' - } - Register-PackageSource -Name PSGallery -ProviderName NuGet -Location https://www.powershellgallery.com/api/v2 -Force - Save-Package @pesterParams | Select-Object -Property Name, Version, Status, Source - Install-Module PSKoans -Repository ${{ env.PSRepositoryName }} -Force -Scope CurrentUser - - - name: Run Pester Tests - shell: pwsh - run: ./Build/Invoke-ModuleTests.ps1 - - - name: Publish Test Results - if: ${{ always() }} - uses: MirageNet/nunit-reporter@v1.0.5 - with: - access-token: ${{ secrets.GITHUB_TOKEN }} - path: '$GITHUB_WORKSPACE\$TestResults' - - - name: Generate Code Coverage - uses: danielpalme/ReportGenerator-GitHub-Action@4.8.8 - with: - reports: '$GITHUB_WORKSPACE\$CodeCoverageFile' - targetdir: '$GITHUB_WORKSPACE\coveragereports' - sourcedirs: $SourceFolders - title: PSKoans Code Coverage - - - name: Publish Code Coverage artifacts - uses: actions/upload-artifact@v2.2.3 - with: - name: 'Code Coverage Reports' - path: '$GITHUB_WORKSPACE\coveragereports' - - publish: - needs: test - if: ${{ success() && startsWith( 'refs/tags/', env.GITHUB_REF ) }} - - runs-on: ubuntu-latest - - env: - BuiltModulePath: '$GITHUB_WORKSPACE/Deploy/PSKoans' - GalleryDeploymentPath: '$GITHUB_WORKSPACE/Deploy/PSGallery' - # This variable must be set by the script - TagName: '' - - steps: - - uses: actions/checkout@v2 - - - name: Download Module Artifact - uses: actions/download-artifact@v2.0.9 - with: - name: $ModuleArtifactName - path: $BuiltModulePath - - - name: Deploy Module to PSGallery - shell: pwsh - run: ./Deploy/Publish.ps1 -ApiKey '${{ secrets.PSGALLERYAPIKEY }}' -Path '${{ env.GalleryDeploymentPath }}' - - - name: Set Release Tag Name - shell: pwsh - run: | - $tagName = ("${{ env.GITHUB_REF }}" -replace '^refs/tags/').Trim() - "TagName=$tagname" | Add-Content -Path '${{ env.GITHUB_ENV }}' - - - name: Download Artifacts - uses: actions/download-artifact@v2.0.9 - with: - path: '$GITHUB_WORKSPACE/artifacts' - - - name: Update Release with Artifacts & Changelog - uses: Roang-zero1/github-create-release-action@v2.1.0 - with: - created_tag: $TagName - changelog_file: '$GITHUB_WORKSPACE/artifacts/Changelog.md' - release_title: 'PSKoans Release $TagName' diff --git a/Build/Build-Module.ps1 b/Build/Build-Module.ps1 deleted file mode 100644 index 1ee5a3b8d..000000000 --- a/Build/Build-Module.ps1 +++ /dev/null @@ -1,40 +0,0 @@ -# Grab nuget bits, set build variables, start build. -Get-PackageProvider -Name NuGet -ForceBootstrap > $null - -# Create format.ps1xml file -& "$PSScriptRoot/../PSKoans.ezformat.ps1" - -Import-Module "$env:PROJECTROOT/PSKoans" - -Set-BuildEnvironment - -$Lines = '-' * 70 - -Write-Host $Lines -Write-Host "STATUS: Generating External Help and Building Module" -Write-Host $Lines - -# Load the module, read the exported functions, update the psd1 FunctionsToExport -Set-ModuleFunction - -# Bump the module version if we didn't already -try { - [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 - - $GalleryVersion = Get-NextNugetPackageVersion -Name $env:BHProjectName -ErrorAction Stop - $GithubVersion = Get-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -ErrorAction Stop - - if ($GalleryVersion -ge $GithubVersion) { - Update-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value $GalleryVersion -ErrorAction Stop - } -} -catch { - Write-Host "Failed to update version for '$env:BHProjectName': $_." - Write-Host "Continuing with existing version." -} - -# Build external help files from Platyps MD files -New-ExternalHelp -Path "$env:PROJECTROOT/docs/" -OutputPath "$env:PROJECTROOT/PSKoans/en" - -Copy-Item -Path "$env:PROJECTROOT/PSKoans" -Destination $env:BUILTMODULEPATH -Recurse -PassThru | - Where-Object { -not $_.PSIsContainer } diff --git a/Build/Initialize-Environment.ps1 b/Build/Initialize-Environment.ps1 deleted file mode 100644 index 9576a58d6..000000000 --- a/Build/Initialize-Environment.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -Get-PackageProvider -Name NuGet -ForceBootstrap > $null - -Set-BuildEnvironment - -$ProjectRoot = Resolve-Path -Path "$PSScriptRoot/.." -Write-Host "##vso[task.setvariable variable=ProjectRoot]$ProjectRoot" - -$Lines = '-' * 70 - -Write-Host $Lines -Write-Host "Repository Branch: $env:BUILD_SOURCEBRANCHNAME ($env:BUILD_SOURCEBRANCH)" -Write-Host "Build System Details:" -Get-Item 'Env:BH*' | Out-String | Write-Host -Write-Host $Lines diff --git a/Build/Invoke-ModuleTests.ps1 b/Build/Invoke-ModuleTests.ps1 deleted file mode 100644 index 70fe1c365..000000000 --- a/Build/Invoke-ModuleTests.ps1 +++ /dev/null @@ -1,51 +0,0 @@ -$Lines = '-' * 70 - -Import-Module 'PSKoans' - -$PesterVersion = (Get-Module -Name Pester).Version -$PSVersion = $PSVersionTable.PSVersion - -Write-Host $Lines -Write-Host "TEST: PowerShell Version: $PSVersion" -Write-Host "TEST: Pester Version: $PesterVersion" -Write-Host $Lines - -try { - # Try/Finally required since -CI will exit with exit code on failure. - Invoke-Pester -Path "$env:PROJECTROOT" -CI -Output Normal -} -finally { - $Timestamp = Get-Date -Format "yyyyMMdd-hhmmss" - $TestFile = "PS${PSVersion}_${TimeStamp}_PSKoans.TestResults.xml" - $CodeCoverageFile = "PS${PSVersion}_${TimeStamp}_PSKoans.CodeCoverage.xml" - - $ModuleFolders = @( - Get-Item -Path "$env:PROJECTROOT/PSKoans" - Get-ChildItem -Path "$env:PROJECTROOT/PSKoans" -Directory -Recurse | - Where-Object FullName -NotMatch '[\\/]Tests[\\/]|[\\/]PSKoans[\\/]Koans[\\/]' - ).FullName -join ';' - - $AzurePipelines = $env:BUILD_SOURCESDIRECTORY -and $env:BUILD_BUILDNUMBER - $GithubActions = [bool]$env:GITHUB_WORKSPACE - - if ($AzurePipelines) { - # Tell Azure what the test results & code coverage file names will be - Write-Host "##vso[task.setvariable variable=TestResults]$TestFile" - Write-Host "##vso[task.setvariable variable=CodeCoverageFile]$CodeCoverageFile" - Write-Host "##vso[task.setvariable variable=SourceFolders]$ModuleFolders" - - # Move files generated from Invoke-Pester to expected location - Move-Item -Path './testResults.xml' -Destination "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$TestFile" - Move-Item -Path './coverage.xml' -Destination "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$CodeCoverageFile" - } - elseif ($GithubActions) { - @( - "TestResults=$TestFile" - "CodeCoverageFile=$CodeCoverageFile" - "SourceFolders=$ModuleFolders" - ) | Add-Content -Path $env:GITHUB_ENV - - Move-Item -Path './testResults.xml' -Destination "$env:GITHUB_WORKSPACE/$TestFile" - Move-Item -Path './coverage.xml' -Destination "$env:GITHUB_WORKSPACE/$CodeCoverageFile" - } -} diff --git a/Build/New-Changelog.ps1 b/Build/New-Changelog.ps1 deleted file mode 100644 index 86f821ad4..000000000 --- a/Build/New-Changelog.ps1 +++ /dev/null @@ -1,122 +0,0 @@ -<# - .SYNOPSIS - Creates a Markdown changelog file with table formatting. - - .DESCRIPTION - Uses `git log` to compare the current commit to the last tagged commit, - and parses the output into CSV data. This is then processed and email - addresses of commit authors are used to retrieve their Github - usernames, if available. - - The final result is stored in a Markdown plaintext file at the - designated path. - - .PARAMETER Path - The file location to save the markdown text to. The file will be - overwritten if it already contains data. - - .PARAMETER CommitID - The commit tag or hash that is used to identify the commit to - compare with. By default, the last value given by `git tag` - will be used. - - .PARAMETER ApiKey - The Github API key to use when looking up commit authors' - Github user names. - - .EXAMPLE - New-Changelog.ps1 -Path File.md -ApiKey $GHApiKey - - Retrieves the commits since the last tagged commit and creates a - Markdown-formatted plaintext file called File.md in the current - location. - - .NOTES - The Github API limitation of 60 requests per minute is -barely- - usable without authentication. Authenticated requests have a - substantially higher limit on requests per minute. -#> -[CmdletBinding()] -param( - [Parameter(Mandatory, Position = 0)] - [ValidateScript( { Test-Path $_ -IsValid })] - [string] - $Path, - - [Parameter(Position = 1)] - [ValidatePattern('[a-f0-9]{6,40}|v?(\d+\.)+\d+(-\w+\d+)?')] - [string] - $CommitID = (git tag | Select-Object -Last 1), - - [Parameter()] - [Alias('OauthToken')] - [string] - $ApiKey -) - -begin { - if ($ApiKey) { - $RequestParams = @{ - SessionVariable = 'AuthSession' - Uri = 'https://api.github.com/' - Headers = @{ Authorization = "token $ApiKey" } - } - Invoke-RestMethod @RequestParams | Out-String | Write-Verbose - } -} -process { - $RequestParams = if ($AuthSession) { @{ WebSession = $AuthSession } } else { @{ } } - $Args = @( - '--no-pager' - 'log' - '--first-parent' - "$CommitID..HEAD" - '--format="%H~%aN~%aE~%s"' - '--' - '.' - '":(exclude)*.md"' - ) - $Commits = & git @args | ConvertFrom-Csv -Delimiter '~' -Header Hash, Name, Email, Subject - - $NameTable = @{ } - foreach ($Item in ($Commits | Sort-Object -Property Email -Unique)) { - $RequestParams['Uri'] = "https://api.github.com/search/users?q=$($Item.Email)+in:email" - - do { - $result = $null - $attempt = 0 - try { - $result = Invoke-RestMethod @RequestParams -ErrorAction Stop - } - catch { - # If this errors, we have probably hit Github's per-minute API restriction, - # so wait at least 30 seconds before retry. - Start-Sleep -Seconds 30 - $attempt++ - } - } while ($attempt -lt 3 -and -not $result) - - $NameTable[$Item.Email] = if ($result.total_count) { $result.items[0].login } else { $Item.Name } - } - - $CsvString = $Commits | - Select-Object -Property @( - @{ Name = 'Hash'; Expression = { $_.Hash.Substring(0, 7) } } - @{ Name = 'Name'; Expression = { $NameTable[$_.Email] } } - 'Subject' - ) | - ConvertTo-Csv -Delimiter '|' - - $TableRows = $CsvString -replace '"', ' ' -replace '^|$', '|' - - $MarkdownTable = @( - # Header Row Only - $TableRows | Select-Object -First 1 - # Adding Markdown table column alignments - "| :--: | :--- | :--- |" - # Data Rows - $TableRows | Select-Object -Skip 1 - ) - - $MarkdownTable | Set-Content -Path $Path -} diff --git a/Build/Register-FileSystemRepository.ps1 b/Build/Register-FileSystemRepository.ps1 deleted file mode 100644 index 2a79a77f0..000000000 --- a/Build/Register-FileSystemRepository.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -[CmdletBinding()] -param( - [Parameter(Mandatory)] - [string] - $Path, - - [Parameter(Mandatory)] - [string] - $Name -) - -$RepositoryFolder = if (-not (Test-Path $Path)) { - New-Item -ItemType Directory -Path $Path -Force -} -else { - Get-Item -Path $Path -} - -$Params = @{ - Name = $Name - SourceLocation = $RepositoryFolder.FullName - ScriptSourceLocation = $RepositoryFolder.FullName - InstallationPolicy = 'Trusted' -} -Register-PSRepository @Params diff --git a/Deploy/FileSystem/PSKoans.psdeploy.ps1 b/Deploy/FileSystem/PSKoans.psdeploy.ps1 deleted file mode 100644 index e8a6734a8..000000000 --- a/Deploy/FileSystem/PSKoans.psdeploy.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -Deploy Module { - By PSGalleryModule { - FromSource "$PSScriptRoot/../PSKoans" - To FileSystem - WithOptions @{ - ApiKey = 'FileSystem' - } - } -} diff --git a/Deploy/PSGallery/PSKoans.psdeploy.ps1 b/Deploy/PSGallery/PSKoans.psdeploy.ps1 deleted file mode 100644 index 8aae78b5d..000000000 --- a/Deploy/PSGallery/PSKoans.psdeploy.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -Deploy Module { - By PSGalleryModule { - FromSource "$PSScriptRoot/../PSKoans" - To PSGallery - WithOptions @{ - ApiKey = $ENV:NugetApiKey - } - } -} diff --git a/Deploy/Publish.ps1 b/Deploy/Publish.ps1 deleted file mode 100644 index 62c5a9443..000000000 --- a/Deploy/Publish.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -[CmdletBinding()] -param( - [string] - $Key, - - [string] - $Path, - - [string] - $OutputDirectory -) - -$env:NugetApiKey = $Key - -if ($OutputDirectory) { - Import-Module "$PSScriptRoot/PSKoans" - $Module = Get-Module -Name PSKoans - $Dependencies = @( - $Module.RequiredModules.Name - $Module.NestedModules.Name - ).Where{ $_ } - - foreach ($Module in $Dependencies) { - Publish-Module -Name $Module -Repository FileSystem -NugetApiKey "Test-Publish" - } -} - -$HelpFile = Get-ChildItem -Path "$PSScriptRoot/PSKoans" -File -Recurse -Filter '*-help.xml' - -if ($HelpFile.Directory -notmatch 'en|\w{1,2}(-\w{1,2})?') { - $PSCmdlet.WriteError( - [System.Management.Automation.ErrorRecord]::new( - [IO.FileNotFoundException]::new("Help files are missing!"), - 'Build.HelpXmlMissing', - 'ObjectNotFound', - $null - ) - ) - - exit 404 -} - -$DeploymentParams = @{ - Path = $Path - Recurse = $false - Force = $true - Verbose = $true -} - -Invoke-PSDeploy @DeploymentParams - -Get-ChildItem -Path $DeploymentParams['Path'] | Out-String | Write-Host - -$Nupkg = Get-ChildItem -Path $DeploymentParams['Path'] -Filter 'PSKoans*.nupkg' | ForEach-Object FullName - -$AzurePipelines = $env:BUILD_SOURCESDIRECTORY -and $env:BUILD_BUILDNUMBER -$GithubActions = [bool]$env:GITHUB_WORKSPACE - -if ($AzurePipelines) { - Write-Host "##vso[task.setvariable variable=NupkgPath]$Nupkg" -} - -if ($GithubActions) { - "NupkgPath=$Nupkg" | Add-Content -Path $env:GITHUB_ENV -} diff --git a/README.md b/README.md index 108700517..ad7dd2b7d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # PowerShell Koans -| | Build Status | -| ------------------------------------ | ----------------------------------------------------------------------------------------------- | -| [![PSKoans Logo][logo-64]][logo-svg] | [![Build Status][build-badge]][build-link]
[![Coverage Status][coverage-badge]][build-link] | +[![PSKoans Logo][logo-64]][logo-svg] ## About the Author @@ -57,7 +55,7 @@ Install-Module PSKoans -Scope CurrentUser ### Or Download the Repo -1. `git clone` the repository into your desired directory, or download the module zip file from the build artifacts available on [this page](https://dev.azure.com/SallowCode/PSKoans/_build/latest?definitionId=1). +1. `git clone` the repository into your desired directory. 2. From a normal powershell session run `Get-ChildItem -Recurse | Unblock-File` in that directory to remove the "downloaded from internet" flag that blocks them from running. 3. Check `Get-ExecutionPolicy`: if it says 'Restricted' or 'Undefined', you need to also run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser` in order to allow the scripts to run. 4. Add the repository folder to `$env:PSModulePath` so that PowerShell can see it. @@ -170,10 +168,7 @@ If you would like to support the project, you can: - [Donate with Ko-fi][ko-fi] [blog]: https://vexx32.github.io -[build-badge]: https://dev.azure.com/SallowCode/PSKoans/_apis/build/status/PSKoans%20CI?branchName=main -[build-link]: https://dev.azure.com/SallowCode/PSKoans/_build/latest?definitionId=1&branchName=main [contributing]: CONTRIBUTING.md -[coverage-badge]: https://img.shields.io/azure-devops/coverage/SallowCode/PSKoans/1 [define-koan]: https://en.wikipedia.org/wiki/K%C5%8Dan [fsharp-koans]: https://github.com/ChrisMarinos/FSharpKoans [github-sponsor]: https://github.com/sponsors/vexx32 diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 39d9e9f65..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,269 +0,0 @@ -# YAML spec: -# https://aka.ms/yaml - -trigger: - branches: - include: - - main - tags: - include: - - '*' - -pr: -- main - -variables: - NupkgArtifactName: 'PSKoans.nupkg' - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - Trigger: '$(SourceBranchName)' - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - Trigger: 'PR #$(System.PullRequest.PullRequestNumber)' - -name: '$(BuildID)-$(Date:yyyy-MM-dd)$(Rev:.r) $(TeamProject) (${{ variables.Trigger }})' - -stages: -- stage: UploadChangelog - displayName: 'Upload Changelog' - dependsOn: [] - condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/main') - - jobs: - - job: GenerateChangelog - displayName: "Generate Changelog" - - pool: - vmImage: ubuntu-latest - - variables: - FilePath: '$(System.DefaultWorkingDirectory)/Changelog.md' - - steps: - - task: PowerShell@2 - displayName: 'Create Changelog' - inputs: - targetType: 'filepath' - filePath: ./Build/New-Changelog.ps1 - arguments: -Path '$(FilePath)' -ApiKey $(GithubApiKey) -Verbose - - - task: PublishPipelineArtifact@1 - displayName: 'Publish Changelog' - inputs: - path: '$(FilePath)' - artifact: Changelog - -- stage: Build - displayName: 'Build PSKoans' - dependsOn: [] - - variables: - FileSystemDeploymentPath: '$(System.DefaultWorkingDirectory)/Deploy/FileSystem' - BuiltModulePath: '$(System.DefaultWorkingDirectory)/Deploy/PSKoans' - - jobs: - - job: BuildNupkg - displayName: 'Module Nupkg' - - pool: - vmImage: ubuntu-latest - - steps: - - template: templates/environment-setup.yml - - - task: PowerShell@2 - displayName: 'Stage PSKoans Module' - - inputs: - targetType: 'filePath' - filePath: ./Build/Build-Module.ps1 - - errorActionPreference: 'stop' - failOnStdErr: true - pwsh: true - - - task: PublishPipelineArtifact@1 - displayName: 'Publish Built Module Artifact' - inputs: - path: '$(BuiltModulePath)' - artifact: PSKoans - - - template: ./templates/register-local-repo.yml - parameters: - repositoryPath: '$(FileSystemDeploymentPath)' - - - task: PowerShell@2 - displayName: 'Create Module Nupkg' - inputs: - targetType: 'filePath' - filePath: ./Deploy/Publish.ps1 - arguments: -Key 'filesystem' -Path '$(FileSystemDeploymentPath)' -OutputDirectory '$(FileSystemDeploymentPath)' - - errorActionPreference: 'stop' - failOnStderr: true - pwsh: true - - - task: PublishPipelineArtifact@1 - displayName: 'Publish Nupkg Artifact' - inputs: - path: '$(NupkgPath)' - artifact: '$(NupkgArtifactName)' - -- stage: LinuxTests - displayName: 'Linux' - dependsOn: - - Build - - variables: - PackageDownloadPath: '$(System.DefaultWorkingDirectory)/Module' - PSRepositoryName: 'FileSystem' - - jobs: - - job: Linux - displayName: 'Pester Tests' - - pool: - vmImage: ubuntu-latest - - steps: - - template: templates/environment-setup.yml - - - template: ./templates/install-built-module.yml - parameters: - repositoryPath: '$(PackageDownloadPath)' - repositoryName: '$(PSRepositoryName)' - artifactName: '$(NupkgArtifactName)' - - - template: templates/test-steps.yml - -- stage: WindowsTests - displayName: 'Windows' - dependsOn: - - Build - - variables: - PackageDownloadPath: '$(System.DefaultWorkingDirectory)/Module' - PSRepositoryName: 'FileSystem' - - jobs: - - job: Windows - displayName: 'Pester Tests' - - pool: - vmImage: windows-latest - - steps: - - template: templates/environment-setup.yml - - - template: ./templates/install-built-module.yml - parameters: - repositoryPath: '$(PackageDownloadPath)' - repositoryName: '$(PSRepositoryName)' - artifactName: '$(NupkgArtifactName)' - - - template: templates/test-steps.yml - -- stage: MacOSTests - displayName: 'MacOS' - dependsOn: - - Build - - variables: - PackageDownloadPath: '$(System.DefaultWorkingDirectory)/Module' - PSRepositoryName: 'FileSystem' - - jobs: - - job: MacOS - displayName: 'Pester Tests' - - pool: - vmImage: macOS-latest - - steps: - - template: templates/environment-setup.yml - - - template: ./templates/install-built-module.yml - parameters: - repositoryPath: '$(PackageDownloadPath)' - repositoryName: '$(PSRepositoryName)' - artifactName: '$(NupkgArtifactName)' - - - template: templates/test-steps.yml - -- stage: PublishModule - displayName: 'Publish Module' - dependsOn: - - LinuxTests - - WindowsTests - - MacOSTests - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) - variables: - TagName: '' - - jobs: - - deployment: PublishToGallery - displayName: 'PowerShell Gallery' - environment: - name: 'pskoans-releases' - - pool: - vmImage: ubuntu-latest - - variables: - BuiltModulePath: '$(System.DefaultWorkingDirectory)/Deploy/PSKoans' - GalleryDeploymentPath: '$(System.DefaultWorkingDirectory)/Deploy/PSGallery' - strategy: - runOnce: - deploy: - steps: - - checkout: self - - template: templates/environment-setup.yml - - task: DownloadPipelineArtifact@2 - displayName: 'Download Built Module Artifact' - inputs: - artifact: PSKoans - path: $(BuiltModulePath) - - - task: PowerShell@2 - displayName: 'Publish Module to PSGallery' - - inputs: - targetType: 'filePath' - arguments: -Key $(PSApiKey) -Path '$(GalleryDeploymentPath)' - filePath: ./Deploy/Publish.ps1 - - errorActionPreference: 'stop' - failOnStderr: true - pwsh: true - - - job: PublishAssets - displayName: 'Publish Assets to Github' - - pool: - vmImage: ubuntu-latest - - steps: - - task: PowerShell@2 - displayName: 'Set Release Tag Name' - - inputs: - targetType: 'inline' - script: | - $tagName = ("$(Build.SourceBranch)" -replace '^refs/tags/').Trim() - - Write-Host "##vso[task.setvariable variable=TagName]$tagname" - - errorActionPreference: 'stop' - failOnStderr: true - pwsh: true - - - task: DownloadPipelineArtifact@2 - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)/' - - - task: GitHubRelease@0 - inputs: - gitHubConnection: github.com_vexx32 - repositoryName: '$(Build.Repository.Name)' - action: 'edit' # Options: create, edit, delete - tag: '$(TagName)' # Required when action == Edit || Action == Delete || TagSource == Manual - assets: '$(Build.ArtifactStagingDirectory)/**/*.nupkg' # Optional - assetUploadMode: 'replace' # Optional. Options: delete, replace diff --git a/templates/environment-setup.yml b/templates/environment-setup.yml deleted file mode 100644 index 634a3f602..000000000 --- a/templates/environment-setup.yml +++ /dev/null @@ -1,44 +0,0 @@ -steps: -- task: PowerShell@2 - displayName: 'Install Dependencies' - - inputs: - targetType: 'inline' - script: | - $Params = @{ - Scope = 'CurrentUser' - Force = $true - } - - Write-Host "Installing Modules" - $Params.Name = @( 'PSDeploy', 'BuildHelpers', 'PlatyPS' ) - $Params | Out-String | Write-Host - Install-Module @Params - - $Params.Name = 'Pester' - $Params.SkipPublisherCheck = $true - $Params.MinimumVersion = '5.0.2' - $Params | Out-String | Write-Host - Install-Module @Params - $Params.Remove('SkipPublisherCheck') - $Params.Remove('MinimumVersion') - - $Params.Name = 'EZOut' - $Params.AllowClobber = $true - $Params | Out-String | Write-Host - Install-Module @Params - - errorActionPreference: 'stop' - failOnStderr: true - pwsh: true - -- task: PowerShell@2 - displayName: 'Initialize Environment' - - inputs: - targetType: 'filePath' - filePath: ./Build/Initialize-Environment.ps1 - - errorActionPreference: 'stop' - failOnStdErr: true - pwsh: true diff --git a/templates/install-built-module.yml b/templates/install-built-module.yml deleted file mode 100644 index 268f4c651..000000000 --- a/templates/install-built-module.yml +++ /dev/null @@ -1,44 +0,0 @@ -parameters: -- name: repositoryPath - type: string - default: '$(System.DefaultWorkingDirectory)' -- name: repositoryName - type: string - default: 'FileSystem' -- name: artifactName - type: string - default: 'PSKoans.nupkg' - -steps: -- template: ./register-local-repo.yml - parameters: - repositoryPath: ${{ parameters.repositoryPath }} - repositoryName: ${{ parameters.repositoryName }} - -- task: DownloadPipelineArtifact@2 - displayName: 'Download Built Module Artifact' - inputs: - artifact: ${{ parameters.artifactName }} - path: ${{ parameters.repositoryPath }} - -- task: PowerShell@2 - displayName: 'Install PSKoans from Nupkg' - inputs: - targetType: 'inline' - script: | - $pesterParams = @{ - Name = 'Pester' - MinimumVersion = '5.0.2' - ProviderName = 'NuGet' - Path = '${{ parameters.repositoryPath }}' - Force = $true - Source = 'PSGallery' - } - - Register-PackageSource -Name PSGallery -ProviderName NuGet -Location https://www.powershellgallery.com/api/v2 -Force - Save-Package @pesterParams | Select-Object -Property Name, Version, Status, Source - Install-Module PSKoans -Repository ${{ parameters.repositoryName }} -Force -Scope CurrentUser - - errorActionPreference: 'stop' - failOnStderr: true - pwsh: true diff --git a/templates/register-local-repo.yml b/templates/register-local-repo.yml deleted file mode 100644 index 4887e49ee..000000000 --- a/templates/register-local-repo.yml +++ /dev/null @@ -1,19 +0,0 @@ -parameters: -- name: repositoryPath - type: string - default: '$(System.DefaultWorkingDirectory)' -- name: repositoryName - type: string - default: 'FileSystem' - -steps: -- task: PowerShell@2 - displayName: 'Register FileSystem Repository' - inputs: - targetType: 'filePath' - filePath: ./Build/Register-FileSystemRepository.ps1 - arguments: -Path '${{ parameters.repositoryPath }}' -Name '${{ parameters.repositoryName }}' - - errorActionPreference: 'stop' - failOnStderr: true - pwsh: true diff --git a/templates/test-steps.yml b/templates/test-steps.yml deleted file mode 100644 index 0af79d3a7..000000000 --- a/templates/test-steps.yml +++ /dev/null @@ -1,31 +0,0 @@ -steps: -- task: PowerShell@2 - displayName: 'Run Pester Tests' - - inputs: - targetType: 'filePath' - filePath: ./Build/Invoke-ModuleTests.ps1 - - errorActionPreference: 'stop' - failOnStderr: true - pwsh: true - -- task: PublishTestResults@2 - displayName: 'Publish Test Results' - condition: succeededOrFailed() - - inputs: - testResultsFormat: NUnit - testResultsFiles: '$(TestResults)' - searchFolder: '$(Build.ArtifactStagingDirectory)' - mergeTestResults: true - -- task: PublishCodeCoverageResults@1 - displayName: 'Publish Code Coverage' - condition: succeededOrFailed() - - inputs: - codeCoverageTool: JaCoCo - summaryFileLocation: '$(Build.ArtifactStagingDirectory)/$(CodeCoverageFile)' - #reportDirectory: '$(Build.ArtifactStagingDirectory)' - pathToSources: '$(SourceFolders)'