The workflows have the goal of automating as much as possible, while keeping workflows flexible to handle odd cases when needed.
Here is a diagram that shows the path from developing a feature/fix to releasing it on NuGet org.
NOTE: whenever I write mainline below, I am referring to whatever is the default branch in a GitHub repository, e.g. main
.
The goals are:
- Follow GitHub flow, e.g. PRs into mainline branch.
- Mainline has latest preview/nightly code in unreleased form, and new preview releases is automatically pushed to GitHub Package Repository when source code changes in mainline.
stable
branch contains latest released code to NuGet.org.- Use "Keep a change log, where mainline has new items in "Unreleased" section, that are automatically moved to a "released versioned" section when released.
- Use "Nerdbank.GitVersioning" to correctly stamp versions, repository references, and commit references in .NET assemblies of both releases and prereleases.
- Automatically create GitHub releases and add tags on new release.
- Allow for live documentation to be updated independently of releases from stable.
- Allow for changes to docs to be updated with a release.
- Release workflows should be idempotent, be re-runable in case of errors.
The workflow examples are located in the usual place in this repository under .github/workflows
, and are built with the settings defined in the version.json
in mind.
The following sections will list what should happen in the different scenarios involved.
- Locally, make changes from mainline branch. remember to update CHANGELOG.md.
- Push to mainline or create a PR targeting mainline, if not authorized to push directly.
- Automatically trigger
verification
workflow. - Automatically trigger
release-preview
workflow ifverification
workflow successed.
- Automatically trigger
verification
workflow.
Manually trigger prepare-release
workflow, specifying if it is a minor
or major
release. This does the following:
- Check that release contains changes, if not, abort. This is verified by looking at the "Unreleased" section in the CHANGELOG.md.
- Increment version.json on mainline, e.g. 1.1-preview to 1.2-preview. Push mainline branch to origin.
- Create release branch and set version.json in that to non preview, e.g. 1.1. Push release branch to origin.
- Create pull request for release branch towards
stable
.
Creating the PR ensures verification
workflow runs, and gives the option to make small adjustments before release if needed.
TODO:
- Make it possible to specify that the release PR should be accepted automatically for immidiate release.
- Use some tooling like https://github.com/fsprojects/SyntacticVersioning/ or changelog analyser to automatically determine if the release is a minor or major release.
Automatically trigger release
workflow on release PR merged with stable, or if it is triggered manaully. This does the following:
- Check that release contains changes, if not, abort. This is verified by looking at the "Unreleased" section in the CHANGELOG.md.
- Update changelog: move content from "unreleased" section to an "[x.y.c] yyyy-mm-dd" section
- Commit CHANGELOG.md to
stable
branch - Building library in release mode
- Upload library to NuGet.org repository
- Push
stable
branch to origin - Create GitHub release from commit with CHANGELOG.md changes on stable. The release is created with the title and content from the CHANGELOG related to the release.
- Merge
stable
with mainline and push to origin - If merge between
stable
and mainline fails, then create a PR fromstable
to mainline instead.
The order of these steps are important as they make sure that GitVersioning correctly stamps the generated assemblies/nuget packages with the right version and github commit hash from when the changelog was updated.
If a library has a documentation site, the version of the docs should match the latest released version of the library. This, the source for the docs located on the stable
branch is where the live documentation website is built from.
Since it is not uncommon that fixes and changes to the docs need to happen between releases, changes to the docs sources are the only changes allowed to be pushed to stable
outside of normal release pull requests. When this happens, the following should happen:
- Automatically trigger
docs-deploy
workflow, that builds and uploads docs to whatever hosting solution it uses, e.g. GH Pages. - Merge
stable
with mainline branch, such that updated docs are visible in the mainline branch. - If merge between
stable
and mainline fails, then create a PR fromstable
to mainline instead.