Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
node-version: 26
cache: npm
cache-dependency-path: |
${{ env.CLIENT_DIR }}/package-lock.json
Expand Down Expand Up @@ -242,7 +242,7 @@ jobs:
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
if: vars.NPM_PUBLISH == 'true'
with:
node-version: 22
node-version: 26

# A pre-release gets the "next" tag. A release of the newest stable major gets "latest", so a plain install takes
# it; an older major's release gets "umbraco-NN", so it never takes "latest" from a newer major. A version already
Expand All @@ -253,7 +253,6 @@ jobs:
TAG: ${{ github.ref_name }}
REPOSITORY: ${{ github.repository }}
run: |
npm install --global npm@11 # trusted publishing needs npm 11.5.1 or later
package="@umbricians/feature-flags"
version="${TAG#v}"
major="${version%%.*}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/umbraco-minors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
node-version: 26

- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ node build/smoke-test.mjs demo/Umbricians.FeatureFlags.Demo /App_Plugins/Umbrici
dotnet pack src/Umbricians.FeatureFlags -c Release -o artifacts
```

Packing also checks the public API against the major's last release on nuget.org (package validation, with the baseline in
`Directory.Build.props`), so it needs network access and fails on a breaking change.

Each Umbraco major is its own package, built from the same source. Build and test one major at a time with
`-p:UmbracoMajor=18` or `-p:UmbracoMajor=19` on the `dotnet` commands. Each major has its own folders under `bin` and
`obj`, such as `bin/umbraco18/`. Umbraco 17 and 18 run on .NET 10; 19 needs the .NET 11 SDK. For 18, the smoke test's
Expand Down
10 changes: 10 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,33 @@
<UmbracoMajor Condition="'$(UmbracoMajor)' == ''">17</UmbracoMajor>
</PropertyGroup>

<!-- Package validation packs against the last release of the same major, and fails the pack on a breaking API change: the API
of a major must not break, so breaking changes wait for a new Umbraco major. After each release, move that major's
PackageValidationBaselineVersion to the new version (see docs/RELEASING.md). -->
<PropertyGroup>
<EnablePackageValidation>true</EnablePackageValidation>
</PropertyGroup>

<!-- The lowest version of each major, which sites on newer versions resolve past. The "Umbraco minors" workflow passes
a newer one with -p:UmbracoVersion=, and .github/dependabot.yml ignores these packages, so they change here only. -->
<PropertyGroup Condition="'$(UmbracoMajor)' == '17'">
<UmbracoVersion Condition="'$(UmbracoVersion)' == ''">17.8.2</UmbracoVersion>
<UmbracoTargetFramework>net10.0</UmbracoTargetFramework>
<!-- Microsoft's ASP.NET Core packages the tests use, of the same .NET version. -->
<AspNetCoreVersion>10.0.15</AspNetCoreVersion>
<PackageValidationBaselineVersion>17.0.0</PackageValidationBaselineVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(UmbracoMajor)' == '18'">
<UmbracoVersion Condition="'$(UmbracoVersion)' == ''">18.3.2</UmbracoVersion>
<UmbracoTargetFramework>net10.0</UmbracoTargetFramework>
<AspNetCoreVersion>10.0.15</AspNetCoreVersion>
<PackageValidationBaselineVersion>18.0.0</PackageValidationBaselineVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(UmbracoMajor)' == '19'">
<UmbracoVersion Condition="'$(UmbracoVersion)' == ''">19.0.0-rc1</UmbracoVersion>
<UmbracoTargetFramework>net11.0</UmbracoTargetFramework>
<AspNetCoreVersion>11.0.0</AspNetCoreVersion>
<PackageValidationBaselineVersion>19.0.0-rc.1</PackageValidationBaselineVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@
[![NuGet](https://img.shields.io/nuget/v/Umbricians.FeatureFlags?label=NuGet)](https://www.nuget.org/packages/Umbricians.FeatureFlags)
[![Build](https://github.com/Umbricians/Feature-Flags/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/Umbricians/Feature-Flags/actions/workflows/build.yml)

Switch the site's feature flags on and off from the Umbraco backoffice, for everyone or only for chosen members and member groups, built on Microsoft.FeatureManagement. It supports Umbraco 17, 18 and 19.
A feature flag is a switch that turns part of your website on or off without a new release. Developers build the
feature and add the flag. Editors then decide, in the Umbraco backoffice, when it is on and who sees it.

Developers declare flags in appsettings or code and check them with
[Microsoft.FeatureManagement](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-dotnet-reference),
as they would on any ASP.NET Core site. Feature Flags gives editors a screen in Settings to switch each flag off, on
for everyone, or on for an audience of members, member groups and groups the site works out in code. Changes apply
to that site and environment only, reach every server within seconds, and never need a deploy.
## Why use a feature flag

A flag doesn't have to switch on a whole new page. It can add one button, swap a search box, or change a price for
the members it is on for.
- Show a redesigned checkout to a few members first, then to everyone.
- Let a group of beta testers try a new feature before it is public.
- Put a seasonal banner on the site and take it off again at set times.
- Switch a feature off at once if it causes trouble, without waiting for a deploy.
- Turn something on for one site of several on the same Umbraco install.
- Use different settings in staging and production. Each environment keeps its own.

## What this package adds

- Everything happens in the backoffice, under **Settings → Feature Flags**.
- Safe defaults: new flags start off, and a visitor who isn't signed in is in no audience.
- Umbraco permissions decide which users can see flags and which can change them.
- It is built on Microsoft's standard feature management, so developers use the normal .NET ways of declaring and
checking flags.
- It supports Umbraco 17, 18 and 19.

Changes reach every server within seconds and never need a deploy. A flag usually controls one part of a page, such as
a button, a search box or a price, rather than a whole page.

<img src="docs/images/feature-flags-list.png" alt="The Feature Flags list in Settings, with flags in sections for Checkout and Members, each showing its state, an on/off switch and notes such as Changed here">

Expand Down
43 changes: 27 additions & 16 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ named after its 17.x version.
7. Check each run also published the npm types package, or publish it by hand while npm publishing is off (see
below).
8. Merge `main` back into `develop` through a pull request with the `release-flow` label.
9. In that back-merge or the next pull request, move each released major's `PackageValidationBaselineVersion` in
`Directory.Build.props` to the version just released. Packing fails when a major's public API breaks against its
baseline, so breaking changes wait for a new Umbraco major.

Umbraco 19 stays a pre-release until Umbraco 19.0.0 is out (due 10 December 2026), so until then leave `v19.x.y`
out of step 4 and tag it as `v19.N.P-rc.M` on the release branch, as in the first release below.
Expand All @@ -79,9 +82,8 @@ The first release is `17.0.0`. There is no 0.x or 1.0. Until Umbraco 19.0.0 is o
```

