-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathupdate.ps1
executable file
·72 lines (57 loc) · 1.99 KB
/
update.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
71
72
#!/usr/bin/pwsh
using namespace System.Management.Automation
[CmdletBinding()]
param ()
$PSNativeCommandUseErrorActionPreference = $true
if ($DebugPreference -ne 'SilentlyContinue') {
$ErrorActionPreference = 'Break'
} else {
$ErrorActionPreference = 'Stop'
}
$Debug = $PSCmdlet.MyInvocation.BoundParameters['Debug']
git config --global user.email '[email protected]'
git config --global user.name 'David Huang'
Push-Location .
try {
Set-Location $PSScriptRoot
$localTag = git describe --tags --abbrev=0
Write-Host "Local at $localTag"
Set-Location "$PSScriptRoot/seagull-icons/upstream"
git checkout main
git pull --ff-only
$upstreamTag = git describe --tag --abbrev=0
Write-Host "Upstream at $upstreamTag"
if (([Version][SemanticVersion]::Parse($localTag)) -ge ([Version][SemanticVersion]::Parse($upstreamTag)) -and -not $Debug) {
return
}
Set-Location $PSScriptRoot
& "$PSScriptRoot/seagull-icons/build.ps1"
# update enums
$symbolCs = "$PSScriptRoot/FluentIcons.Common/Symbol.cs"
$symbolMap = [System.Collections.Generic.Dictionary[string, int]]::new()
(Get-Content "$PSScriptRoot/seagull-icons/obj/codepoints.json" | ConvertFrom-Json).PSObject.Properties | ForEach-Object {
$symbolMap.Add(($_.Name -replace '(?:^|_)([0-9a-z])', { $_.Groups[1].Value.ToUpperInvariant() }),
[int]$_.Value)
}
@'
namespace FluentIcons.Common;
public enum Symbol : int
{
'@ > $symbolCs
foreach ($key in $symbolMap.Keys) {
" $key = $('0x{0:X}' -f $symbolMap[$key])," >> $symbolCs
}
@'
}
'@ >> $symbolCs
# patch project version
(Get-Content "$PSScriptRoot/Directory.Build.props") -replace '<VersionPrefix>(.*)<\/VersionPrefix>', "<VersionPrefix>$($upstreamTag)</VersionPrefix>" | Out-File "$PSScriptRoot/Directory.Build.props"
# Commit
git add -A
if (-not $Debug) {
git commit -m "Upstream version v$upstreamTag"
git tag "$upstreamTag-ci"
}
} finally {
Pop-Location
}