Skip to content

Commit 3bfccdb

Browse files
committed
pushing to nuget
1 parent 5abb190 commit 3bfccdb

File tree

3 files changed

+93
-11
lines changed

3 files changed

+93
-11
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ _UpgradeReport*
1414
packages
1515
.nuget
1616
.paket
17+
nupkg/
18+
_.nuspec
1719

1820
# Ignore Visual Studio files
1921
*.pdb

.travis.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ install:
66
- mono .paket/paket.exe install
77
script:
88
- echo "module Xake.Const [<Literal>] let internal Version = \"$VER.$TRAVIS_BUILD_NUMBER\"" > ./core/VersionInfo.fs
9-
- fsharpi build.fsx -- build test
9+
- fsharpi build.fsx -- build test nuget-pack
1010
deploy:
11-
provider: releases
12-
file:
13-
- "./bin/Xake.Core.dll"
14-
- "./bin/Xake.Core.XML"
15-
skip_cleanup: true
16-
on:
17-
tags: true
18-
condition: "${TRAVIS_TAG:0:1} = v"
19-
api-key:
20-
secure: GcNd0L3Kdyv9vTeKqDXHAfxQne8a6guWQYCiiEvQWtLwNss4foV2dD6PQ8W+J7l+ay8wLC+P3ZKxO0GiKbn5cglXTbBI9WlrHk+nrSQ/JWmaqqjZhGUlAvlek0Ko4walGfRQJPIaZ9pbnX4L4Mj+jrwQWrI1IyzZXbSBL2i2Tgo=
11+
- provider: releases
12+
file:
13+
- "./bin/Xake.Core.dll"
14+
- "./bin/Xake.Core.XML"
15+
skip_cleanup: true
16+
on:
17+
tags: true
18+
condition: "${TRAVIS_TAG:0:1} = v"
19+
api-key:
20+
secure: GcNd0L3Kdyv9vTeKqDXHAfxQne8a6guWQYCiiEvQWtLwNss4foV2dD6PQ8W+J7l+ay8wLC+P3ZKxO0GiKbn5cglXTbBI9WlrHk+nrSQ/JWmaqqjZhGUlAvlek0Ko4walGfRQJPIaZ9pbnX4L4Mj+jrwQWrI1IyzZXbSBL2i2Tgo=
21+
- provider: script
22+
script: fsharpi build.fsx -- -ll Diag nuget-push
23+
skip_cleanup: true
24+
on:
25+
tags: true
26+
condition: "${TRAVIS_TAG:0:1} = v"

build.fsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,33 @@ open Xake
1616
open Xake.SystemTasks
1717

1818
let TestsAssembly = "bin/XakeLibTests.dll"
19+
let (=?) value deflt = match value with |Some v -> v |None -> deflt
20+
21+
let DEF_VER = "0.0.1"
22+
23+
let nuget_exe args = system (useClr >> checkErrorLevel) "packages/NuGet.CommandLine/tools/NuGet.exe" args |> Action.Ignore
24+
25+
module nuget =
26+
module private impl =
27+
let newline = System.Environment.NewLine
28+
let wrapXml node value = sprintf "<%s>%s</%s>" node value node
29+
let wrapXmlNl node (value:string) =
30+
let attrs = value.Split([|newline|], System.StringSplitOptions.None) |> Seq.ofArray
31+
let content = attrs |> Seq.map ((+) " ") |> String.concat newline
32+
sprintf "<%s>%s</%s>" node (newline + content + newline) node
33+
let toXmlStr (node,value) = wrapXml node value
34+
35+
open impl
36+
37+
let dependencies deps =
38+
"dependencies", newline
39+
+ (deps |> List.map (fun (s,v) -> sprintf """<dependency id="%s" version="%s" />""" s v) |> String.concat newline)
40+
+ newline
41+
42+
let metadata = List.map toXmlStr >> String.concat newline >> wrapXmlNl "metadata"
43+
let files = List.map (fun(f,t) -> (f,t) ||> sprintf """<file src="%s" target="%s" />""") >> String.concat newline >> wrapXmlNl "files"
44+
let target t ff = ff |> List.map (fun file -> file,t)
45+
let package = String.concat newline >> wrapXmlNl "package" >> ((+) ("<?xml version=\"1.0\"?>" + newline))
1946

2047
do xake {ExecOptions.Default with ConLogLevel = Verbosity.Chatty } {
2148
var "NETFX-TARGET" "4.5"
@@ -134,4 +161,51 @@ do xake {ExecOptions.Default with ConLogLevel = Verbosity.Chatty } {
134161

135162
}
136163
]
164+
165+
(* Nuget publishing rules *)
166+
rules [
167+
"nuget-pack" => action {
168+
169+
let libFiles = ["bin/Xake.Core.dll"]
170+
do! need libFiles
171+
172+
let! ver = getEnv("VER")
173+
174+
let nuspec =
175+
nuget.package [
176+
nuget.metadata [
177+
"id", "Xake"
178+
"version", ver =? DEF_VER
179+
"authors", "OlegZee"
180+
"owners", "OlegZee"
181+
"projectUrl", "https://github.com/OlegZee/Xake"
182+
"requireLicenseAcceptance", "false"
183+
"description", "Xake build tool"
184+
"releaseNotes", ""
185+
"copyright", sprintf "Copyright %i" System.DateTime.Now.Year
186+
"tags", "Xake F# Build"
187+
nuget.dependencies []
188+
]
189+
nuget.files (libFiles |> nuget.target "tools")
190+
]
191+
192+
let nuspec_file = "_.nuspec"
193+
do System.IO.Directory.CreateDirectory("nupkg") |> ignore
194+
do System.IO.File.WriteAllText(nuspec_file, nuspec)
195+
196+
do! nuget_exe ["pack"; nuspec_file; "-OutputDirectory"; "nupkg" ]
197+
}
198+
199+
"nuget-push" => action {
200+
201+
do! need ["nuget-pack"]
202+
203+
let! ver = getEnv("VER")
204+
let package_name = sprintf "Xake.%s.nupkg" (ver =? DEF_VER)
205+
206+
let! nuget_key = getEnv("NUGET_KEY")
207+
do! nuget_exe ["push"; "nupkg" </> package_name; nuget_key =? ""; "-Source"; "nuget.org"]
208+
}
209+
]
137210
}
211+

0 commit comments

Comments
 (0)