@@ -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,76 @@ 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+ elif not ( githubRef.StartsWith tagPrefix) then
117+ failwithf " Unexpected GITHUB_REF value: %s " githubRef
118+
119+ let nugetApiKeyVarName = " NUGET_API_KEY"
120+ let nugetApiKey = Environment.GetEnvironmentVariable nugetApiKeyVarName
121+
122+ if String.IsNullOrEmpty nugetApiKey then
123+ Console.WriteLine(
124+ sprintf
125+ " Secret '%s ' not set as env var, skipping dotnet nuget push"
126+ nugetApiKeyVarName
127+ )
128+
129+ Environment.Exit 0
130+
131+ let githubEventName = Environment.GetEnvironmentVariable " GITHUB_EVENT_NAME"
132+
133+ match githubEventName with
134+ | " push" ->
135+ let nugetApiSource = " https://api.nuget.org/v3/index.json"
136+
137+ let NugetPush proj =
138+ Process
139+ .Execute(
140+ {
141+ Command = " dotnet"
142+ Arguments =
143+ sprintf
144+ " nuget push %s /nupkg/%s .%s .nupkg --api-key %s --source %s "
145+ proj
146+ proj
147+ fullVersion
148+ nugetApiKey
149+ nugetApiSource
150+ },
151+ Echo.All
152+ )
153+ .UnwrapDefault()
154+ |> ignore
155+
156+ for proj in projs do
157+ NugetPush proj
158+
159+ | null
160+ | " " -> failwith " The env var for github event name should have a value"
161+
162+ | _ ->
163+ Console.WriteLine
164+ " Github event name is not 'push', skipping dotnet nuget push"
165+
166+ Environment.Exit 0
0 commit comments