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.
Create your GitHub repository and configure NuGet trusted publishing before the first release.
For each release, add CHANGELOG notes and run the Release build target.
nuget if it does not exist.MyCoolNewLib, or its actual name if you renamed it.publish.yml and the environment to nuget.NUGET_USER in the GitHub nuget environment.Do not use an email address or assume that the NuGet profile matches the GitHub owner.
NuGet/login@v1 supplies the API key through the existing NUGET_TOKEN build input.
The workflow has no stored-key fallback.
After an authorized tag-triggered release, verify the NuGet package version and GitHub release artifacts.
Check the complete run logs for credentials and credential fragments.
Check that NuGet reports the policy as active and permanent.
Only after all verification succeeds, remove the stored GitHub NUGET_TOKEN secret and revoke the old scoped NuGet key.
Keep both credentials until these checks pass.
Use the release guide for detailed setup, failure checks, and manual emergency recovery.
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!