This repository consists of a .NET solution containing multiple class libraries, with each library published as a standalone NuGet package. The libraries follow the naming convention: DfE.CoreLibs.{library_name}
.
To add a new library to this repository and automatically publish it as a NuGet package, follow these steps:
- Create a new library in the
src
folder in the root of the solution. - Copy the two YAML workflow files used for other libraries (e.g., from
Caching
) into your new library directory, and modify them as needed to match your new library.
For example, if your new library is called "FileService," name the file build-test-FileService.yml
.
name: Build DfE.CoreLibs.FileService
on:
push:
branches:
- main
paths:
- 'src/DfE.CoreLibs.FileService/**'
pull_request:
branches:
- main
paths:
- 'src/DfE.CoreLibs.FileService/**'
jobs:
build-and-test:
uses: ./.github/workflows/build-test-template.yml
with:
project_name: DfE.CoreLibs.FileService
project_path: src/DfE.CoreLibs.FileService
run_tests: false
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Make sure to:
- Replace
DfE.CoreLibs.FileService
with your new library name. - Ensure the path to the new library is correct.
For example, name the file pack-FileService.yml
for your new library.
name: Pack DfE.CoreLibs.FileService
on:
workflow_run:
workflows: ["Build DfE.CoreLibs.FileService"]
types:
- completed
jobs:
build-and-package:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.event != 'pull_request' }}
uses: ./.github/workflows/nuget-package-template.yml
with:
project_name: DfE.CoreLibs.FileService
project_path: src/DfE.CoreLibs.FileService
nuget_package_name: DfE.CoreLibs.FileService
- Build and Test Workflow (
build-test-{library_name}.yml
): This workflow is responsible for building and testing your library. - Pack Workflow (
pack-{library_name}.yml
): This workflow handles versioning and packaging of your library, but it only runs after the build and test workflow successfully completes.
- Initial Versioning: The first time your library is published, the version will start at
1.0.0
. - Automatic Increment: With subsequent changes, the patch version will increment automatically (e.g.,
1.0.1
,1.0.2
, and so on). - Custom Version Bumps: To bump the minor or major version of your library, follow these steps:
-
Make the necessary changes in your library.
-
Commit your changes with a message like the following:
(%update {Project_Name} package version to {version_number})
Example:
(%update DfE.CoreLibs.FileService package version to 1.1.0)
-
The packaging workflow will then automatically set the version to 1.1.0
and increment the patch part (1.1.x
) with each further change.
Each time a package is published succesfully, a new tag and release is created in the repository.
-
Custom Release Note: To add a Release Note to the release, simply include the following to your commit messages:
(%release-note: {note} %) Example: (%release-note: Example Message to be Added in the Release Note %)