Skip to content

Commit a73b688

Browse files
author
Juriyx
authored
Added the project template based on the Star Wars API Sample (#419)
1 parent 5ee1581 commit a73b688

17 files changed

+439
-43
lines changed

.github/workflows/publish_ci.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,28 @@ on:
66
- dev
77

88
jobs:
9-
build:
9+
publish:
10+
1011
runs-on: ubuntu-latest
1112

1213
steps:
1314
- name: Checkout
1415
uses: actions/checkout@v3
16+
1517
- name: Set Build Version
1618
run: |
1719
$File = (
1820
Select-Xml -XPath "/Project/PropertyGroup[@Label='NuGet']/Version" -Path "Directory.Build.targets"
1921
)[0].Node
20-
$Version = $File.InnerText
21-
$File.InnerText = "$Version-ci-$env:GITHUB_RUN_ID"
22+
$version = "$($File.InnerText)-ci-$Env:GITHUB_RUN_ID"
23+
$File.InnerText = $version
2224
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath Directory.Build.targets))
25+
echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
2326
shell: pwsh
27+
2428
- name: Install .NET Core
2529
uses: actions/setup-dotnet@v3
30+
2631
- name: Add the GitHub source
2732
run: dotnet nuget add source --username USERNAME --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/fsprojects/index.json"
2833

