Skip to content

Commit f549166

Browse files
committed
Initial commit
0 parents  commit f549166

11 files changed

Lines changed: 1051 additions & 0 deletions

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
*.ps1 text
4+
*.psm1 text
5+
*.psd1 text

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Build/
2+
Release/
3+
Thumbs.db

AppvProvider.ps1

Lines changed: 495 additions & 0 deletions
Large diffs are not rendered by default.

AppvProvider.psd1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@{
2+
ModuleVersion = '0.6.0';
3+
GUID = 'efea3f79-595c-4eda-82fa-7cf72a3d85ac';
4+
Author = 'Iain Brighton, Nathan Sperry';
5+
CompanyName = 'Virtual Engine';
6+
Description = 'Powershell OneGet/Package Management Provider for App-V 5.x'
7+
Copyright = 'Copyright (c) 2015 Virtual Engine Limited. All rights reserved.';
8+
PowerShellVersion = '3.0';
9+
RequiredModules = @('PackageManagement','AppvClient');
10+
PrivateData = @{
11+
PackageManagementProviders = 'AppvProvider.psm1';
12+
PSData = @{
13+
Tags = @('VirtualEngine','Powershell','OneGet','Appv','App-V');
14+
LicenseUri = 'https://raw.githubusercontent.com/VirtualEngine/AppvProvider/master/LICENSE';
15+
ProjectUri = 'https://github.com/VirtualEngine/AppvProvider';
16+
IconUri = 'https://raw.githubusercontent.com/VirtualEngine/AppvProvider/b0d3234d050d9be087a088afd95a15c744d76cea/appv_oneget.png';
17+
} # End of PSData hashtable
18+
};
19+
}

AppvProvider.psm1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<#
2+
3+
Copyright (c) Virtual Engine Limited. All rights reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
#>
17+
18+
$moduleRoot = Split-Path -Parent $MyInvocation.MyCommand.Path;
19+
. (Join-Path -Path $moduleRoot -ChildPath AppvProvider.ps1);

