@@ -5,14 +5,12 @@ let licenseHeader = """
55
66# This file is auto-generated.""" .Trim()
77
8- #r " nuget: Generaptor.Library , 1.9.1"
8+ #r " nuget: Generaptor, 1.9.1"
99
1010open System
1111open Generaptor
1212open Generaptor.GitHubActions
1313open type Generaptor.GitHubActions .Commands
14- open type Generaptor.Library .Actions
15- open type Generaptor.Library .Patterns
1614
1715let mainBranch = " main"
1816let ubuntu = " ubuntu-24.04"
@@ -36,43 +34,83 @@ let workflows = [
3634 yield ! actions
3735 ]
3836
39- workflow " main" [
40- name " Main"
41- yield ! mainTriggers
37+ let checkOut = step(
38+ name = " Check out the sources" ,
39+ usesSpec = Auto " actions/checkout"
40+ )
4241
43- job " verify-workflows" [
44- runsOn " ubuntu-24.04"
42+ let dotNetJob id steps =
43+ job id [
44+ setEnv " DOTNET_CLI_TELEMETRY_OPTOUT" " 1"
45+ setEnv " DOTNET_NOLOGO" " 1"
46+ setEnv " NUGET_PACKAGES" " ${{ github.workspace }}/.github/nuget-packages"
4547
46- checkout
48+ checkOut
4749 step(
4850 name = " Set up .NET SDK" ,
4951 usesSpec = Auto " actions/setup-dotnet"
5052 )
53+ step(
54+ name = " Cache NuGet packages" ,
55+ usesSpec = Auto " actions/cache" ,
56+ options = Map.ofList [
57+ " key" , " ${{ runner.os }}.nuget.${{ hashFiles('**/*.*proj', '**/*.props') }}"
58+ " path" , " ${{ env.NUGET_PACKAGES }}"
59+ ]
60+ )
61+
62+ yield ! steps
63+ ]
64+
65+ workflow " main" [
66+ name " Main"
67+ yield ! mainTriggers
68+
69+ dotNetJob " verify-workflows" [
70+ runsOn " ubuntu-24.04"
5171 step( run = " dotnet fsi ./scripts/github-actions.fsx verify" )
5272 ]
5373
54- job " check" [
55- checkout
56- yield ! dotNetBuildAndTest( projectFileExtensions = [ " .csproj" ])
57- ] |> addMatrix images
74+ dotNetJob " check" [
75+ strategy( failFast = false , matrix = [
76+ " image" , [
77+ " macos-14"
78+ " ubuntu-24.04"
79+ " ubuntu-24.04-arm"
80+ " windows-11-arm"
81+ " windows-2025"
82+ ]
83+ ])
84+ runsOn " ${{ matrix.image }}"
85+
86+ step(
87+ name = " Build" ,
88+ run = " dotnet build"
89+ )
90+ step(
91+ name = " Test" ,
92+ run = " dotnet test" ,
93+ timeoutMin = 10
94+ )
95+ ]
5896
5997 job " licenses" [
6098 runsOn ubuntu
61- checkout
99+ checkOut
62100
63101 step( name = " REUSE license check" , usesSpec = Auto " fsfe/reuse-action" )
64102 ]
65103
66104 job " encoding" [
67105 runsOn ubuntu
68- checkout
106+ checkOut
69107
70108 step( name = " Verify encoding" , shell = " pwsh" , run = " scripts/Test-Encoding.ps1" )
71109 ]
72110
73- job " nowarn-empty" [
111+ dotNetJob " nowarn-empty" [
74112 runsOn ubuntu
75- checkout
113+ checkOut
76114
77115 step( name = " Verify with NoWarn as empty" , run = " dotnet build /p:NoWarn='' --no-incremental" )
78116 ]
@@ -84,15 +122,22 @@ let workflows = [
84122 onPushTags " v*"
85123 job " nuget" [
86124 runsOn ubuntu
87- checkout
125+ checkOut
88126 jobPermission( PermissionKind.Contents, AccessKind.Write)
89127
90128 let configuration = " Release"
91129
92130 let versionStepId = " version"
93131 let versionField = " ${{ steps." + versionStepId + " .outputs.version }}"
94- getVersionWithScript( stepId = versionStepId, scriptPath = " scripts/Get-Version.ps1" )
95- dotNetPack( version = versionField)
132+ step(
133+ id = " version" ,
134+ name = " Get version" ,
135+ shell = " pwsh" ,
136+ run = " echo \" version=$(scripts/Get-Version.ps1 -RefName $env:GITHUB_REF)\" >> $env:GITHUB_OUTPUT"
137+ )
138+ step(
139+ run = " dotnet pack --configuration Release -p:Version=${{ steps.version.outputs.version }}"
140+ )
96141
97142 let releaseNotes = " ./release-notes.md"
98143 step(
@@ -112,23 +157,35 @@ let workflows = [
112157 yield ! artifacts " TruePath" true
113158 yield ! artifacts " TruePath.SystemIo" true
114159 ]
115- uploadArtifacts [
116- releaseNotes
117- yield ! allArtifacts
118- ]
119- yield ! ifCalledOnTagPush [
120- createRelease(
121- name = $" TruePath v{versionField}" ,
122- releaseNotesPath = releaseNotes,
123- files = allArtifacts
124- )
125- yield ! pushToNuGetOrg " NUGET_TOKEN_TRUE_PATH" (
126- artifacts " TruePath" false
127- )
128- yield ! pushToNuGetOrg " NUGET_TOKEN_TRUE_PATH_SYSTEM_IO" (
129- artifacts " TruePath.SystemIo" false
130- )
131- ]
160+
161+ step(
162+ name = " Upload artifacts" ,
163+ usesSpec = Auto " actions/upload-artifact" ,
164+ options = Map.ofList [
165+ " path" , [ releaseNotes; yield ! allArtifacts ] |> String.concat " \n "
166+ ]
167+ )
168+
169+ step(
170+ condition = " startsWith(github.ref, 'refs/tags/v')" ,
171+ name = " Create a release" ,
172+ usesSpec = Auto " softprops/action-gh-release" ,
173+ options = Map.ofList [
174+ " body_path" , " ./release-notes.md"
175+ " files" , allArtifacts |> String.concat " \n "
176+ " name" , $" TruePath v{versionField}"
177+ ]
178+ )
179+ step(
180+ condition = " startsWith(github.ref, 'refs/tags/v')" ,
181+ name = " Push TruePath to NuGet" ,
182+ run = $" dotnet nuget push ./TruePath/bin/Release/TruePath.{versionField}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{{{ secrets.NUGET_TOKEN_TRUE_PATH }}}}"
183+ )
184+ step(
185+ condition = " startsWith(github.ref, 'refs/tags/v')" ,
186+ name = " Push TruePath.SystemIo to NuGet" ,
187+ run = $" dotnet nuget push ./TruePath.SystemIo/bin/Release/TruePath.SystemIo.{versionField}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{{{ secrets.NUGET_TOKEN_TRUE_PATH_SYSTEM_IO }}}}"
188+ )
132189 ]
133190 ]
134191
@@ -146,10 +203,7 @@ let workflows = [
146203 job " publish-docs" [
147204 environment( name = " github-pages" , url = " ${{ steps.deployment.outputs.page_url }}" )
148205 runsOn " ubuntu-24.04"
149- step(
150- name = " Checkout" ,
151- usesSpec = Auto " actions/checkout"
152- )
206+ checkOut
153207 step(
154208 name = " Set up .NET SDK" ,
155209 usesSpec = Auto " actions/setup-dotnet" ,
0 commit comments