Skip to content

Commit 286c824

Browse files
committed
Publish via FAKE
1 parent c4c1ec3 commit 286c824

File tree

5 files changed

+131
-4
lines changed

5 files changed

+131
-4
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ temp
5757
.fake
5858
.vs
5959
*.js
60+
.vscode
61+
.orig
62+
release.cmd
63+
paket-files

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 1.0.2 - 20.11.2015
2+
* First release from FAKE
3+
14
#### 1.0.1 - 19.11.2015
25
* Fix paths for Linux
36

build.fsx

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,39 +66,132 @@ let run cmd args dir =
6666
) System.TimeSpan.MaxValue = false then
6767
traceError <| sprintf "Error while running '%s' with args: %s" cmd args
6868

69+
let npmTool =
70+
match isUnix with
71+
| true -> "/usr/local/bin/npm"
72+
| _ -> __SOURCE_DIRECTORY__ </> "packages/Npm.js/tools/npm.cmd"
73+
74+
let vsceTool =
75+
#if MONO
76+
"vsce"
77+
#else
78+
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) </> "npm" </> "vsce.cmd"
79+
#endif
80+
6981

7082
// --------------------------------------------------------------------------------------
7183
// Build the Generator project and run it
7284
// --------------------------------------------------------------------------------------
7385

7486
Target "Clean" (fun _ ->
87+
CleanDir "./temp"
7588
CopyFiles "release" ["README.md"; "LICENSE.md"; "RELEASE_NOTES.md"]
7689
)
7790

7891
#if MONO
7992
Target "BuildGenerator" (fun () ->
80-
[ __SOURCE_DIRECTORY__ @@ "src" @@ "Ionide.FSharp.fsproj" ]
93+
[ __SOURCE_DIRECTORY__ </> "src" </> "Ionide.FSharp.fsproj" ]
8194
|> MSBuildDebug "" "Rebuild"
8295
|> Log "AppBuild-Output: "
8396
)
8497

8598
Target "RunGenerator" (fun () ->
8699
(TimeSpan.FromMinutes 5.0)
87100
|> ProcessHelper.ExecProcess (fun p ->
88-
p.FileName <- __SOURCE_DIRECTORY__ @@ "src" @@ "bin" @@ "Debug" @@ "Ionide.FSharp.exe" )
101+
p.FileName <- __SOURCE_DIRECTORY__ </> "src" </> "bin" </> "Debug" </> "Ionide.FSharp.exe" )
89102
|> ignore
90103
)
91104
#else
92105
Target "RunScript" (fun () ->
93-
Ionide.VSCode.Generator.translateModules typeof<Ionide.VSCode.FSharp> "../release/fsharp.js"
106+
Ionide.VSCode.Generator.translateModules typeof<Ionide.VSCode.FSharp> (".." </> "release" </> "fsharp.js")
94107
)
95108
#endif
96109

