Skip to content

Commit e516479

Browse files
Juriyxxperiandri
Juriyx
andauthored
Added NuGet dependencies between packages (#413)
* Added variable to switch to `PackageReference` when packaging * Updated pipelines to build depend on NuGet packages * Changed branch for CI to package_dependencies * Updated pipelines to build depend on NuGet packages * Removed environment variables, updated checkout task and added Dunamai versioning * Moved build and test to solution level, edited triggers and further steps Co-authored-by: XperiAndri <[email protected]>
1 parent 1bdab9f commit e516479

File tree

4 files changed

+100
-53
lines changed

4 files changed

+100
-53
lines changed

.github/workflows/publish_ci.yml

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,63 @@ on:
77

88
jobs:
99
build:
10-
11-
env:
12-
GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}'
13-
1410
runs-on: ubuntu-latest
1511

1612
steps:
17-
- uses: actions/checkout@v2
18-
19-
- name: Setup .NET Core
20-
uses: actions/setup-dotnet@v1
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- name: Set Build Version
16+
run: |
17+
$File = (
18+
Select-Xml -XPath "/Project/PropertyGroup[@Label='NuGet']/Version" -Path "Directory.Build.targets"
19+
)[0].Node
20+
$Version = $File.InnerText
21+
$File.InnerText = "$Version-ci-$env:GITHUB_RUN_ID"
22+
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath Directory.Build.targets))
23+
shell: pwsh
24+
- name: Install .NET Core
25+
uses: actions/setup-dotnet@v3
26+
- name: Add the GitHub source
27+
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"
2128

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"
29+
- name: Install local tools
30+
run: dotnet tool restore
2431

25-
- name: Set version
26-
run: sed -i "s|<Version>\(.*\)</Version>|<Version>\1-ci-$GITHUB_RUN_ID</Version>|" Directory.Build.targets
32+
- name: Run integration tests
33+
run: dotnet fsi build.fsx
2734

