Skip to content

Commit 83521d9

Browse files
Juriyxxperiandri
andauthored
Added NuGet dependencies between packages (#403)
* Added variable to switch to `PackageReference` when packaging * Updated pipelines to build depending on NuGet packages * Changed branch for CI to package_dependencies * Removed unnecessary branch from PR CI workflow * Renamed workflow to pull_request * Separated each workflow step Co-authored-by: XperiAndri <xperiandri@live.ru>
1 parent 946b9f9 commit 83521d9

File tree

7 files changed

+70
-54
lines changed

7 files changed

+70
-54
lines changed

.github/workflows/publish_ci.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,43 @@ on:
88
jobs:
99
build:
1010

11+
env:
12+
GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}'
13+
1114
runs-on: ubuntu-latest
1215

1316
steps:
1417
- uses: actions/checkout@v2
18+
1519
- name: Setup .NET Core
1620
uses: actions/setup-dotnet@v1
17-
- name: Pack FSharp.Data.GraphQL.Client project
21+
22+
- name: Add GitHub Packges NuGet source
23+
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"
24+
25+
- name: Set version
26+
run: sed -i "s|<Version>\(.*\)</Version>|<Version>\1-ci-$GITHUB_RUN_ID</Version>|" Directory.Build.targets
27+
28+
- name: Pack FSharp.Data.GraphQL.Shared project and push to GitHub Packages
29+
run: |
30+
cd src/FSharp.Data.GraphQL.Shared
31+
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
32+
dotnet nuget push ../../nuget/*Shared*.nupkg -s "github" -k $GITHUB_TOKEN
33+
34+
- name: Pack FSharp.Data.GraphQL.Client project and push to GitHub Packages
1835
run: |
19-
sed -i "s|<Version>\(.*\)</Version>|<Version>\1-ci-$GITHUB_RUN_ID</Version>|" Directory.Build.targets
2036
cd src/FSharp.Data.GraphQL.Client
21-
dotnet pack --nologo --configuration Release -o ../../nuget
22-
- name: Pack FSharp.Data.GraphQL.Server project
37+
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
38+
dotnet nuget push ../../nuget/*Client*.nupkg -s "github" -k $GITHUB_TOKEN
39+
40+
- name: Pack FSharp.Data.GraphQL.Server project and push to GitHub Packages
2341
run: |
2442
cd src/FSharp.Data.GraphQL.Server
25-
dotnet pack --nologo --configuration Release -o ../../nuget
26-
- name: Pack FSharp.Data.GraphQL.Server.Middleware project
43+
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
44+
dotnet nuget push ../../nuget/*Server*.nupkg -s "github" -k $GITHUB_TOKEN
45+
46+
- name: Pack FSharp.Data.GraphQL.Server.Middleware project and push to GitHub Packages
2747
run: |
2848
cd src/FSharp.Data.GraphQL.Server.Middleware
29-
dotnet pack --nologo --configuration Release -o ../../nuget
30-
- name: NuGet push
31-
run: |
32-
source=https://nuget.pkg.github.com/fsprojects/index.json
33-
key=${{secrets.GITHUB_TOKEN}}
34-
dotnet nuget push nuget/*.nupkg -s $source -k $key
49+
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
50+
dotnet nuget push ../../nuget/*Server.Middleware*.nupkg -s "github" -k $GITHUB_TOKEN

.github/workflows/publish_release.yml

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,40 @@ on:
88
jobs:
99
publish:
1010

11+
env:
12+
KEY: '${{secrets.NUGET_SECRET}}'
13+
1114
runs-on: ubuntu-latest
1215

1316
steps:
14-
- uses: actions/checkout@v2
15-
16-
# Required for a specific dotnet version that doesn't come with ubuntu-latest / windows-latest
17-
# Visit bit.ly/2synnZl to see the list of SDKs that are pre-installed with ubuntu-latest / windows-latest
18-
# - name: Setup dotnet
19-
# uses: actions/setup-dotnet@v1
20-
# with:
21-
# dotnet-version: 3.1.100
22-
23-
# Publish
24-
- name: publish FSharp.Data.GraphQL.Client on version change
25-
uses: rohith/publish-nuget@v2
26-
with:
27-
PROJECT_FILE_PATH: src/FSharp.Data.GraphQL.Client/FSharp.Data.GraphQL.Client.fsproj # Relative to repository root
28-
VERSION_FILE_PATH: Directory.Build.targets
29-
VERSION_REGEX: <Version>(.*)<\/Version>
30-
# VERSION_FILE_PATH: Directory.Build.props # Filepath with version info, relative to repository root. Defaults to project file
31-
# VERSION_REGEX: <Version>(.*)<\/Version> # Regex pattern to extract version info in a capturing group
32-
# TAG_COMMIT: true # Flag to enable / disalge git tagging
33-
# TAG_FORMAT: v* # Format of the git tag, [*] gets replaced with version
34-
NUGET_KEY: ${{secrets.NUGET_SECRET}}
35-
- name: publish FSharp.Data.GraphQL.Server on version change
36-
uses: rohith/publish-nuget@v2
37-
with:
38-
PROJECT_FILE_PATH: src/FSharp.Data.GraphQL.Server/FSharp.Data.GraphQL.Server.fsproj
39-
VERSION_FILE_PATH: Directory.Build.targets
40-
VERSION_REGEX: <Version>(.*)<\/Version>
41-
NUGET_KEY: ${{secrets.NUGET_SECRET}}
42-
- name: publish FSharp.Data.GraphQL.Server.Middleware on version change
43-
uses: rohith/publish-nuget@v2
44-
with:
45-
PROJECT_FILE_PATH: src/FSharp.Data.GraphQL.Server.Middleware/FSharp.Data.GraphQL.Server.Middleware.fsproj
46-
VERSION_FILE_PATH: Directory.Build.targets
47-
VERSION_REGEX: <Version>(.*)<\/Version>
48-
NUGET_KEY: ${{secrets.NUGET_SECRET}}
17+
- uses: actions/checkout@v2
18+
- name: Setup .NET Core
19+
uses: actions/setup-dotnet@v1
20+
21+
- name: Pack FSharp.Data.GraphQL.Shared project and push to NuGet
22+
if: startsWith(github.ref, 'refs/tags/release')
23+
run: |
24+
cd src/FSharp.Data.GraphQL.Shared
25+
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
26+
dotnet nuget push ../../nuget/*Shared*.nupkg -k $KEY
27+
28+
- name: Pack FSharp.Data.GraphQL.Client project and push to NuGet
29+
if: startsWith(github.ref, 'refs/tags/release')
30+
run: |
31+
cd src/FSharp.Data.GraphQL.Client
32+
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
33+
dotnet nuget push ../../nuget/*Client*.nupkg -k $KEY
34+
35+
- name: Pack FSharp.Data.GraphQL.Server project and push to NuGet
36+
if: startsWith(github.ref, 'refs/tags/release')
37+
run: |
38+
cd src/FSharp.Data.GraphQL.Server
39+
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
40+
dotnet nuget push ../../nuget/*Server*.nupkg -k $KEY
41+
42+
- name: Pack FSharp.Data.GraphQL.Server.Middleware project and push to NuGet
43+
if: startsWith(github.ref, 'refs/tags/release')
44+
run: |
45+
cd src/FSharp.Data.GraphQL.Server.Middleware
46+
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
47+
dotnet nuget push ../../nuget/*Server.Middleware*.nupkg -k $KEY

.github/workflows/dotnetcore.yml renamed to .github/workflows/pull_request.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ on:
55
push:
66
branches:
77
- master
8-
- remove-desktop-build
98
- dev
109
pull_request:
1110
branches:
12-
- remove-desktop-build
1311
- master
1412
- dev
1513

@@ -32,4 +30,4 @@ jobs:
3230
- name: Install local tools
3331
run: dotnet tool restore
3432
- name: Build and Test
35-
run: dotnet fsi build.fsx
33+
run: dotnet fsi build.fsx

FSharp.Data.GraphQL.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
147147
EndProject
148148
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub", "GitHub", "{313AC7F5-4282-4779-8FEF-1536B4145860}"
149149
ProjectSection(SolutionItems) = preProject
150-
.github\workflows\dotnetcore.yml = .github\workflows\dotnetcore.yml
151150
.github\workflows\publish_ci.yml = .github\workflows\publish_ci.yml
152151
.github\workflows\publish_release.yml = .github\workflows\publish_release.yml
152+
.github\workflows\pull_request.yml = .github\workflows\pull_request.yml
153153
EndProjectSection
154154
EndProject
155155
Global

src/FSharp.Data.GraphQL.Client/FSharp.Data.GraphQL.Client.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
</ItemGroup>
3939

4040
<ItemGroup>
41-
<ProjectReference Include="..\FSharp.Data.GraphQL.Shared\FSharp.Data.GraphQL.Shared.fsproj" />
41+
<PackageReference Condition="$(IsNuget) != ''" Include="FSharp.Data.GraphQL.Shared" VersionOverride="$(Version)" />
42+
<ProjectReference Condition="$(IsNuget) == ''" Include="..\FSharp.Data.GraphQL.Shared\FSharp.Data.GraphQL.Shared.fsproj" />
4243
</ItemGroup>
4344
</Project>

src/FSharp.Data.GraphQL.Server.Middleware/FSharp.Data.GraphQL.Server.Middleware.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<ProjectReference Include="..\FSharp.Data.GraphQL.Server\FSharp.Data.GraphQL.Server.fsproj" />
29+
<PackageReference Condition="$(IsNuget) != ''" Include="FSharp.Data.GraphQL.Server" VersionOverride="$(Version)" />
30+
<ProjectReference Condition="$(IsNuget) == ''" Include="..\FSharp.Data.GraphQL.Server\FSharp.Data.GraphQL.Server.fsproj" />
3031
</ItemGroup>
3132
</Project>

src/FSharp.Data.GraphQL.Server/FSharp.Data.GraphQL.Server.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
</ItemGroup>
4545

4646
<ItemGroup>
47-
<ProjectReference Include="../FSharp.Data.GraphQL.Shared/FSharp.Data.GraphQL.Shared.fsproj" />
47+
<PackageReference Condition="$(IsNuget) != ''" Include="FSharp.Data.GraphQL.Shared" VersionOverride="$(Version)" />
48+
<ProjectReference Condition="$(IsNuget) == ''" Include="..\FSharp.Data.GraphQL.Shared\FSharp.Data.GraphQL.Shared.fsproj" />
4849
</ItemGroup>
4950
</Project>

0 commit comments

Comments
 (0)