Skip to content

Commit 5903872

Browse files
authored
Merge pull request #15 from jwosty/jw-ci
Fix CI
2 parents 5bd41c1 + 6f5e5e7 commit 5903872

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ jobs:
2020
run: dotnet fake build
2121
- name: Pack
2222
run: |
23-
dotnet fake build -t Pack
24-
dotnet fake build -t PackTemplates
23+
dotnet fake build -t PackAll
2524
- name: Upload artifacts
2625
uses: actions/upload-artifact@v2
2726
with:
28-
name: artifacts-windows
27+
name: interstellar-windows
2928
path: artifacts
3029
- name: Test
3130
run: |
@@ -48,11 +47,11 @@ jobs:
4847
- name: Build
4948
run: dotnet fake build
5049
- name: Pack
51-
run: dotnet fake build -t pack
50+
run: dotnet fake build -t PackAll
5251
- name: Upload artifacts
5352
uses: actions/upload-artifact@v2
5453
with:
55-
name: artifacts-macos
54+
name: interstellar-macos
5655
path: artifacts/
5756
- name: Test
5857
run: |

build.fsx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ let changelog = scrapeChangelog () |> Seq.toList
8787
let currentVersionInfo = changelog.[0]
8888
/// Indicates the extra version number that's added to the template package. When releasing a new version of Interstellar, reset this to 0. Whenever making a
8989
/// change to just the template, increment this.
90-
let currentTemplateMinorVersion = 2
90+
let currentTemplateMinorVersion = 1
9191

9292
let addProperties props defaults = { defaults with Properties = [yield! defaults.Properties; yield! props]}
9393

@@ -134,13 +134,12 @@ let getNupkgPath version projPath =
134134
Path.Combine ([|projDir; "bin"; "Release";
135135
sprintf "%s%s.nupkg" (Path.GetFileNameWithoutExtension projPath) vstr|])
136136

137-
let getNupkgArtifactPath proj = Path.Combine (artifactsPath, sprintf "%s.nupkg" (Path.GetFileNameWithoutExtension proj))
138-
139137
Target.create "Clean" (fun _ ->
140138
Trace.log " --- Cleaning --- "
141139
for proj in projects do
142-
try File.Delete (getNupkgPath (Some currentVersionInfo.versionName) proj) with _ -> ()
143-
try File.Delete (getNupkgArtifactPath proj) with _ -> ()
140+
let vstr = currentVersionInfo.versionName
141+
File.delete (getNupkgPath (Some vstr) proj)
142+
!! (Path.Combine (artifactsPath, "**/*.nupkg")) |> File.deleteAll
144143
let projects =
145144
if Environment.isWindows then [ Projects.winFormsLib; Projects.wpfLib; yield! Templates.winProjects ]
146145
else if Environment.isMacOS then [ Solutions.macos; yield! Templates.macosProjects ]
@@ -150,7 +149,6 @@ Target.create "Clean" (fun _ ->
150149
Shell.deleteDir ".fsdocs"
151150
Shell.deleteDir "output"
152151
Shell.deleteDir "temp"
153-
Shell.deleteDir artifactsPath
154152
)
155153

156154
Target.create "Restore" (fun _ ->
@@ -201,14 +199,14 @@ Target.create "Pack" (fun _ ->
201199
Trace.log (sprintf "PROJECT LIST: %A" projects)
202200
for proj in projects do
203201
msbuild id proj
204-
// Strip version stuff from the file name, and collect all generated package archives into a common folder
205-
let oldNupkgPath = getNupkgPath (Some currentVersionInfo.versionName) proj
206-
Directory.CreateDirectory "artifacts" |> ignore
207-
let nupkgArtifact = getNupkgArtifactPath proj
208-
Trace.log (sprintf "Moving %s -> %s" oldNupkgPath nupkgArtifact)
209-
try File.Delete nupkgArtifact with _ -> ()
210-
File.Copy (oldNupkgPath, nupkgArtifact)
211-
``Nupkg-hack``.hackNupkgAtPath nupkgArtifact // see #3
202+
// Collect all generated package archives into a common folder
203+
let vstr = currentVersionInfo.versionName
204+
let oldNupkgPath = getNupkgPath (Some vstr) proj
205+
Shell.mkdir artifactsPath
206+
Shell.moveFile artifactsPath oldNupkgPath
207+
// see https://github.com/jwosty/Interstellar/issues/3
208+
!! (Path.Combine (artifactsPath, "**", "*.nupkg"))
209+
|> Seq.iter (``Nupkg-hack``.hackNupkgAtPath)
212210
)
213211

214212
Target.create "BuildTemplateProjects" (fun _ ->
@@ -243,20 +241,20 @@ Target.create "PackTemplates" (fun _ ->
243241

244242
Target.create "PackAll" ignore
245243

244+
Target.create "TestAll" ignore
245+
246246
Target.create "All" ignore
247247

248248
open Fake.Core.TargetOperators
249249

250250
// *** Define Dependencies ***
251-
"Clean"
252-
==> "Restore"
251+
"Restore"
253252
==> "Build"
254253
==> "Pack"
255254
==> "PackAll"
256255
==> "All"
257256

258-
"Clean"
259-
==> "PackTemplates"
257+
"PackTemplates"
260258
==> "PackAll"
261259
==> "All"
262260

@@ -265,6 +263,14 @@ open Fake.Core.TargetOperators
265263
==> "ReleaseDocs"
266264
==> "All"
267265

266+
"BuildTemplateProjects"
267+
==> "TestAll"
268+
269+
// "Build"
270+
// ==> "Test"
271+
"Test"
272+
==> "TestAll"
273+
268274
"Build"
269275
==> "BuildTemplateProjects"
270276

nupkg-hack.fsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ open System.IO
44
open System.IO.Compression
55
open System.Text
66
open System.Text.RegularExpressions
7+
open Fake.Core
8+
open Fake.IO
79

810
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
911

@@ -27,8 +29,7 @@ let changeVersionConstraints text =
2729

2830
let hackNupkgFromStream (path: string) (stream: Stream) =
2931
use archive = new ZipArchive(stream, ZipArchiveMode.Update)
30-
let nuspecName = sprintf "%s.nuspec" (Path.GetFileNameWithoutExtension path)
31-
let oldEntry = archive.GetEntry nuspecName
32+
let oldEntry = archive.Entries |> Seq.find (fun e -> e.Name.EndsWith ".nuspec")
3233
let input =
3334
(use nuspecReader = new StreamReader(oldEntry.Open(), Encoding.UTF8) in nuspecReader.ReadToEnd())
3435
let output = changeVersionConstraints input
@@ -37,6 +38,7 @@ let hackNupkgFromStream (path: string) (stream: Stream) =
3738

3839
/// Cracks open a nupkg and changes all Interstellar package reference constraints from >= to =
3940
let hackNupkgAtPath (path: string) =
41+
Trace.log ("Hacking nupkg: " + path)
4042
use file = File.Open (path, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
4143
hackNupkgFromStream path file
4244

0 commit comments

Comments
 (0)