@@ -27,12 +27,6 @@ let versionConfigFileName = "version.config"
2727let versionConfigFile =
2828 Path.Combine( rootDir.FullName, versionConfigFileName) |> FileInfo
2929
30- let AppendFullVersion fullVersion =
31- let fullVersionVarAssignment =
32- sprintf " %s FullVersion=%s " Environment.NewLine fullVersion
33-
34- File.AppendAllText( versionConfigFile.FullName, fullVersionVarAssignment)
35-
3630let tagPrefix = " refs/tags/"
3731
3832let fullVersion =
@@ -85,8 +79,6 @@ let fullVersion =
8579
8680 fullVersion
8781
88- AppendFullVersion fullVersion
89-
9082let Pack proj =
9183 Process
9284 .Execute(
@@ -99,10 +91,77 @@ let Pack proj =
9991 proj
10092 fullVersion
10193 },
102- Echo.Off
94+ Echo.All
10395 )
10496 .UnwrapDefault()
10597 |> ignore
10698
107- for proj in [ " fsxc" ; " Fsdk" ; " fsx" ] do
99+ let projs = [ " fsxc" ; " Fsdk" ; " fsx" ]
100+
101+ for proj in projs do
108102 Pack proj
103+
104+ let defaultBranch = " master"
105+ let branchPrefix = " refs/heads/"
106+
107+ if githubRef.StartsWith branchPrefix then
108+ if not ( githubRef.StartsWith( sprintf " %s%s " branchPrefix defaultBranch)) then
109+ Console.WriteLine(
110+ sprintf
111+ " Branch different than '%s ', skipping dotnet nuget push"
112+ defaultBranch
113+ )
114+
115+ Environment.Exit 0
116+ else
117+ if not ( githubRef.StartsWith tagPrefix) then
118+ failwithf " Unexpected GITHUB_REF value: %s " githubRef
119+
120+ let nugetApiKeyVarName = " NUGET_API_KEY"
121+ let nugetApiKey = Environment.GetEnvironmentVariable nugetApiKeyVarName
122+
123+ if String.IsNullOrEmpty nugetApiKey then
124+ Console.WriteLine(
125+ sprintf
126+ " Secret '%s ' not set as env var, skipping dotnet nuget push"
127+ nugetApiKeyVarName
128+ )
129+
130+ Environment.Exit 0
131+
132+ let githubEventName = Environment.GetEnvironmentVariable " GITHUB_EVENT_NAME"
133+
134+ match githubEventName with
135+ | " push" ->
136+ let nugetApiSource = " https://api.nuget.org/v3/index.json"
137+
138+ let NugetPush proj =
139+ Process
140+ .Execute(
141+ {
142+ Command = " dotnet"
143+ Arguments =
144+ sprintf
145+ " nuget push %s /nupkg/%s .%s .nupkg --api-key %s --source %s "
146+ proj
147+ proj
148+ fullVersion
149+ nugetApiKey
150+ nugetApiSource
151+ },
152+ Echo.All
153+ )
154+ .UnwrapDefault()
155+ |> ignore
156+
157+ for proj in projs do
158+ NugetPush proj
159+
160+ | null
161+ | " " -> failwith " The env var for github event name should have a value"
162+
163+ | _ ->
164+ Console.WriteLine
165+ " Github event name is not 'push', skipping dotnet nuget push"
166+
167+ Environment.Exit 0
0 commit comments