Build.PSake.ps1

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#requires -Module VirtualEngine.Build, VirtualEngine.Compression;
2+
#requires -Version 3;
3+
4+
Properties {
5+
$currentDir = Resolve-Path -Path .;
6+
$basePath = $psake.build_script_dir;
7+
$buildDir = 'Build';
8+
$releaseDir = 'Release';
9+
$invocation = (Get-Variable MyInvocation -Scope 1).Value;
10+
$thumbprint = 'D10BB31E5CE3048A7D4DA0A4DD681F05A85504D3';
11+
$timeStampServer = 'http://timestamp.verisign.com/scripts/timestamp.dll';
12+
$company = 'Virtual Engine';
13+
$author = 'Iain Brighton';
14+
$githubOwner = 'VirtualEngine';
15+
$githubTokenPath = '~\Github.apitoken';
16+
$chocolateyTokenPath = '~\Chocolatey.apitoken';
17+
}
18+
19+
Task Default -Depends Build;
20+
Task Build -Depends Clean, Setup, Deploy;
21+
Task Stage -Depends Build, Version, Sign, Zip;
22+
Task Publish -Depends Stage, Release, Chocolatey;
23+
24+
Task Clean {
25+
## Remove build directory
26+
$baseBuildPath = Join-Path -Path $psake.build_script_dir -ChildPath $buildDir;
27+
if (Test-Path -Path $baseBuildPath) {
28+
Write-Host (' Removing build base directory "{0}".' -f $baseBuildPath) -ForegroundColor Yellow;
29+
Remove-Item $baseBuildPath -Recurse -Force -ErrorAction Stop;
30+
}
31+
}
32+
33+
Task Setup {
34+
# Properties are not available in the script scope.
35+
Set-Variable manifest -Value (Get-ModuleManifest) -Scope Script;
36+
Set-Variable buildPath -Value (Join-Path -Path $psake.build_script_dir -ChildPath "$buildDir\$($manifest.Name)") -Scope Script;
37+
Set-Variable releasePath -Value (Join-Path -Path $psake.build_script_dir -ChildPath $releaseDir) -Scope Script;
38+
Set-Variable version -Value (Get-GitVersionString) -Scope Script;
39+
40+
Write-Host (' Building module "{0}".' -f $manifest.Name) -ForegroundColor Yellow;
41+
Write-Host (' Using Git version "{0}".' -f $version) -ForegroundColor Yellow;
42+
43+
## Create the build directory
44+
Write-Host (' Creating build directory "{0}".' -f $buildPath) -ForegroundColor Yellow;
45+
[Ref] $null = New-Item $buildPath -ItemType Directory -Force -ErrorAction Stop;
46+
47+
## Create the release directory
48+
if (!(Test-Path -Path $releasePath)) {
49+
Write-Host (' Creating release directory "{0}".' -f $releasePath) -ForegroundColor Yellow;
50+
[Ref] $null = New-Item $releasePath -ItemType Directory -Force -ErrorAction Stop;
51+
}
52+
}
53+
54+
Task Test {
55+
$testResultsPath = Join-Path $buildPath -ChildPath 'NUnit.xml';
56+
$testResults = Invoke-Pester -Path $basePath -OutputFile $testResultsPath -OutputFormat NUnitXml -PassThru -Strict;
57+
if ($testResults.FailedCount -gt 0) {
58+
Write-Error ('{0} unit tests failed.' -f $testResults.FailedCount);
59+
}
60+
}
61+
62+
Task Deploy {
63+
## Copy release files
64+
Write-Host (' Copying release files to build directory "{0}".' -f $buildPath) -ForegroundColor Yellow;
65+
$excludedFiles = @( '*.Tests.ps1','Build.PSake.ps1','.git*','*.png','Build','Release','readme.md' );
66+
Get-ModuleFile -Exclude $excludedFiles | % {
67+
$destinationPath = '{0}{1}' -f $buildPath, $PSItem.FullName.Replace($basePath, '');
68+
[Ref] $null = New-Item -ItemType File -Path $destinationPath -Force;
69+
Copy-Item -Path $PSItem.FullName -Destination $destinationPath -Force;
70+
}
71+
}
72+
73+
Task Version {
74+
## Version module manifest prior to build
75+
$manifestPath = Join-Path $buildPath -ChildPath "$($manifest.Name).psd1";
76+
Write-Host (' Versioning module manifest "{0}".' -f $manifestPath) -ForegroundColor Yellow;
77+
Set-ModuleManifestProperty -Path $manifestPath -Version $version -CompanyName $company -Author $author;
78+
## Reload module manifest to ensure the version number is picked back up
79+
Set-Variable manifest -Value (Get-ModuleManifest -Path $manifestPath) -Scope Script -Force;
80+
}
81+
82+
Task Sign {
83+
Get-ChildItem -Path $buildPath -Include *.ps* -Recurse -File | % {
84+
Write-Host (' Signing file "{0}":' -f $PSItem.FullName) -ForegroundColor Yellow -NoNewline;
85+
$signResult = Set-ScriptSignature -Path $PSItem.FullName -Thumbprint $thumbprint -TimeStampServer $timeStampServer -ErrorAction Stop;
86+
Write-Host (' {0}.' -f $signResult.Status) -ForegroundColor Green;
87+
}
88+
}
89+
90+
Task Zip {
91+
## Creates the release files in the $releaseDir
92+
$zipReleaseName = '{0}-v{1}.zip' -f $manifest.Name, $version;
93+
$zipPath = Join-Path -Path $releasePath -ChildPath $zipReleaseName;
94+
Write-Host (' Creating zip file "{0}".' -f $zipPath) -ForegroundColor Yellow;
95+
## Zip the parent directory
96+
$zipSourcePath = Split-Path -Path $buildPath -Parent;
97+
$zipFile = New-ZipArchive -Path $zipSourcePath -DestinationPath $zipPath;
98+
Write-Host (' Zip file "{0}" created.' -f $zipFile.Fullname) -ForegroundColor Yellow;
99+
}
100+
101+
Task Release {
102+
## Create a Github release
103+
$githubApiKey = (New-Object System.Management.Automation.PSCredential 'OAUTH', (Get-Content -Path $githubTokenPath | ConvertTo-SecureString)).GetNetworkCredential().Password;
104+
Write-Host (' Creating new Github "{0}" release in repository "{1}/{2}".' -f $version, $githubOwner, $manifest.Name) -ForegroundColor Yellow;
105+
#$release = New-GitHubRelease -Version $version -Repository $manifest.Name -Owner $githubOwner -ApiKey $githubApiKey;
106+
if ($release) {
107+
## Creates the release files in the $releaseDir
108+
$zipReleaseName = '{0}-v{1}.zip' -f $manifest.Name, $version;
109+
$zipPath = Join-Path -Path $releasePath -ChildPath $zipReleaseName;
110+
Write-Host (' Uploading asset "{0}".' -f $zipPath) -ForegroundColor Yellow;
111+
$asset = Invoke-GitHubAssetUpload -Release $release -ApiKey $githubApiKey -Path $zipPath;
112+
Set-Variable -Name assetUri -Value $asset.Browser_Download_Url -Scope Script -Force;
113+
}
114+
}
115+
116+
Task Chocolatey {
117+
Set-Variable chocolateyBuildPath -Value (Join-Path -Path $psake.build_script_dir -ChildPath "$buildDir\Chocolatey") -Scope Script;
118+
## Create the Chocolatey folder
119+
Write-Host (' Creating Chocolatey directory "{0}".' -f $chocolateyBuildPath) -ForegroundColor Yellow;
120+
[Ref] $null = New-Item $chocolateyBuildPath -ItemType Directory -Force -ErrorAction Stop;
121+
$chocolateyToolsPath = New-Item "$chocolateyBuildPath\tools" -ItemType Directory -Force -ErrorAction Stop;
122+
123+
## Create the Chocolatey package
124+
$nuspecFilename = '{0}.nuspec' -f $manifest.Name;
125+
$nuspecPath = Join-Path -Path $chocolateyBuildPath -ChildPath $nuspecFilename;
126+
Write-Host (' Creating Nuget specification "{0}".' -f $nuspecPath) -ForegroundColor Yellow;
127+
(New-NuGetNuspec -InputObject $manifest).Save($nuspecPath);
128+
129+
Write-Host ' Creating Chocolatey install files.' -ForegroundColor Yellow;
130+
New-ChocolateyInstallZipModule -Path $chocolateyToolsPath.FullName -PackageName $manifest.Name -Uri $assetUri;
131+
Write-Host (' Creating Nuget package from "{0}".' -f $nuspecPath) -ForegroundColor Yellow;
132+
$nugetOutput = Invoke-NuGetPack -Path $nuspecPath -DestinationPath $releasePath;
133+
if ($nugetOutput) {
134+
$nugetPackagePath = Join-Path -Path $releasePath -ChildPath ('{0}.{1}.nupkg' -f $manifest.Name.ToLower(), $version);
135+
Write-Host (' Chocolatey package "{0}" created.' -f $nugetPackagePath) -ForegroundColor Yellow;
136+
$chocolateyApiKey = (New-Object System.Management.Automation.PSCredential 'OAUTH', (Get-Content -Path $chocolateyTokenPath | ConvertTo-SecureString)).GetNetworkCredential().Password;
137+
Write-Host (' Pushing Chocolatey package "{0}".' -f $nugetPackagePath) -ForegroundColor Yellow;
138+
}
139+
}

0 commit comments

Comments
 (0)