Skip to content

Commit c39621f

Browse files
authored
use infrastructure nuget package published to DfE Digital on github (#36)
* use nuget package published to DfE Digital on github * add package source to yml * Readme - info on consuming github packages nuget feed
1 parent 39895e4 commit c39621f

File tree

6 files changed

+34
-13
lines changed

6 files changed

+34
-13
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
uses: actions/setup-dotnet@v4
2121
with:
2222
dotnet-version: 8.0.x
23+
- name: Add nuget package source
24+
run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/DFE-Digital/index.json"
2325
- name: Restore dependencies
2426
run: dotnet restore
2527
- name: Build

Dfe.Data.SearchPrototype.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dfe.Data.SearchPrototype",
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dfe.Data.SearchPrototype.Tests", "Dfe.Data.SearchPrototype\Tests\Dfe.Data.SearchPrototype.Tests.csproj", "{011C329A-A195-439A-ACED-F20AFF560FE7}"
99
EndProject
10-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{0D4ACC06-9FA9-422A-8F92-92B565879E16}"
11-
ProjectSection(SolutionItems) = preProject
12-
NuGet\Dfe.Data.Common.Infrastructure.CognitiveSearch.1.0.0.nupkg = NuGet\Dfe.Data.Common.Infrastructure.CognitiveSearch.1.0.0.nupkg
13-
EndProjectSection
14-
EndProject
1510
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dfe.Data.SearchPrototype.Infrastructure", "Dfe.Data.SearchPrototype\Infrastructure\Dfe.Data.SearchPrototype.Infrastructure.csproj", "{95EDB119-5238-451B-944A-84A1F8891171}"
1611
EndProject
1712
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dfe.Data.SearchPrototype.Infrastructure.Tests", "Dfe.Data.SearchPrototype\Infrastructure\Tests\Dfe.Data.SearchPrototype.Infrastructure.Tests.csproj", "{62F6B827-75B0-43A6-9323-297F32016D71}"
1813
EndProject
1914
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dfe.Data.SearchPrototype.Common", "Dfe.Data.SearchPrototype\Common\Dfe.Data.SearchPrototype.Common.csproj", "{641005EB-1F41-466C-80C2-FA6F59572474}"
2015
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E7775773-B4F2-4B47-88CC-9F5C71EB54CC}"
17+
ProjectSection(SolutionItems) = preProject
18+
README.md = README.md
19+
EndProjectSection
20+
EndProject
2121
Global
2222
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2323
Debug|Any CPU = Debug|Any CPU

Dfe.Data.SearchPrototype/Infrastructure/Dfe.Data.SearchPrototype.Infrastructure.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21+
<PackageReference Include="Dfe.Data.Common.Infrastructure.CognitiveSearch" Version="0.0.1-42" />
2122
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
2223
<PackageReference Include="Azure.Search.Documents" Version="11.4.0" />
2324
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
24-
<PackageReference Include="Dfe.Data.Common.Infrastructure.CognitiveSearch" Version="1.0.0" />
2525
</ItemGroup>
2626

2727
</Project>
Binary file not shown.

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
1-
# data.search-prototype
1+
# data.search-prototype
2+
## Using The Nuget Packages From Your Development Machine
3+
Some Nuget packages referenced by this repository are served under the DfE-Digital organisation.
4+
The be able to use these Nuget Packages (and others) you must configure your development machine to have a new NuGet Package Source.
5+
To do this, you must first create a PAT token that has at least __read access for packages__.
6+
7+
> **NEVER commit your PAT token to GitHub or any other VCS !**
8+
9+
Next add a package source to your NuGet configuration using the CLI.
10+
Use the following command, replacing `[USERNAME] with your GitHub username, and `[PAT-TOKEN] with the PAT token you just generated.
11+
12+
`dotnet nuget add source --username "[USERNAME]" --password "[PAT-TOKEN]" --store-password-in-clear-text --name DfE "https://nuget.pkg.github.com/DFE-Digital/index.json"`
13+
14+
> Alternatively you may add a package source directly in Visual Studio.Once you have generated a PAT token you can add a new NuGet Package Source to visual studio. You may be prompted to sign in, if you are then enter your GitHub username and instead of the password enter the PAT token you generated.
15+
16+
---
17+
18+
## Referencing the Nuget Registry From a GitHub Action That Directly Builds DotNet Projects
19+
This applies when building dotnet solutions that reference the nuget registry directly within a GitHub action.
20+
21+
You can use the Nuget Registry from a GitHub action pipeline without need for a PAT token. GitHub creates a special token for use during the lifetime of the GitHub action. For your apps to be able to restore from the DfE nuget repository, add the followint two lines to your yml file __before__ restoring packages
22+
23+
```sh
24+
- name: Add nuget package source
25+
run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/DFE-Digital/index.json"
26+
```

nuget.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)