-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathStreamus Deploy.ps1
70 lines (49 loc) · 5.74 KB
/
Streamus Deploy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# TODO: Prompt for version number.
# TODO: Minify CSS and JavaScript for obfuscation purposes. (maybe just JavaScript)
$version = '0.82';
$rootPath = ${env:userprofile} + '\Documents\GitHub\Streamus'
$manifestFile = $rootPath + '\Streamus Chrome Extension\manifest.json';
$versionManifestEntry = '"version": "' + $version + '"';
Write-Output $versionManifestEntry;
# Update the version number of the manifest.
(Get-Content $manifestFile) |
# Find the line that looks like: "version: #.##" and update it with current version
Foreach-Object {$_ -replace '"version": "[0-9]\.[0-9][0-9]"', $versionManifestEntry} |
Set-Content -Encoding UTF8 $manifestFile
$deploymentPath = $rootPath + '\Deploy';
# Create a deployment directory if it does not already exist. This will be the staging area for deploying the client/server.
if( !(Test-Path $deploymentPath) )
{
New-Item -ItemType directory -Path $deploymentPath
}
else {
# Clear out the deployment folder if it already exists.
Get-ChildItem $deploymentPath | Remove-Item -Recurse
}
# Copy the Streams Chrome Extension folder's contents to deployment.
$extensionPath = $rootPath + '\Streamus Chrome Extension';
$excludedDeployEntities = @('*.csproj', '*.csproj.user', 'bin', 'obj', 'Properties');
Get-ChildItem $extensionPath -Exclude $excludedDeployEntities | Copy-Item -destination $deploymentPath -Recurse
$deployedManifestFile = $deploymentPath + '\manifest.json';
(Get-Content $deployedManifestFile) |
# Remove permissions that're only needed for debugging.
Where-Object {$_ -notmatch '"key": "'} |
# Remove manifest key -- can't upload to Chrome Web Store if this entry exists in manifest.json, but helps with debugging.
Where-Object {$_ -notmatch '"http://test.streamus.com:61975/Streamus/",'} |
Set-Content -Encoding UTF8 $deployedManifestFile
# Ensure that localDebug is set to false in settings.js -- local debugging is for development only.
$deployedSettingsFile = $deploymentPath + '\js\background\model\settings.js';
(Get-Content $deployedSettingsFile) |
# Find the line that looks like: "localDebug: true" and set it to false. Local debugging is for development only.
Foreach-Object {$_ -replace "localDebug: true", "localDebug: false"} |
Set-Content $deployedSettingsFile
# 7-Zip must be installed on the target system for this to work.
# Inspiration from: http://stackoverflow.com/questions/1153126/how-to-create-a-zip-archive-with-powershell
function create-7zip([String] $aDirectory, [String] $aZipfile){
[string]$pathToZipExe = "C:\Program Files\7-zip\7z.exe";
[Array]$arguments = "a", "-tzip", "$aZipfile", "$aDirectory", "-r";
& $pathToZipExe $arguments;
}
# Zip up package ready for deployment.
$deployZipPath = $rootPath + '\Streamus v' + $version + '.zip';
create-7zip $deploymentPath $deployZipPath