Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
Add support for publishing examples configurations to PowerShell Gall…
Browse files Browse the repository at this point in the history
…ery (#235)

- Changes to DscResource.Tests
  - Add support for publishing examples configurations to PowerShell Gallery if
    opt-in (issue #234).
  • Loading branch information
johlju committed Jul 3, 2018
1 parent 7956b15 commit e872956
Show file tree
Hide file tree
Showing 11 changed files with 1,552 additions and 15 deletions.
88 changes: 88 additions & 0 deletions AppVeyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1228,4 +1228,92 @@ function Push-TestArtifact
}
}

<#
.SYNOPSIS
Performs the deploy tasks for the AppVeyor build process.
This includes:
1. Optional: Publish examples that opt-in to being published to
PowerShell Gallery.
.PARAMETER OptIn
This controls the deploy steps that will be executed.
If not specified will default to opt-in for all deploy tasks.
.PARAMETER ModuleRootPath
This is the relative path of the folder that contains the repository
being deployed. If not specified it will default to the root folder
of the repository ($env:APPVEYOR_BUILD_FOLDER).
.PARAMETER MainModulePath
This is the relative path of the folder that contains the Examples
folder. If not specified it will default to the root folder of the
repository ($env:APPVEYOR_BUILD_FOLDER).
.PARAMETER ResourceModuleName
Name of the resource module being deployed.
If not specified will default to GitHub repository name.
.PARAMETER Branch
Name of the branch or branches to execute the deploy tasks on.
If not specified will default to the branch 'master'.
The default value is normally correct, but can be changed for
debug purposes.
#>
function Invoke-AppVeyorDeployTask
{

[CmdletBinding(DefaultParameterSetName = 'Default')]
param
(
[Parameter()]
[ValidateSet('PublishExample')]
[String[]]
$OptIn = @(
'PublishExample'
),

[Parameter()]
[ValidateNotNullOrEmpty()]
[String]
$ModuleRootPath = $env:APPVEYOR_BUILD_FOLDER,

[Parameter()]
[ValidateNotNullOrEmpty()]
[String]
$MainModulePath = $env:APPVEYOR_BUILD_FOLDER,

[Parameter()]
[ValidateNotNullOrEmpty()]
[String]
$ResourceModuleName = (($env:APPVEYOR_REPO_NAME -split '/')[1]),

[Parameter()]
[ValidateNotNullOrEmpty()]
[String[]]
$Branch = @(
'master'
)
)

# Will only publish examples on pull request merge to master.
if ($OptIn -contains 'PublishExample' -and $Branch -contains $env:APPVEYOR_REPO_BRANCH)
{
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'DscResource.GalleryDeploy')

$startGalleryDeployParameters = @{
ResourceModuleName = $ResourceModuleName
Path = (Join-Path -Path $MainModulePath -ChildPath 'Examples')
Branch = $env:APPVEYOR_REPO_BRANCH
ModuleRootPath = $ModuleRootPath
}

Start-GalleryDeploy @startGalleryDeployParameters
}
else
{
Write-Info -Message 'Skip publish examples to Gallery. Either not opt-in, or building on the wrong branch.'
}
}

Export-ModuleMember -Function *
59 changes: 59 additions & 0 deletions DscResource.GalleryDeploy/DscResource.GalleryDeploy.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Module manifest for module 'DscResource.Container'

@{
# Version number of this module.
ModuleVersion = '1.0.0.0'

# ID used to uniquely identify this module
GUID = '5d4a03fb-9b7a-4c21-b457-368ab790c9f1'

# Author of this module
Author = 'Microsoft Corporation'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = '(c) 2018 Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
Description = 'This module is used to assist in publish configurations to PowerShell Gallery for PowerShell DSC resources.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '4.0'

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @(
'DscResource.GalleryDeploy.psm1'
)

# Cmdlets to export from this module
CmdletsToExport = @(
'Start-GalleryDeploy'
)

# 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 = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource')

# A URL to the license for this module.
LicenseUri = 'https://github.com/PowerShell/DscResource.Tests/blob/master/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/PowerShell/DscResource.Tests'

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = ''

} # End of PSData hashtable

} # End of PrivateData hashtable
}

Loading

0 comments on commit e872956

Please sign in to comment.