In this tutorial, we'll take a look at getting started with MiniScaffold and publishing your first library to NuGet and GitHub.
Install the dotnet template from NuGet:
|
Then use the template to create your own library. Replace MyCoolNewLib
with your own library name and MyGithubUsername
with your own GitHub name. If you have trouble picking a library name then generate one.
|
This will generate a structure similar to this
|
This may look overwhelming, but we don't have to worry about all of these yet. Let's just focus on the real important ones for this tutorial.
./src/MyCoolNewLib
- This is where your library's source code will live../tests/MyCoolNewLib.Tests
- This is where your library's test code will live..\build.cmd
or ./build.sh
- Platform specific entry points into your build
project../build/
- The main build script of your repository../README.md
- The text file that introduces and explains a project../CHANGELOG.md
- Text file containing versioning, date, and release notes.To make sure everything is functioning correctly, run the build command for your platform:
|
You'll be flooded with a screen full of text, documenting the build processes at it currently stands. If it completes successfully you should be greeted with something similar:
|
This is FAKE telling us everything that ran, how long, and if it completed successfully.
If it does not complete successfully, either open an issue or ask on F# Slack.
The README.md comes with a lot of information but it's recommended to fill out the introduction description.
The release process is streamlined so you only have to start your git repository, set your NuGet keys for GitHub Actions, create CHANGELOG
notes, and run the Release
build target. After you've done the initial setup, you will only need to perform the last two steps for each release.
nuget
.NUGET_TOKEN
to the Environment Secrets of your newly created environment.Then update the CHANGELOG.md
with an "Unreleased" section containing release notes for this version, in KeepAChangelog format.
NOTE: Its highly recommend to add a link to the Pull Request next to the release note that it affects. The reason for this is when the RELEASE
target is run, it will add these new notes into the body of git commit. GitHub will notice the links and will update the Pull Request with what commit referenced it saying "added a commit that referenced this pull request". Since we automate the commit message, it will say "Bump Version to x.y.z". The benefit of this is when users goto a Pull Request, it will be clear when and which version those code changes released. Also when reading the CHANGELOG
, if someone is curious about how or why those changes were made, they can easily discover the work and discussions.
Additionally adding the GitHub handle of the user that contributed the pull request will allow GitHub to notify them of the release and have them show up as contributors for that release.
Here's an example of adding an Unreleased
section to a CHANGELOG.md
with a 0.1.0
section already released.
|
Release
target, specifying the version number either in the RELEASE_VERSION
environment
variable, or else as a parameter after the target name.
./build.sh Release 0.2.0
CHANGELOG.md
, moving changes from the Unreleased
section into a new 0.2.0
section
Bump version to 0.2.0
and adds the new changelog section to the commit's bodymacOS/Linux Parameter:
|
macOS/Linux Environment Variable:
|
You have now successfully created your first OSS library that has been published to NuGet and GitHub. Congratulations!