-
Notifications
You must be signed in to change notification settings - Fork 23
/
publish.fish
executable file
·57 lines (45 loc) · 1.15 KB
/
publish.fish
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
#!/usr/bin/env fish
function csproj_field
set csproj $argv[1]
set field $argv[2]
set value (string replace -rf "\\s*<$field>(.*)</$field>" '$1' < $csproj | string trim)[1]
if ! string match -qr -- '.' $value
echo "Could not extract value of $field from $csproj" 1>&2
exit 1
end
echo $value
end
function publish_csproj
set csproj $argv[1]
if ! test -f $csproj
echo "Could not find project file $csproj!" 1>&2
exit 1
end
set -l pkgname (csproj_field $csproj "PackageId")
set -l pkgversion (csproj_field $csproj "Version")
if ! dotnet build -c Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg $csproj
exit 1
end
set nupkg (dirname $csproj)/bin/Release/$pkgname.$pkgversion.nupkg
if ! test -f $nupkg
echo "Could not find nuget package $nupkg!" 1>&2
exit 1
end
set snupkg (dirname $csproj)/bin/Release/$pkgname.$pkgversion.snupkg
if ! test -f $nupkg
echo "Could not find nuget symbol package $snupkg!" 1>&2
exit 1
end
if ! nuget push $nupkg
exit 1
end
if ! nuget push $snupkg
exit 1
end
end
if string match -qr -- . $argv[1]
set csproj $argv[1]
publish_csproj $csproj
else
publish_csproj ./unicode/*.csproj
end