Skip to content

Commit 2b22b37

Browse files
committed
new pipeline to publish pcakages to feed
1 parent 98ba995 commit 2b22b37

5 files changed

Lines changed: 308 additions & 357 deletions

File tree

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI build
2+
3+
env:
4+
OUTPUT_PATH: ${{ github.workspace }}/.nupkg
5+
DOTNET_VERSION: "3.1.100"
6+
GITHUB_SOURCE: "https://nuget.pkg.github.com/aaronpowell/index.json"
7+
CONFIGURATION: "Debug"
8+
9+
on:
10+
push:
11+
branches:
12+
- main
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Setup Dotnet ${{ env.DOTNET_VERSION }}
22+
uses: actions/setup-dotnet@v1
23+
with:
24+
dotnet-version: ${{ env.DOTNET_VERSION }}
25+
26+
- name: Restore dotnet tools
27+
run: dotnet tool restore
28+
29+
- name: Generate packages
30+
run: dotnet fake run ./build.fsx --target Release
31+
32+
- name: Publish release packages
33+
uses: actions/upload-artifact@v1
34+
with:
35+
name: packages
36+
path: ${{ env.OUTPUT_PATH }}
37+
38+
publish-github:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/download-artifact@v2
44+
with:
45+
name: packages
46+
path: ${{ env.OUTPUT_PATH }}
47+
48+
- name: Setup .NET Core ${{ env.DOTNET_VERSION }}
49+
uses: actions/setup-dotnet@v1
50+
with:
51+
dotnet-version: ${{ env.DOTNET_VERSION }}
52+
53+
- name: Publish
54+
run: dotnet nuget push --api-key ${{ secrets.GITHUB_TOKEN }} --source ${{ env.GITHUB_SOURCE }} "*.nupkg"
55+
working-directory: ${{ env.OUTPUT_PATH }}

.paket/Paket.Restore.targets

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,10 @@
2727
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
2828
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
2929
<PaketBootStrapperExeDir Condition=" Exists('$(PaketBootStrapperExePath)') " >$([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\</PaketBootStrapperExeDir>
30-
30+
3131
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT' ">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
3232
<PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
3333

34-
<!-- Disable automagic references for F# DotNet SDK -->
35-
<!-- This will not do anything for other project types -->
36-
<!-- see https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1002-fsharp-in-dotnet-sdk.md -->
37-
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
38-
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
39-
4034
<!-- Disable Paket restore under NCrunch build -->
4135
<PaketRestoreDisabled Condition="'$(NCrunch)' == '1'">True</PaketRestoreDisabled>
4236

@@ -136,7 +130,7 @@
136130
<!-- Parse our simple 'paket.restore.cached' json ...-->
137131
<PaketRestoreCachedSplitObject Include="$([System.Text.RegularExpressions.Regex]::Split(`$(PaketRestoreCachedContents)`, `{|}|,`))"></PaketRestoreCachedSplitObject>
138132
<!-- Keep Key, Value ItemGroup-->
139-
<PaketRestoreCachedKeyValue Include="@(PaketRestoreCachedSplitObject)"
133+
<PaketRestoreCachedKeyValue Include="@(PaketRestoreCachedSplitObject)"
140134
Condition=" $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `&quot;: &quot;`).Length) &gt; 1 ">
141135
<Key>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))</Key>
142136
<Value>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))</Value>
@@ -169,7 +163,7 @@
169163
<Exec Command='$(PaketBootStrapperCommand)' Condition=" '$(PaketBootstrapperStyle)' == 'classic' AND Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
170164
<Error Text="Stop build because of PAKET_ERROR_ON_MSBUILD_EXEC and we need a full restore (hashes don't match)" Condition=" '$(PAKET_ERROR_ON_MSBUILD_EXEC)' == 'true' AND '$(PaketRestoreRequired)' == 'true' AND '$(PaketDisableGlobalRestore)' != 'true'" />
171165
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(PaketDisableGlobalRestore)' != 'true' " ContinueOnError="false" />
172-
166+
173167
<!-- Step 2 Detect project specific changes -->
174168
<ItemGroup>
175169
<MyTargetFrameworks Condition="'$(TargetFramework)' != '' " Include="$(TargetFramework)"></MyTargetFrameworks>

build.fsx

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ open Fake.DotNet
55
open Fake.IO
66
open Fake.IO.Globbing.Operators
77
open Fake.Core.TargetOperators
8-
open Fake.DotNet.Testing
8+
open Fake.BuildServer
99

10-
Target.initEnvironment()
10+
Target.initEnvironment ()
1111

1212
let sln = "./FSharp.CosmosDb.sln"
1313

14-
let getChangelog() =
14+
let getChangelog () =
1515
let changelog = "CHANGELOG.md" |> Changelog.load
1616
changelog.LatestEntry
1717

@@ -23,64 +23,75 @@ let isRelease (targets: Target list) =
2323
let configuration (targets: Target list) =
2424
let defaultVal =
2525
if isRelease targets then "Release" else "Debug"
26+
2627
match Environment.environVarOrDefault "CONFIGURATION" defaultVal with
2728
| "Debug" -> DotNet.BuildConfiguration.Debug
2829
| "Release" -> DotNet.BuildConfiguration.Release
2930
| config -> DotNet.BuildConfiguration.Custom config
3031

