Skip to content

Commit efeebfd

Browse files
committed
Added a publish.fsx script
1 parent 98dfe92 commit efeebfd

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/Elmish.Avalonia.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ EndProject
1212
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{7E33C4FF-FDB6-45C5-8748-743F48523213}"
1313
ProjectSection(SolutionItems) = preProject
1414
build.fsx = build.fsx
15+
publish.fsx = publish.fsx
1516
EndProjectSection
1617
EndProject
1718
Global

src/publish.fsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#r "nuget: Fun.Build, 1.0.2"
2+
#r "nuget: Fake.Core.Environment, 5.22.0"
3+
4+
open System.IO
5+
open System.Xml.Linq
6+
open Fun.Build
7+
open Fake.Core
8+
9+
let src = __SOURCE_DIRECTORY__
10+
11+
let version =
12+
let project = (FileInfo $"{src}/Elmish.Avalonia/Elmish.Avalonia.fsproj")
13+
let doc = XDocument.Load(project.FullName)
14+
doc.Descendants("Version") |> Seq.tryHead
15+
|> Option.map (fun versionElement -> versionElement.Value)
16+
|> Option.defaultWith (fun () -> failwith $"Could not find a <Version> element in '{project.Name}'.")
17+
18+
let nugetKey =
19+
match Environment.environVarOrNone "ELMISH_AVALONIA_NUGET_KEY" with
20+
| Some nugetKey -> nugetKey
21+
| None -> failwith "The NuGet API key must be set in an 'ELMISH_AVALONIA_NUGET_KEY' environmental variable"
22+
23+
pipeline "Publish" {
24+
25+
stage "Build Elmish.Avalonia" {
26+
run $"dotnet restore {src}/Elmish.Avalonia.sln"
27+
run $"dotnet build {src}/Elmish.Avalonia.sln --configuration Release"
28+
}
29+
30+
stage "Publish Elmish.Avalonia" {
31+
run $"dotnet nuget push \"{src}/Elmish.Avalonia/bin/Release/Elmish.Avalonia.{version}.nupkg\" -s nuget.org -k {nugetKey} --skip-duplicate"
32+
}
33+
34+
runIfOnlySpecified false
35+
}
36+
37+
tryPrintPipelineCommandHelp ()

0 commit comments

Comments
 (0)