Skip to content

Commit

Permalink
Publish via FAKE
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Nov 20, 2015
1 parent c4c1ec3 commit 286c824
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ temp
.fake
.vs
*.js
.vscode
.orig
release.cmd
paket-files
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 1.0.2 - 20.11.2015
* First release from FAKE

#### 1.0.1 - 19.11.2015
* Fix paths for Linux

Expand Down
107 changes: 104 additions & 3 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,39 +66,132 @@ let run cmd args dir =
) System.TimeSpan.MaxValue = false then
traceError <| sprintf "Error while running '%s' with args: %s" cmd args

let npmTool =
match isUnix with
| true -> "/usr/local/bin/npm"
| _ -> __SOURCE_DIRECTORY__ </> "packages/Npm.js/tools/npm.cmd"

let vsceTool =
#if MONO
"vsce"
#else
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) </> "npm" </> "vsce.cmd"
#endif


// --------------------------------------------------------------------------------------
// Build the Generator project and run it
// --------------------------------------------------------------------------------------

Target "Clean" (fun _ ->
CleanDir "./temp"
CopyFiles "release" ["README.md"; "LICENSE.md"; "RELEASE_NOTES.md"]
)

#if MONO
Target "BuildGenerator" (fun () ->
[ __SOURCE_DIRECTORY__ @@ "src" @@ "Ionide.FSharp.fsproj" ]
[ __SOURCE_DIRECTORY__ </> "src" </> "Ionide.FSharp.fsproj" ]
|> MSBuildDebug "" "Rebuild"
|> Log "AppBuild-Output: "
)

Target "RunGenerator" (fun () ->
(TimeSpan.FromMinutes 5.0)
|> ProcessHelper.ExecProcess (fun p ->
p.FileName <- __SOURCE_DIRECTORY__ @@ "src" @@ "bin" @@ "Debug" @@ "Ionide.FSharp.exe" )
p.FileName <- __SOURCE_DIRECTORY__ </> "src" </> "bin" </> "Debug" </> "Ionide.FSharp.exe" )
|> ignore
)
#else
Target "RunScript" (fun () ->
Ionide.VSCode.Generator.translateModules typeof<Ionide.VSCode.FSharp> "../release/fsharp.js"
Ionide.VSCode.Generator.translateModules typeof<Ionide.VSCode.FSharp> (".." </> "release" </> "fsharp.js")
)
#endif

Target "InstallVSCE" ( fun _ ->
killProcess "npm"
run npmTool "install -g vsce" ""
)

Target "SetVersion" (fun _ ->
let fileName = "./release/package.json"
let lines =
File.ReadAllLines fileName
|> Seq.map (fun line ->
if line.TrimStart().StartsWith("\"version\":") then
let indent = line.Substring(0,line.IndexOf("\""))
sprintf "%s\"version\": \"%O\"," indent release.NugetVersion
else line)
File.WriteAllLines(fileName,lines)
)

Target "BuildPackage" ( fun _ ->
killProcess "vsce"
run vsceTool "package" "release"
!! "release/*.vsix"
|> Seq.iter(MoveFile "./temp/")
)

Target "LoginToVSCE" ( fun _ ->
let publisher =
match getBuildParam "vsce-publisher" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "VSCE Publisher: "

let token =
match getBuildParam "vsce-token" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "VSCE Token: "

killProcess "vsce"
run vsceTool (sprintf "login %s -pat %s" publisher token) "release"
)

Target "PublishToGallery" ( fun _ ->
killProcess "vsce"
run vsceTool "publish" "release"
)

#load "paket-files/fsharp/FAKE/modules/Octokit/Octokit.fsx"
open Octokit

Target "ReleaseGitHub" (fun _ ->
let user =
match getBuildParam "github-user" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserInput "Username: "
let pw =
match getBuildParam "github-pw" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "Password: "
let remote =
Git.CommandHelper.getGitResult "" "remote -v"
|> Seq.filter (fun (s: string) -> s.EndsWith("(push)"))
|> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName))
|> function None -> gitHome + "/" + gitName | Some (s: string) -> s.Split().[0]

StageAll ""
Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
Branches.pushBranch "" remote (Information.getBranchName "")

Branches.tag "" release.NugetVersion
Branches.pushTag "" remote release.NugetVersion

let file = !! ("./temp" </> "*.vsix") |> Seq.head

// release on github
createClient user pw
|> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> uploadFile file
|> releaseDraft
|> Async.RunSynchronously
)

// --------------------------------------------------------------------------------------
// Run generator by default. Invoke 'build <Target>' to override
// --------------------------------------------------------------------------------------

Target "Default" DoNothing
Target "Release" DoNothing

#if MONO
"Clean"
Expand All @@ -111,4 +204,12 @@ Target "Default" DoNothing
==> "Default"
#endif

"Default"
==> "SetVersion"
==> "InstallVSCE"
==> "BuildPackage"
==> "ReleaseGitHub"
// ==> "LoginToVSCE"
==> "PublishToGallery"
==> "Release"
RunTargetOrDefault "Default"
3 changes: 3 additions & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ source https://nuget.org/api/v2

nuget FAKE
nuget FunScript
nuget Npm.js

github fsharp/FAKE modules/Octokit/Octokit.fsx
18 changes: 17 additions & 1 deletion paket.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
NUGET
remote: https://nuget.org/api/v2
specs:
FAKE (4.0.0)
FAKE (4.9.3)
FunScript (1.1.94)
Microsoft.Bcl (1.1.10)
Microsoft.Bcl.Build (>= 1.0.14)
Microsoft.Bcl.Build (1.0.21) - import_targets: false
Microsoft.Net.Http (2.2.29)
Microsoft.Bcl (>= 1.1.10)
Microsoft.Bcl.Build (>= 1.0.14)
Node.js (4.0.0)
Npm.js (2.13.1)
Node.js (>= 0.12.7)
Octokit (0.16.0)
Microsoft.Net.Http
GITHUB
remote: fsharp/FAKE
specs:
modules/Octokit/Octokit.fsx (752592c55d7f9e2b7a10f1782cb4128703d7a7d3)
Octokit

0 comments on commit 286c824

Please sign in to comment.