-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathutilities.ps1
More file actions
70 lines (57 loc) · 2.14 KB
/
utilities.ps1
File metadata and controls
70 lines (57 loc) · 2.14 KB
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
function update-files()
{
param(
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $true)]
[System.String]
$file,
[Parameter(Mandatory = $True, Position = 1, ValueFromPipeline = $false)]
[System.String]
$oldVersion,
[Parameter(Mandatory = $True, Position = 2, ValueFromPipeline = $false)]
[System.String]
$newVersion
)
$file = Resolve-Path $file
Write-Host "Update file $file version from $oldVersion to $newVersion"
((Get-Content $file -Raw) -replace $oldVersion, $newVersion) | Set-Content $file -NoNewline
}
# example: publish-vsix -mode "test" -major 4 -minor 3 -patch 0 -token $token
function publish-vsix()
{
param(
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $false)]
$mode,
[Parameter(Mandatory = $True, Position = 1, ValueFromPipeline = $false)]
$major,
[Parameter(Mandatory = $True, Position = 2, ValueFromPipeline = $false)]
$minor,
[Parameter(Mandatory = $True, Position = 3, ValueFromPipeline = $false)]
$patch,
[Parameter(Mandatory = $True, Position = 4, ValueFromPipeline = $false)]
$token
)
$date = ([datetime]::UtcNow.ToString("yyMMddHHmm")).Substring(0, 9)
$version = "$major.$minor.$patch.$date"
$vsix = "dist/gittools.gittools-$version.vsix"
echo "Release mode: $mode"
echo "Version: $version"
npm run publish:prepare -- --mode $mode --version $version
npm run publish:azure:local -- --env mode=$mode version=$version --output-path $vsix
npm run publish:azure:marketplace -- --token $token --env mode=$mode version=$version
echo "vsix=$vsix" >> $env:GITHUB_OUTPUT
}
function extract-version()
{
$filePath = ".github/workflows/ci.yml"
if (Test-Path $filePath) {
$content = Get-Content $filePath -Raw
if ($content -match "versionSpec:\s*'([^']+)'") {
$version = $Matches[1]
Write-Output $version
} else {
Write-Error "Could not find versionSpec in $filePath"
}
} else {
Write-Error "File not found: $filePath"
}
}