@@ -38,32 +43,43 @@ jobs:
3843
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
3944
- name: Publish FSharp.Data.GraphQL.Shared project to GitHub
4045
run: |
41-
cd src/FSharp.Data.GraphQL.Shared
42-
dotnet nuget push ../../nuget/*Shared*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
46+
dotnet nuget push nuget/*Shared*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
4347
4448
- name: Pack FSharp.Data.GraphQL.Client project
4549
run: |
4650
cd src/FSharp.Data.GraphQL.Client
4751
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
4852
- name: Publish FSharp.Data.GraphQL.Client project to GitHub
4953
run: |
50-
cd src/FSharp.Data.GraphQL.Client
51-
dotnet nuget push ../../nuget/*Client*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
54+
dotnet nuget push nuget/*Client*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
5255
5356
- name: Pack FSharp.Data.GraphQL.Server project
5457
run: |
5558
cd src/FSharp.Data.GraphQL.Server
5659
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
5760
- name: Publish FSharp.Data.GraphQL.Server project to GitHub
5861
run: |
59-
cd src/FSharp.Data.GraphQL.Server
60-
dotnet nuget push ../../nuget/*Server*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
62+
dotnet nuget push nuget/*Server*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
6163
6264
- name: Pack FSharp.Data.GraphQL.Server.Middleware project
6365
run: |
6466
cd src/FSharp.Data.GraphQL.Server.Middleware
6567
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
6668
- name: Publish FSharp.Data.GraphQL.Server.Middleware project to GitHub
6769
run: |
68-
cd src/FSharp.Data.GraphQL.Server.Middleware
69-
dotnet nuget push ../../nuget/*Server.Middleware*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
70+
dotnet nuget push nuget/*Server.Middleware*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
71+
72+
- name: Prepare the sample project to be packed as a project template
73+
run: |
74+
& "./Prepare template project for packing.ps1"
75+
shell: pwsh
76+
77+
- name: Pack FSharp.Data.GraphQL.ProjectTemplates template project
78+
run: |
79+
cd samples
80+
dotnet pack --nologo --configuration Release -o ../nuget
81+
- name: Publish FSharp.Data.GraphQL.ProjectTemplates project to GitHub
82+
run: |
83+
$path = "nuget/FSharp.Data.GraphQL.ProjectTemplates.$Env:VERSION.nupkg"
84+
dotnet nuget push $path -s "github" -k ${{secrets.GITHUB_TOKEN}}
85+
shell: pwsh

.github/workflows/publish_release.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ jobs:
1515
with:
1616
# This is necessary so that we have the tags.
1717
fetch-depth: 0
18+
1819
- name: Set Build Version
1920
run: |
20-
$Version = "$env:GITHUB_REF_NAME"
21-
21+
$version = "$env:GITHUB_REF_NAME"
2222
$File = (
2323
Select-Xml -XPath "/Project/PropertyGroup[@Label='NuGet']/Version" -Path "Directory.Build.targets"
2424
)[0].Node
25-
26-
$File.InnerText = $Version
25+
$File.InnerText = $version
2726
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath Directory.Build.targets))
27+
echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
2828
shell: pwsh
2929

3030
- name: Install .NET Core
@@ -42,32 +42,43 @@ jobs:
4242
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
4343
- name: Publish FSharp.Data.GraphQL.Shared project to NuGet
4444
run: |
45-
cd src/FSharp.Data.GraphQL.Shared
46-
dotnet nuget push ../../nuget/*Shared*.nupkg -k ${{secrets.NUGET_SECRET}}
45+
dotnet nuget push nuget/*Shared*.nupkg -k ${{secrets.NUGET_SECRET}}
4746
4847
- name: Pack FSharp.Data.GraphQL.Client project
4948
run: |
5049
cd src/FSharp.Data.GraphQL.Client
5150
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
5251
- name: Publish FSharp.Data.GraphQL.Client project to NuGet
5352
run: |
54-
cd src/FSharp.Data.GraphQL.Client
55-
dotnet nuget push ../../nuget/*Client*.nupkg -k ${{secrets.NUGET_SECRET}}
53+
dotnet nuget push nuget/*Client*.nupkg -k ${{secrets.NUGET_SECRET}}
5654
5755
- name: Pack FSharp.Data.GraphQL.Server project
5856
run: |
5957
cd src/FSharp.Data.GraphQL.Server
6058
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
6159
- name: Publish FSharp.Data.GraphQL.Server project to NuGet
6260
run: |
63-
cd src/FSharp.Data.GraphQL.Server
64-
dotnet nuget push ../../nuget/*Server*.nupkg -k ${{secrets.NUGET_SECRET}}
61+
dotnet nuget push nuget/*Server*.nupkg -k ${{secrets.NUGET_SECRET}}
6562
6663
- name: Pack FSharp.Data.GraphQL.Server.Middleware project
6764
run: |
6865
cd src/FSharp.Data.GraphQL.Server.Middleware
6966
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
7067
- name: Publish FSharp.Data.GraphQL.Server.Middleware project to NuGet
7168
run: |
72-
cd src/FSharp.Data.GraphQL.Server.Middleware
73-
dotnet nuget push ../../nuget/*Server.Middleware*.nupkg -k ${{secrets.NUGET_SECRET}}
69+
dotnet nuget push nuget/*Server.Middleware*.nupkg -k ${{secrets.NUGET_SECRET}}
70+
71+
- name: Prepare the sample project to be packed as a project template
72+
run: |
73+
& "./Prepare template project for packing.ps1"
74+
shell: pwsh
75+
76+
- name: Pack FSharp.Data.GraphQL.ProjectTemplates template project
77+
run: |
78+
cd samples
79+
dotnet pack --nologo --configuration Release -o ../nuget
80+
- name: Publish FSharp.Data.GraphQL.ProjectTemplates project to GitHub
81+
run: |
82+
$path = "nuget/FSharp.Data.GraphQL.ProjectTemplates.$Env:VERSION.nupkg"
83+
dotnet nuget push $path -k ${{secrets.NUGET_SECRET}}
84+
shell: pwsh

Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
<RepoRoot>$([System.IO.Path]::GetDirectoryName($([MSBuild]::GetPathOfFileAbove('.gitignore', '$(MSBuildThisFileDirectory)'))))</RepoRoot>
1818
<RepositoryUrl>https://github.com/fsprojects/FSharp.Data.GraphQL</RepositoryUrl>
19+
<RepositoryType>git</RepositoryType>
1920
<Version>2.0.0</Version>
2021
<PackageTags>FSharp GraphQL Relay React Middleware</PackageTags>
2122
<PackageReadmeFile>README.md</PackageReadmeFile>
2223
<PackageIcon>icon.png</PackageIcon>
2324
<!--<PackageIconUrl>https://www.newtonsoft.com/content/images/nugeticon.png</PackageIconUrl>-->
2425
<PackageProjectUrl>https://fsprojects.github.io/FSharp.Data.GraphQL</PackageProjectUrl>
26+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
2527
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2628
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2729
<IncludeSymbols>true</IncludeSymbols>

Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project>
33
<PropertyGroup>
44
<MicrosoftExtensionsVersion>6.0.*</MicrosoftExtensionsVersion>
55
<AspNetCoreVersion>6.0.*</AspNetCoreVersion>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$starWarsApiProjPath = "samples/star-wars-api/FSharp.Data.GraphQL.Samples.StarWarsApi.fsproj"
2+
[xml]$starWarsApiProj = Get-Content -Path $starWarsApiProjPath
3+
$starWarsApiProjRefNode = $starWarsApiProj.SelectSingleNode("//ItemGroup[@Label='ProjectReferences']")
4+
$starWarsApiProjRefNode.ParentNode.RemoveChild($starWarsApiProjRefNode) | Out-Null
5+
6+
$dirBuildTargetsPath = "Directory.Build.targets"
7+
[xml]$dirBuildTargets = Get-Content -Path $dirBuildTargetsPath
8+
$version = $dirBuildTargets.SelectSingleNode("//PropertyGroup[@Label='NuGet']/Version").InnerText
9+
10+
[xml]$fsharpPackages = @"
11+
<ItemGroup Label="PackageReferences">
12+
<PackageReference Include="FSharp.Data.GraphQL.Server.Middleware" Version="$($version)" />
13+
<PackageReference Include="FSharp.Data.GraphQL.Server" Version="$($version)" />
14+
<PackageReference Include="FSharp.Data.GraphQL.Shared" Version="$($version)" />
15+
</ItemGroup>
16+
"@
17+
18+
$packagesPropsPath = "Packages.props"
19+
[xml]$packagesProps = Get-Content -Path $packagesPropsPath
20+
$giraffeVersion = $packagesProps.SelectSingleNode("//PackageReference[@Update='Giraffe']/@Version")
21+
$starWarsApiProj.SelectSingleNode("//ItemGroup[@Label='PackageReferences']/PackageReference[@Include='Giraffe']").SetAttribute("Version",$giraffeVersion.Value)
22+
$packageReferences = $starWarsApiProj.SelectSingleNode("//ItemGroup[@Label='PackageReferences']")
23+
foreach($packageReference in $fsharpPackages.DocumentElement.ChildNodes){
24+
$innerNode = $starWarsApiProj.ImportNode($packageReference,$true)
25+
$packageReferences.AppendChild($innerNode)
26+
}
27+
$starWarsApiProj.Save($starWarsApiProjPath)

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ F# implementation of Facebook [GraphQL query language specification](https://fac
66

77
[![Join the chat at https://gitter.im/FSharp-Data-GraphQL/community](https://badges.gitter.im/FSharp-Data-GraphQL/community.svg)](https://gitter.im/FSharp-Data-GraphQL/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
88

9+
## Installing project templates
10+
11+
Type the following commands to install the template for creating web applications:
12+
13+
From GitHub:
14+
`dotnet new -i "FSharp.Data.GraphQL::2.0.0-ci-*" --nuget-source "https://nuget.pkg.github.com/fsprojects/index.json"`
15+
16+
From NuGet:
17+
`dotnet new -i "FSharp.Data.GraphQL::2.0.0"`
18+
919
## Quick start
1020

1121
```fsharp

build.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let startGraphQLServer (project : string) (streamRef : DataRef<Stream>) =
9090
</> DotNetMoniker
9191
</> (projectName + ".dll")
9292

93-
CreateProcess.fromRawCommandLine "dotnet" serverExe
93+
CreateProcess.fromRawCommandLine "dotnet" $"{serverExe} --urls=http://localhost:8086/"
9494
|> CreateProcess.withStandardInput (CreatePipe streamRef)
9595
|> Proc.start
9696
|> ignore

icon.png

3.27 KB
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<PackageType>Template</PackageType>
5+
<PackageId>FSharp.Data.GraphQL.ProjectTemplates</PackageId>
6+
<Title>FSharp.Data.GraphQL project templates</Title>
7+
<Description>Templates to use when creating a GraphQL API aplication in F#.</Description>
8+
<PackageTags>dotnet-new;templates;graphql;giraffe;api;fsharp;f#</PackageTags>
9+
<PackageReleaseNotes>https://github.com/fsprojects/FSharp.Data.GraphQL/releases</PackageReleaseNotes>
10+
11+
<TargetFramework>net6.0</TargetFramework>
12+
13+
<IncludeContentInPack>true</IncludeContentInPack>
14+
<IncludeBuildOutput>false</IncludeBuildOutput>
15+
<ContentTargetFolders>content</ContentTargetFolders>
16+
<NoWarn>$(NoWarn);NU5128</NoWarn>
17+
<NoDefaultExcludes>true</NoDefaultExcludes>
18+
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<Content Include="samples/star-wars-api/**/*" Exclude="samples/star-wars-api/**/bin/**;samples/star-wars-api/**/obj/**" />
22+
<Compile Remove="**/*" />
23+
</ItemGroup>
24+
25+
</Project>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"$schema": "http://json.schemastore.org/dotnetcli.host",
3+
"symbolInfo": {
4+
"Title": {
5+
"longName": "title"
6+
},
7+
"TitleXmlEncoded": {
8+
"isHidden": true
9+
},
10+
"Description": {
11+
"longName": "description"
12+
},
13+
"DescriptionXmlEncoded": {
14+
"isHidden": true
15+
},
16+
"Author": {
17+
"longName": "author"
18+
},
19+
"AuthorXmlEncoded": {
20+
"isHidden": true
21+
},
22+
"Contact": {
23+
"longName": "contact"
24+
},
25+
"ContactXmlEncoded": {
26+
"isHidden": true
27+
},
28+
"EditorConfig": {
29+
"longName": "editorconfig"
30+
},
31+
"SourceControl": {
32+
"longName": "source-control"
33+
},
34+
"GitHubUsername": {
35+
"longName": "github-username"
36+
},
37+
"GitHubProject": {
38+
"longName": "github-project"
39+
},
40+
"ReadMe": {
41+
"longName": "readme"
42+
},
43+
"TreatWarningsAsErrors": {
44+
"longName": "treat-warnings-as-errors"
45+
},
46+
"Mutations": {
47+
"longName": "mutations"
48+
},
49+
"Subscriptions": {
50+
"longName": "subscriptions"
51+
},
52+
"PersistedQueries": {
53+
"longName": "persisted-queries"
54+
},
55+
"ForwardedHeaders": {
56+
"longName": "forwarded-headers"
57+
},
58+
"HostFiltering": {
59+
"longName": "host-filtering"
60+
},
61+
"ReverseProxyWebServer": {
62+
"longName": "reverse-proxy"
63+
},
64+
"CloudProvider": {
65+
"longName": "cloud-provider"
66+
},
67+
"OpenTelemetry": {
68+
"longName": "open-telemetry"
69+
},
70+
"Logging": {
71+
"longName": "logging"
72+
},
73+
"ApplicationInsights": {
74+
"longName": "app-insights"
75+
},
76+
"ApplicationInsightsKey": {
77+
"longName": "app-insights-key"
78+
},
79+
"HttpsEverywhere": {
80+
"longName": "https-everywhere"
81+
},
82+
"HstsPreload": {
83+
"longName": "hsts-preload"
84+
},
85+
"Authorization": {
86+
"longName": "authorization"
87+
},
88+
"CORS": {
89+
"longName": "cors"
90+
},
91+
"ResponseCompression": {
92+
"longName": "response-compression"
93+
},
94+
"DistributedCache": {
95+
"longName": "distributed-cache"
96+
},
97+
"HealthCheck": {
98+
"longName": "health-check"
99+
},
100+
"RobotsTxt": {
101+
"longName": "robots-txt"
102+
},
103+
"SecurityTxt": {
104+
"longName": "security-txt"
105+
},
106+
"HumansTxt": {
107+
"longName": "humans-txt"
108+
},
109+
"HttpPort": {
110+
"longName": "http-port"
111+
},
112+
"HttpsPort": {
113+
"longName": "https-port"
114+
},
115+
"IISExpressHttpPort": {
116+
"longName": "iis-express-http-port"
117+
},
118+
"IISExpressHttpsPort": {
119+
"longName": "iis-express-https-port"
120+
},
121+
"IntegrationTest": {
122+
"longName": "integration-test"
123+
},
124+
"StyleCop": {
125+
"longName": "style-cop"
126+
},
127+
"GitHubActions": {
128+
"longName": "github-actions"
129+
},
130+
"SkipOpenToDo": {
131+
"longName": "no-open-todo"
132+
}
133+
}
134+
}
4.58 KB
Loading

0 commit comments

Comments
 (0)