forked from icsharpcode/ILSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathghactions-install.ps1
48 lines (38 loc) · 1.5 KB
/
ghactions-install.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
$ErrorActionPreference = "Stop"
$baseCommit = "d779383cb85003d6dabeb976f0845631e07bf463";
$baseCommitRev = 1;
# make sure this matches artifacts-only branches list in appveyor.yml!
$masterBranches = '^refs/heads/(master|release/.+)$';
$decompilerVersionInfoTemplateFile = "ICSharpCode.Decompiler/Properties/DecompilerVersionInfo.template.cs";
$versionParts = @{};
Get-Content $decompilerVersionInfoTemplateFile | where { $_ -match 'string (\w+) = "?(\w+)"?;' } | foreach { $versionParts.Add($Matches[1], $Matches[2]) }
$major = $versionParts.Major;
$minor = $versionParts.Minor;
$build = $versionParts.Build;
$versionName = $versionParts.VersionName;
if ($versionName -ne "null") {
$versionName = "-$versionName";
} else {
$versionName = "";
}
Write-Host "GITHUB_REF: '$env:GITHUB_REF'";
if ($env:GITHUB_REF -match $masterBranches) {
$branch = "";
$suffix = "";
} elseif ($env:GITHUB_REF -match '^refs/pull/(\d+)/merge$') {
$branch = "";
$suffix = "-pr" + $Matches[1];
} elseif ($env:GITHUB_REF -match '^refs/heads/(.+)$') {
$branch = "-" + $Matches[1];
$suffix = "";
} else {
$branch = "";
$suffix = "";
}
$revision = [Int32]::Parse((git rev-list --count "$baseCommit..HEAD")) + $baseCommitRev;
$newVersion="$major.$minor.$build.$revision";
$ilspyVersionNumber = "$newVersion$branch$versionName$suffix";
$ilspyVersionNumber = $ilspyVersionNumber.Replace("/", "-");
$env:ILSPY_VERSION_NUMBER="$ilspyVersionNumber";
$env:ILSPY_VERSION_NUMBER | Out-File "ILSPY_VERSION"
Write-Host "new version: $ilspyVersionNumber";