Skip to content

Commit

Permalink
AppVeyorModule deployment type docs
Browse files Browse the repository at this point in the history
* Fix #34, along with prior commits…
* Add docs
* Bump for !Deploy
  • Loading branch information
RamblingCookieMonster committed Jul 12, 2016
1 parent 15ecbe1 commit f197e5f
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 13 deletions.
2 changes: 1 addition & 1 deletion PSDeploy/PSDeploy.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'PSDeploy.psm1'

# Version number of this module.
ModuleVersion = '0.1.13'
ModuleVersion = '0.1.14'

# ID used to uniquely identify this module
GUID = '268bd8de-5f4d-4f84-85d2-fb885ffb0837'
Expand Down
26 changes: 14 additions & 12 deletions PSDeploy/PSDeployScripts/AppVeyorModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
NuGet Package Name. Defaults to module name.
.PARAMETER Version
NuGet Version. Required.
TODO: Default to module version.
NuGet Version. Defaults to APPVEYOR_BUILD_VERSION
.PARAMETER Author
NuGet Author. Defaults to Unknown
Expand All @@ -35,7 +33,7 @@
NuGet Owners. Defaults to the Author
.PARAMETER LicenseUrl
NuGet LicenseUrl. Optional
NuGet LicenseUrl. Defaults to github.com/account/repo/LICENSE
.PARAMETER ProjectUrl
NuGet ProjectUrl. Optional
Expand All @@ -45,7 +43,6 @@
.PARAMETER Tags
NuGet Tags. Optional
#>
[cmdletbinding()]
param(
Expand Down Expand Up @@ -159,7 +156,7 @@ function New-Nuspec
$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

foreach($Deploy in $Deployment) {

#Validate expected deployment options
$RequiredParams = echo Version
If( -not (Validate-DeploymentParameters -Required $RequiredParams -Parameters $Deploy.DeploymentOptions.Keys))
Expand Down Expand Up @@ -243,9 +240,18 @@ foreach($Deploy in $Deployment) {
$LicenseUrl = $Deploy.DeploymentOptions.LicenseUrl
}

if(-not $Deploy.DeploymentOptions.Version)
{
$Version = "env:APPVEYOR_REPO_NAME"
}
else
{
$Version = $Deploy.DeploymentOptions.Version
}

$NuSpecParams = @{
PackageName = $ModuleName
Version = $Deployment.DeploymentOptions.Version
Version = $Version
Author = $Author
Description = $Description
DestinationPath = $StagingDirectory
Expand All @@ -262,13 +268,9 @@ foreach($Deploy in $Deployment) {
}
}

Write-Host "NuSpecParams: $($NuSpecParams | out-string)"
Write-Host "DeploymentOptions: $($Deploy.DeploymentOptions | out-string)"
Write-Host "Author: $Author"

New-Nuspec @NuSpecParams

nuget pack "$StagingDirectory\$ModuleName.nuspec" -outputdirectory $StagingDirectory
$null = nuget pack "$StagingDirectory\$ModuleName.nuspec" -outputdirectory $StagingDirectory
$NuGetPackagePath = "$StagingDirectory\$ModuleName.$Version.nupkg"

$ZipFilePath,
Expand Down
61 changes: 61 additions & 0 deletions docs/Example-AppVeyorModuleDeployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
This example illustrates using the AppVeyorModule deployment to publish a module directly to AppVeyor.

Here's the deployment config, My.PSDeploy.ps1:

```PowerShell
Deploy DeveloperBuild {
By AppVeyorModule {
FromSource MyModuleNameHere
To AppVeyor
}
}
```

In this example, we deploy both a zip file and a NuGet package to our AppVeyor build.

This idea was borrowed from the PowerShell team's use of AppVeyor to distribute [development builds](https://github.com/PowerShell/DscResources#development-builds) for DSC resources.

## Real Example

Here's a quick example from PSDeploy itself:

```PowerShell
# Publish to AppVeyor if we're in AppVeyor
if(
$env:BHProjectName -and $ENV:BHProjectName.Count -eq 1 -and
$env:BHBuildSystem -eq 'AppVeyor'
)
{
Deploy DeveloperBuild {
By AppVeyorModule {
FromSource $ENV:BHProjectName
To AppVeyor
WithOptions @{
Version = $env:APPVEYOR_BUILD_VERSION
}
}
}
}
```

The $ENV:BH* variables are created via [BuildHelpers](https://github.com/RamblingCookieMonster/BuildHelpers).

Here are the resulting artifacts in the build:

[![Source](images/appveyormodule.png)](images/appveyormodule.png)

Note that by default, your project's NuGet feed may have some random characters to add uniqueness. To view or configure this URL in AppVeyor, browse to your project settings, NuGet tab:

[![Source](images/appveyornuget.png)](images/appveyornuget.png)

Now that I know the URL, I'm ready to register and use this feed:

```PowerShell
Register-PSRepository -Name PSDeploy -SourceLocation https://ci.appveyor.com/nuget/psdeploy
Find-Module -Repository PSDeploy
# Version Name Type Repository Description
# ------- ---- ---- ---------- -----------
# 1.0.146 psdeploy Module PSDeploy psdeploy
```
21 changes: 21 additions & 0 deletions docs/Example-PSGalleryModuleDeployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
This is a quick example showing a PSGalleryModule deployment:

Here's the deployment config, My.PSDeploy.ps1:

```PowerShell
Deploy Module {
By PSGalleryModule {
FromSource MyModuleNameHere
To PSGallery
WithOptions @{
ApiKey = $ENV:NugetApiKey
}
}
}
```

In this example, we're deploying the module 'MyModuleNameHere' using an API key stored in $ENV:NugetApiKey.

The API key might be stored in a [secure variable](https://www.appveyor.com/docs/build-configuration#secure-variables) of some sort for your build system.

No output is produced from this deployment type.
Binary file added docs/images/appveyormodule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/appveyornuget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f197e5f

Please sign in to comment.