28-
- name: Pack FSharp.Data.GraphQL.Shared project and push to GitHub Packages
35+
- name: Pack FSharp.Data.GraphQL.Shared project
2936
run: |
3037
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
38+
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
39+
- name: Publish FSharp.Data.GraphQL.Shared project to GitHub
40+
run: |
41+
cd src/FSharp.Data.GraphQL.Shared
42+
dotnet nuget push ../../nuget/*Shared*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
3343
34-
- name: Pack FSharp.Data.GraphQL.Client project and push to GitHub Packages
44+
- name: Pack FSharp.Data.GraphQL.Client project
3545
run: |
3646
cd src/FSharp.Data.GraphQL.Client
37-
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
38-
dotnet nuget push ../../nuget/*Client*.nupkg -s "github" -k $GITHUB_TOKEN
47+
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
48+
- name: Publish FSharp.Data.GraphQL.Client project to GitHub
49+
run: |
50+
cd src/FSharp.Data.GraphQL.Client
51+
dotnet nuget push ../../nuget/*Client*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
3952
40-
- name: Pack FSharp.Data.GraphQL.Server project and push to GitHub Packages
53+
- name: Pack FSharp.Data.GraphQL.Server project
4154
run: |
4255
cd src/FSharp.Data.GraphQL.Server
43-
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
44-
dotnet nuget push ../../nuget/*Server*.nupkg -s "github" -k $GITHUB_TOKEN
56+
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
57+
- name: Publish FSharp.Data.GraphQL.Server project to GitHub
58+
run: |
59+
cd src/FSharp.Data.GraphQL.Server
60+
dotnet nuget push ../../nuget/*Server*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
4561
46-
- name: Pack FSharp.Data.GraphQL.Server.Middleware project and push to GitHub Packages
62+
- name: Pack FSharp.Data.GraphQL.Server.Middleware project
4763
run: |
4864
cd src/FSharp.Data.GraphQL.Server.Middleware
4965
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
50-
dotnet nuget push ../../nuget/*Server.Middleware*.nupkg -s "github" -k $GITHUB_TOKEN
66+
- name: Publish FSharp.Data.GraphQL.Server.Middleware project to GitHub
67+
run: |
68+
cd src/FSharp.Data.GraphQL.Server.Middleware
69+
dotnet nuget push ../../nuget/*Server.Middleware*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}

.github/workflows/publish_release.yml

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,72 @@ name: publish to NuGet
22

33
on:
44
push:
5-
branches:
6-
- master
5+
tags:
6+
- 'releases/*'
77

88
jobs:
99
publish:
10-
11-
env:
12-
KEY: '${{secrets.NUGET_SECRET}}'
13-
1410
runs-on: ubuntu-latest
1511

1612
steps:
17-
- uses: actions/checkout@v2
18-
- name: Setup .NET Core
19-
uses: actions/setup-dotnet@v1
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
# This is necessary so that we have the tags.
17+
fetch-depth: 0
18+
- name: Set Build Version
19+
run: |
20+
$Version = "$env:GITHUB_REF_NAME"
21+
22+
$File = (
23+
Select-Xml -XPath "/Project/PropertyGroup[@Label='NuGet']/Version" -Path "Directory.Build.targets"
24+
)[0].Node
25+
26+
$File.InnerText = $Version
27+
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath Directory.Build.targets))
28+
shell: pwsh
2029

21-
- name: Pack FSharp.Data.GraphQL.Shared project and push to NuGet
22-
if: startsWith(github.ref, 'refs/tags/release')
30+
- name: Install .NET Core
31+
uses: actions/setup-dotnet@v3
32+
33+
- name: Install local tools
34+
run: dotnet tool restore
35+
36+
- name: Run integration tests
37+
run: dotnet fsi build.fsx
38+
39+
- name: Pack FSharp.Data.GraphQL.Shared project
2340
run: |
2441
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
42+
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
43+
- name: Publish FSharp.Data.GraphQL.Shared project to NuGet
44+
run: |
45+
cd src/FSharp.Data.GraphQL.Shared
46+
dotnet nuget push ../../nuget/*Shared*.nupkg -k ${{secrets.NUGET_SECRET}}
2747
28-
- name: Pack FSharp.Data.GraphQL.Client project and push to NuGet
29-
if: startsWith(github.ref, 'refs/tags/release')
48+
- name: Pack FSharp.Data.GraphQL.Client project
3049
run: |
3150
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
51+
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
52+
- name: Publish FSharp.Data.GraphQL.Client project to NuGet
53+
run: |
54+
cd src/FSharp.Data.GraphQL.Client
55+
dotnet nuget push ../../nuget/*Client*.nupkg -k ${{secrets.NUGET_SECRET}}
3456
35-
- name: Pack FSharp.Data.GraphQL.Server project and push to NuGet
36-
if: startsWith(github.ref, 'refs/tags/release')
57+
- name: Pack FSharp.Data.GraphQL.Server project
3758
run: |
3859
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
60+
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
61+
- name: Publish FSharp.Data.GraphQL.Server project to NuGet
62+
run: |
63+
cd src/FSharp.Data.GraphQL.Server
64+
dotnet nuget push ../../nuget/*Server*.nupkg -k ${{secrets.NUGET_SECRET}}
4165
42-
- name: Pack FSharp.Data.GraphQL.Server.Middleware project and push to NuGet
43-
if: startsWith(github.ref, 'refs/tags/release')
66+
- name: Pack FSharp.Data.GraphQL.Server.Middleware project
4467
run: |
4568
cd src/FSharp.Data.GraphQL.Server.Middleware
4669
dotnet pack --nologo --configuration Release /p:IsNuget=true -o ../../nuget
47-
dotnet nuget push ../../nuget/*Server.Middleware*.nupkg -k $KEY
70+
- name: Publish FSharp.Data.GraphQL.Server.Middleware project to NuGet
71+
run: |
72+
cd src/FSharp.Data.GraphQL.Server.Middleware
73+
dotnet nuget push ../../nuget/*Server.Middleware*.nupkg -k ${{secrets.NUGET_SECRET}}

.github/workflows/pull_request.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Build and Test
32

43
on:
@@ -22,12 +21,15 @@ jobs:
2221
runs-on: ${{ matrix.os }}
2322

2423
steps:
25-
- uses: actions/checkout@v1
24+
- uses: actions/checkout@v3
25+
2626
- name: Setup .NET Core
27-
uses: actions/setup-dotnet@v1
27+
uses: actions/setup-dotnet@v3
2828
with:
2929
dotnet-version: ${{ matrix.dotnet }}
30+
3031
- name: Install local tools
3132
run: dotnet tool restore
32-
- name: Build and Test
33+
34+
- name: Build and run integration tests
3335
run: dotnet fsi build.fsx

Directory.Build.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
</PropertyGroup>
3333

3434
<ItemGroup>
35-
<None Include="$(RepoRoot)\icon.png" Pack="true" PackagePath="\"/>
36-
<None Include="$(RepoRoot)\README.md" Pack="true" PackagePath="\"/>
35+
<None Include="$(RepoRoot)\icon.png" Pack="true" PackagePath="\" />
36+
<None Include="$(RepoRoot)\README.md" Pack="true" PackagePath="\" />
3737
</ItemGroup>
3838

3939
</Project>

0 commit comments

Comments
 (0)