110+
Target "InstallVSCE" ( fun _ ->
111+
killProcess "npm"
112+
run npmTool "install -g vsce" ""
113+
)
114+
115+
Target "SetVersion" (fun _ ->
116+
let fileName = "./release/package.json"
117+
let lines =
118+
File.ReadAllLines fileName
119+
|> Seq.map (fun line ->
120+
if line.TrimStart().StartsWith("\"version\":") then
121+
let indent = line.Substring(0,line.IndexOf("\""))
122+
sprintf "%s\"version\": \"%O\"," indent release.NugetVersion
123+
else line)
124+
File.WriteAllLines(fileName,lines)
125+
)
126+
127+
Target "BuildPackage" ( fun _ ->
128+
killProcess "vsce"
129+
run vsceTool "package" "release"
130+
!! "release/*.vsix"
131+
|> Seq.iter(MoveFile "./temp/")
132+
)
133+
134+
Target "LoginToVSCE" ( fun _ ->
135+
let publisher =
136+
match getBuildParam "vsce-publisher" with
137+
| s when not (String.IsNullOrWhiteSpace s) -> s
138+
| _ -> getUserPassword "VSCE Publisher: "
139+
140+
let token =
141+
match getBuildParam "vsce-token" with
142+
| s when not (String.IsNullOrWhiteSpace s) -> s
143+
| _ -> getUserPassword "VSCE Token: "
144+
145+
killProcess "vsce"
146+
run vsceTool (sprintf "login %s -pat %s" publisher token) "release"
147+
)
148+
149+
Target "PublishToGallery" ( fun _ ->
150+
killProcess "vsce"
151+
run vsceTool "publish" "release"
152+
)
153+
154+
#load "paket-files/fsharp/FAKE/modules/Octokit/Octokit.fsx"
155+
open Octokit
156+
157+
Target "ReleaseGitHub" (fun _ ->
158+
let user =
159+
match getBuildParam "github-user" with
160+
| s when not (String.IsNullOrWhiteSpace s) -> s
161+
| _ -> getUserInput "Username: "
162+
let pw =
163+
match getBuildParam "github-pw" with
164+
| s when not (String.IsNullOrWhiteSpace s) -> s
165+
| _ -> getUserPassword "Password: "
166+
let remote =
167+
Git.CommandHelper.getGitResult "" "remote -v"
168+
|> Seq.filter (fun (s: string) -> s.EndsWith("(push)"))
169+
|> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName))
170+
|> function None -> gitHome + "/" + gitName | Some (s: string) -> s.Split().[0]
171+
172+
StageAll ""
173+
Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
174+
Branches.pushBranch "" remote (Information.getBranchName "")
175+
176+
Branches.tag "" release.NugetVersion
177+
Branches.pushTag "" remote release.NugetVersion
178+
179+
let file = !! ("./temp" </> "*.vsix") |> Seq.head
180+
181+
// release on github
182+
createClient user pw
183+
|> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
184+
|> uploadFile file
185+
|> releaseDraft
186+
|> Async.RunSynchronously
187+
)
188+
97189
// --------------------------------------------------------------------------------------
98190
// Run generator by default. Invoke 'build <Target>' to override
99191
// --------------------------------------------------------------------------------------
100192

101193
Target "Default" DoNothing
194+
Target "Release" DoNothing
102195

103196
#if MONO
104197
"Clean"
@@ -111,4 +204,12 @@ Target "Default" DoNothing
111204
==> "Default"
112205
#endif
113206

207+
"Default"
208+
==> "SetVersion"
209+
==> "InstallVSCE"
210+
==> "BuildPackage"
211+
==> "ReleaseGitHub"
212+
// ==> "LoginToVSCE"
213+
==> "PublishToGallery"
214+
==> "Release"
114215
RunTargetOrDefault "Default"

paket.dependencies

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ source https://nuget.org/api/v2
22

33
nuget FAKE
44
nuget FunScript
5+
nuget Npm.js
6+
7+
github fsharp/FAKE modules/Octokit/Octokit.fsx

paket.lock

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
NUGET
22
remote: https://nuget.org/api/v2
33
specs:
4-
FAKE (4.0.0)
4+
FAKE (4.9.3)
55
FunScript (1.1.94)
6+
Microsoft.Bcl (1.1.10)
7+
Microsoft.Bcl.Build (>= 1.0.14)
8+
Microsoft.Bcl.Build (1.0.21) - import_targets: false
9+
Microsoft.Net.Http (2.2.29)
10+
Microsoft.Bcl (>= 1.1.10)
11+
Microsoft.Bcl.Build (>= 1.0.14)
12+
Node.js (4.0.0)
13+
Npm.js (2.13.1)
14+
Node.js (>= 0.12.7)
15+
Octokit (0.16.0)
16+
Microsoft.Net.Http
17+
GITHUB
18+
remote: fsharp/FAKE
19+
specs:
20+
modules/Octokit/Octokit.fsx (752592c55d7f9e2b7a10f1782cb4128703d7a7d3)
21+
Octokit

0 commit comments

Comments
 (0)