forked from OctopusDeploy/OctoTFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.ps1
53 lines (45 loc) · 2.01 KB
/
publish.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
param (
[Parameter(Mandatory=$true,HelpMessage="Test or Production")]
[ValidateSet("Test", "Production")]
[string]
$environment,
[Parameter(Mandatory=$true,HelpMessage="The three number version for this release")]
[string]
$version,
[Parameter(Mandatory=$true,HelpMessage="Get a personal access token from https://octopus-deploy.visualstudio.com/_details/security/tokens following the instructions https://www.visualstudio.com/en-us/integrate/extensions/publish/command-line")]
[string]
$accessToken,
[string]
$shareWith="octopus-deploy-test"
)
$ErrorActionPreference = "Stop"
$buildArtifactsPath = "$PSScriptRoot\build\Artifacts"
function UpdateTfxCli() {
Write-Host "Updating tfx-cli..."
& npm up -g tfx-cli
}
function PublishVSIX($vsixFile, $environment) {
if ($environment -eq "Production") {
Write-Output "Publishing $vsixFile to everyone (public extension)..."
& tfx extension publish --vsix $vsixFile --token $accessToken --no-prompt
} elseif ($environment -eq "Test") {
Write-Output "Publishing $vsixFile as a private extension, sharing with $shareWith using access token $accessToken"
& tfx extension publish --vsix $vsixFile --token $accessToken --share-with $shareWith --no-prompt
} else {
Write-Error "The valid environments are 'Test' and 'Production'"
}
}
function PublishAllExtensions($environment) {
$environmentArtifactsPath = "$buildArtifactsPath\$environment"
Write-Output "Looking for VSIX file(s) to publish in $environmentArtifactsPath..."
$vsixFiles = Get-ChildItem $environmentArtifactsPath -Include "*$version.vsix" -Recurse
if ($vsixFiles) {
foreach ($vsixFile in $vsixFiles) {
PublishVSIX $vsixFile $environment
}
} else {
Write-Error "There were no VSIX files found for *$version.vsix in $environmentArtifactsPath"
}
}
UpdateTfxCli
PublishAllExtensions $environment