3. Approve `production` in its run, and check the NuGet pre-release and the GitHub pre-release.
4. Publish `@umbricians/feature-flags@19.0.0-rc.1` by hand, the one npm publish that can't come from the workflow,
and switch npm publishing on, as in "The first npm publish" below. Tags pushed after that publish to npm
themselves.
4. Set up npm publishing before the tag in step 2 is pushed, as in "The first npm publish" below. The run then
publishes `@umbricians/feature-flags@19.0.0-rc.1` to npm with the `next` dist-tag, so no manual publish is needed.
5. Merge the pull request with a merge commit once the `build` check passes.
6. Tag the merge commit on `main` as `v17.0.0` and `v18.0.0`, and push both tags:

Expand Down Expand Up @@ -153,24 +155,33 @@ packs it as the `npm-types-package-17`, `npm-types-package-18` or `npm-types-pac
Install the major that matches your Umbraco with `npm install -D @umbricians/feature-flags@18`. A version that is
already on npm is skipped, so a run can be re-run.

**If a publish fails.** nuget.org and the npm registry can take several minutes to list a new version, and npm can
return 404 for a while, so wait before deciding a publish failed. If a run's npm step fails after NuGet pushed, re-run
its `publish` job. If the bug is in the workflow file, a re-run won't help, because a tag always runs the workflow at
its own commit: publish that version's `.tgz` by hand with its dist-tag, then re-run the job so the GitHub release is
created. NuGet and npm skip the versions they already have. The v17.0.0 run failed this way: npm read the relative
path `folder/file.tgz` as a GitHub `user/repo`, with a git "Permission denied (publickey)" error. The workflow now
passes the tarball's full path (fixed in #69).

### The first npm publish

npm only trusts a workflow for a package that already exists, so the first version is published by hand, once:
For a new npm package, or a fresh setup, set up trusted publishing before the first version exists, and let the first
tagged release publish it and validate the setup:

1. Download `npm-types-package-19` from the `v19.0.0-rc.1` run, and check the `.tgz` holds `index.d.ts`,
`README.md`, `LICENSE` and `package.json`.
2. From a machine logged in to an npm account that can publish to the `@umbricians` scope, run
`npm publish umbricians-feature-flags-19.0.0-rc.1.tgz --access public --tag next`.
3. On npmjs.com, open the package's **Settings → Trusted publishing**, choose GitHub Actions, and enter owner
`Umbricians`, repository `Feature-Flags`, workflow `build.yml` and environment `production`. npm doesn't check
these until the next publish, so check the spelling.
4. In the package's settings, set publishing access to require two-factor authentication and disallow tokens, so
1. On npmjs.com, open the package's **Settings → Trusted publishing**, choose GitHub Actions, and enter owner
`Umbricians`, repository `Feature-Flags`, workflow `build.yml` and environment `production`. Tick both
**Allow npm publish** and **Allow npm dist-tag**. npm then creates a placeholder version `0.0.0-stage`
("Temporary package placeholder for staged publishing") and shows "Trusted publishing config not yet validated.
Publish once before <date> to validate this configuration." npm doesn't check the entries until the next publish,
so check the spelling.
2. In the package's settings, set publishing access to require two-factor authentication and disallow tokens, so
only the workflow and a maintainer can publish.
5. In the GitHub repository, **Settings → Secrets and variables → Actions → Variables**, add the variable
3. In the GitHub repository, **Settings → Secrets and variables → Actions → Variables**, add the variable
`NPM_PUBLISH` with the value `true`.

If a run published to NuGet but not npm (npm publishing was off, or npm failed), re-run its `publish` job, or
publish that run's `.tgz` by hand with the dist-tag above.
4. Tag a release as usual. Its run publishes the package to npm, and that first publish validates the trusted
publishing setup. No manual publish is needed.
5. Once the workflow has published, remove the placeholder with
`npm unpublish @umbricians/feature-flags@0.0.0-stage`, or with `npm deprecate` if npm refuses to unpublish it.

## Adding an Umbraco major

Expand Down
16 changes: 8 additions & 8 deletions src/Umbricians.FeatureFlags.Types/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Umbricians.FeatureFlags.Types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@umbraco-cms/backoffice": "^17.8.2"
},
"devDependencies": {
"@types/node": "^22.20.5",
"@types/node": "^26.6.6",
"@umbraco-cms/backoffice": "17.8.2",
"typescript": "^7.0.2"
},
Expand Down
Loading