32+
let getVersionNumber (changeLog: Changelog.ChangelogEntry) (targets: Target list) =
33+
match GitHubActions.Environment.CI false, isRelease targets with
34+
| (true, true) -> changeLog.NuGetVersion
35+
| (true, false) -> sprintf "%s-ci-%s" changeLog.NuGetVersion GitHubActions.Environment.RunId
36+
| (_, _) -> changeLog.NuGetVersion
37+
3138
Target.create "Clean" (fun _ ->
3239
DotNet.exec id "clean" "" |> ignore
33-
!!"./.nuget" |> Shell.cleanDirs)
40+
!! "./.nuget" |> Shell.cleanDirs)
3441

3542
Target.create "Restore" (fun _ -> DotNet.restore id sln)
3643

3744
Target.create "Build" (fun ctx ->
38-
let changelog = getChangelog()
45+
let changelog = getChangelog ()
3946

4047
let args =
41-
[ sprintf "/p:PackageVersion=%s" (changelog.NuGetVersion)
48+
[ sprintf "/p:PackageVersion=%s" (getVersionNumber changelog (ctx.Context.AllExecutingTargets))
4249
"--no-restore" ]
50+
4351
DotNet.build (fun c ->
4452
{ c with
4553
Configuration = configuration (ctx.Context.AllExecutingTargets)
4654
Common = c.Common |> DotNet.Options.withAdditionalArgs args }) sln)
4755

4856
Target.create "Publish" (fun ctx ->
49-
let changelog = getChangelog()
57+
let changelog = getChangelog ()
5058

5159
let args =
52-
[ sprintf "/p:PackageVersion=%s" (changelog.NuGetVersion)
60+
[ sprintf "/p:PackageVersion=%s" (getVersionNumber changelog (ctx.Context.AllExecutingTargets))
5361
"--no-restore"
5462
"--no-build" ]
63+
5564
DotNet.publish (fun c ->
5665
{ c with
5766
Configuration = configuration (ctx.Context.AllExecutingTargets)
5867
Common = c.Common |> DotNet.Options.withAdditionalArgs args }) sln)
5968

6069
Target.create "Package" (fun ctx ->
61-
let changelog = getChangelog()
70+
let changelog = getChangelog ()
6271

6372
let args =
64-
[ sprintf "/p:PackageVersion=%s" (changelog.NuGetVersion)
73+
[ sprintf "/p:PackageVersion=%s" (getVersionNumber changelog (ctx.Context.AllExecutingTargets))
6574
sprintf "/p:PackageReleaseNotes=\"%s\"" (sprintf "%O" changelog) ]
75+
6676
DotNet.pack (fun c ->
6777
{ c with
6878
Configuration = configuration (ctx.Context.AllExecutingTargets)
6979
OutputPath = Some "./.nupkg"
7080
Common = c.Common |> DotNet.Options.withAdditionalArgs args }) sln)
7181

7282
Target.create "PackageVersion" (fun _ ->
73-
let version = getChangelog()
83+
let version = getChangelog ()
7484
printfn "The version is %s" version.NuGetVersion)
7585

7686
Target.create "Changelog" (fun _ ->
77-
let changelog = getChangelog()
87+
let changelog = getChangelog ()
7888
Directory.ensure "./.nupkg"
7989

80-
[| sprintf "%O" changelog |] |> File.append "./.nupkg/changelog.md")
90+
[| sprintf "%O" changelog |]
91+
|> File.append "./.nupkg/changelog.md")
8192

8293
Target.create "SetVersionForCI" (fun _ ->
83-
let changelog = getChangelog()
94+
let changelog = getChangelog ()
8495
printfn "::set-env name=package_version::%s" changelog.NuGetVersion)
8596

8697
Target.create "Test" (fun _ -> DotNet.test id sln)
@@ -90,14 +101,20 @@ Target.create "RunAnalyzer" (fun ctx ->
90101
sprintf
91102
"--project samples/FSharp.CosmosDb.Samples/FSharp.CosmosDb.Samples.fsproj --analyzers-path src/FSharp.CosmosDb.Analyzer/bin/%A/netcoreapp2.0/publish"
92103
(configuration (ctx.Context.AllExecutingTargets))
104+
93105
DotNet.exec id "fsharp-analyzers" args |> ignore)
94106

95107
Target.create "Default" ignore
96108
Target.create "Release" ignore
97109

98110
"Clean" ==> "Restore" ==> "Build" ==> "Default"
99111

100-
"Default" ==> "Publish" ==> "Test" ==> "Package" ==> "Changelog" ==> "Release"
112+
"Default"
113+
==> "Publish"
114+
==> "Test"
115+
==> "Package"
116+
==> "Changelog"
117+
==> "Release"
101118

102119
"Default" ==> "Publish" ==> "RunAnalyzer"
103120

paket.dependencies

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ nuget YoloDev.Expecto.TestSdk 0.8.0
1818
nuget Microsoft.NET.Test.Sdk 16.5.0
1919
nuget Microsoft.SourceLink.GitHub prerelease copy_local: true
2020
nuget Microsoft.NETFramework.ReferenceAssemblies copy_local: true
21-
2221
nuget FSharp.SystemTextJson 0.10.25
22+
2323
// [ FAKE GROUP ]
2424
group Build
2525
storage none
@@ -28,4 +28,5 @@ group Build
2828
nuget Fake.IO.FileSystem
2929
nuget Fake.Core.Target
3030
nuget Fake.Core.ReleaseNotes
31-
nuget Fake.DotNet.Testing.Expecto
31+
nuget Fake.DotNet.Testing.Expecto
32+
nuget Fake.BuildServer.GitHubActions

0 commit comments

Comments
 (0)