From 9556d062dc012b0515572df0bb7d01fc25fe17e3 Mon Sep 17 00:00:00 2001 From: Tim Jones Date: Fri, 20 Nov 2026 10:56:36 +0000 Subject: [PATCH 1/3] Publish with NuGet trusted publishing and prepare the 11.0.0 release - release.yml replaces publish.yml. On a v* tag it runs the full test suite (fast and integration), checks the tag matches and that docs/releases.md has a section for the version, packs AsyncMonolith and AsyncMonolith.TestHelpers, exchanges GitHub's OIDC token for a one-hour nuget.org key with NuGet/login, pushes the packages and symbols, and creates the GitHub release from the release notes with the packages attached. Running it manually is a dry run that stops before publishing. Publishing runs in the "release" environment so approvals can be required. - The test workflow packs both packages on every push and PR, so package validation and metadata problems show up before a release. - RELEASING.md covers the one-off nuget.org and GitHub setup, each release, and deprecating the five merged packages afterwards. - The 11.0.0 notes gain upgrade steps, drop a stale item about ConsumerRegistry, say "deduplication key", and use an absolute docs link that works on the GitHub release page. --- .github/workflows/publish.yml | 36 --------- .github/workflows/release.yml | 134 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 5 ++ RELEASING.md | 53 ++++++++++++++ docs/releases.md | 15 +++- 5 files changed, 203 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release.yml create mode 100644 RELEASING.md diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 3c1d309..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Publish NuGet packages - -# Publishes every package at the version in Directory.Build.props. The providers and test helpers -# depend on the core package at that same version, so they are always released together. -on: - workflow_dispatch: - push: - tags: - - 'v*' - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - global-json-file: global.json - - - name: Build - run: dotnet build AsyncMonolith.sln -c Release - - - name: Fast tests - run: dotnet test --project AsyncMonolith.Tests -c Release --no-build --filter-not-trait "Category=Integration" - - - name: Pack - run: | - for project in AsyncMonolith AsyncMonolith.TestHelpers; do - dotnet pack "$project/$project.csproj" -c Release --no-build --output nupkg - done - - - name: Publish to NuGet - run: dotnet nuget push "nupkg/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a573211 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,134 @@ +name: Release + +# Publishes AsyncMonolith and AsyncMonolith.TestHelpers to nuget.org with trusted publishing: GitHub issues a +# short-lived OIDC token, nuget.org exchanges it for a one-hour API key, and no long-lived key is stored. +# +# - Push a tag such as v11.0.0 to release. The tag must match in Directory.Build.props. +# - Run it manually ("Run workflow") for a dry run: everything except publishing. +# +# Needs the NUGET_USER secret (the nuget.org profile name that owns the trusted publishing policy for this +# workflow file). +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: release + cancel-in-progress: false + +jobs: + test: + name: Full test suite + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + global-json-file: global.json + + - name: Build + run: dotnet build AsyncMonolith.sln -c Release + + - name: Fast and integration tests + run: dotnet test --project AsyncMonolith.Tests -c Release --no-build + + package: + name: Pack + needs: test + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + global-json-file: global.json + + - name: Read the version + id: version + run: | + version=$(dotnet msbuild AsyncMonolith/AsyncMonolith.csproj -getProperty:Version) + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "Packing $version" + if [[ "$GITHUB_REF_TYPE" == "tag" && "$GITHUB_REF_NAME" != "v$version" ]]; then + echo "::error::Tag $GITHUB_REF_NAME does not match the version in Directory.Build.props ($version)." + exit 1 + fi + + - name: Check the release notes + run: | + version="${{ steps.version.outputs.version }}" + awk -v v="$version" '/^## /{p=($2==v)} p' docs/releases.md > release-notes.md + if [[ ! -s release-notes.md ]]; then + echo "::error::docs/releases.md has no '## $version' section." + exit 1 + fi + + - name: Pack + run: | + dotnet pack AsyncMonolith/AsyncMonolith.csproj -c Release --output nupkg + dotnet pack AsyncMonolith.TestHelpers/AsyncMonolith.TestHelpers.csproj -c Release --output nupkg + ls -l nupkg + + - name: Upload packages + uses: actions/upload-artifact@v4 + with: + name: packages + path: | + nupkg/ + release-notes.md + + publish: + name: Publish to nuget.org + needs: package + if: github.ref_type == 'tag' + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write # trusted publishing + contents: write # GitHub release + steps: + - name: Download packages + uses: actions/download-artifact@v4 + with: + name: packages + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + + # The API key lasts an hour, so ask for it right before pushing. + - name: NuGet login (OIDC to temporary API key) + uses: NuGet/login@v1 + id: login + with: + user: ${{ secrets.NUGET_USER }} + + - name: Push packages + run: >- + dotnet nuget push "nupkg/*.nupkg" + --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" + --source https://api.nuget.org/v3/index.json + --skip-duplicate + + - name: Create the GitHub release + env: + GH_TOKEN: ${{ github.token }} + run: >- + gh release create "$GITHUB_REF_NAME" nupkg/*.nupkg + --repo "$GITHUB_REPOSITORY" + --title "AsyncMonolith ${{ needs.package.outputs.version }}" + --notes-file release-notes.md + --verify-tag diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1413715..3c91031 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,6 +36,11 @@ jobs: name: coverage-fast path: coverage/ + - name: Pack (checks package validation and metadata) + run: | + dotnet pack AsyncMonolith/AsyncMonolith.csproj -c Release --output nupkg + dotnet pack AsyncMonolith.TestHelpers/AsyncMonolith.TestHelpers.csproj -c Release --output nupkg + integration: if: github.event_name == 'workflow_dispatch' && inputs.integration runs-on: ubuntu-latest diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..01ea079 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,53 @@ +# Releasing AsyncMonolith + +Releases publish two packages, `AsyncMonolith` and `AsyncMonolith.TestHelpers`, at the same version, using +[NuGet trusted publishing](https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing): no API key is +stored anywhere. The [release workflow](.github/workflows/release.yml) does the work. + +## One-off setup + +- **nuget.org:** a trusted publishing policy for repository `Timmoth/AsyncMonolith`, workflow file `release.yml`, + covering `AsyncMonolith*`. If the policy names an environment, it must be `release`. +- **GitHub secret `NUGET_USER`:** the nuget.org profile name (not the email address) that owns the policy. +- **GitHub environment `release`:** created on first use. Add required reviewers to it if releases should need an + approval before publishing. +- The old `NUGET_API_KEY` secret is no longer used and can be deleted. + +## Versioning + +AsyncMonolith follows [Semantic Versioning](https://semver.org) from 11.0.0: breaking changes bump the major +version. The version lives in one place, `` in [Directory.Build.props](Directory.Build.props). + +## Each release + +1. On `main`, set `` to the new version. +2. Add a `## ` section to [docs/releases.md](docs/releases.md). It becomes the GitHub release notes, so + say what changed, what breaks, and whether a migration is needed. Add a row to the table at the top. +3. Run the workflow manually ("Run workflow" on the Release workflow) for a dry run: it runs the full test suite, + checks the release notes and packs, but doesn't publish. Download the `packages` artifact to inspect them. +4. Tag and push: + + ```bash + git tag v11.0.0 + ``` + + ```bash + git push origin v11.0.0 + ``` + + The tag must match ``, or the workflow stops. It then runs the full test suite (including the + integration tests against PostgreSQL, SQL Server, MySQL and MariaDB), packs, exchanges GitHub's OIDC token for + a one-hour nuget.org key, pushes both packages and their symbols, and creates the GitHub release with the + packages attached. +5. After the first release of a new major version, set `PackageValidationBaselineVersion` in + [Directory.Build.targets](Directory.Build.targets) to it, so later releases are checked for accidental breaking + changes. + +If a push fails partway, rerun the failed job: pushing uses `--skip-duplicate`, so packages already published are +left alone. + +## After 11.0.0 + +`AsyncMonolith.Ef`, `AsyncMonolith.PostgreSql`, `AsyncMonolith.MsSql`, `AsyncMonolith.MySql` and +`AsyncMonolith.MariaDb` are replaced by `AsyncMonolith`. On nuget.org, mark each as deprecated ("Legacy") with +`AsyncMonolith` as the alternate package, so their users are pointed at the upgrade. diff --git a/docs/releases.md b/docs/releases.md index 142f497..aa0e647 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -2,7 +2,7 @@ Make sure to check this table before updating the nuget package in your solution | Version | Description | Migration Required | |---------|--------------------------------------------|--------------------| -| 11.0.0 | SQLite-safe processing, stored names, modules, backoff, poisoned message service (see below) | Yes | +| 11.0.0 | One package, multi-instance-safe processing, new consumer and options APIs (see below) | Yes | | 8.0.6 | Added ConsumerAttempts override attribute | No | | 8.0.5 | Bundle debug symbols with nuget package | No | | 8.0.4 | Bundle XML docs with nuget package | No | @@ -19,6 +19,14 @@ Make sure to check this table before updating the nuget package in your solution AsyncMonolith is now a single package. From 11.0.0 the major version follows [Semantic Versioning](https://semver.org) (it changes for breaking changes) rather than the .NET version. It is tested against PostgreSQL, SQL Server, MySQL 8.4 (with Oracle's `MySql.EntityFrameworkCore`), MariaDB 11.8 and SQLite. +**Upgrading from 8.x or 10.x** + +1. Replace `AsyncMonolith.Ef`, `.PostgreSql`, `.MsSql`, `.MySql` or `.MariaDb` with the `AsyncMonolith` package, and add your EF Core provider if your app doesn't reference it already. +2. Replace `services.Add{Database}AsyncMonolith(settings => ...)` with `services.AddAsyncMonolith(options => ...)`, converting times to `TimeSpan`s (see the options changes below). +3. Make consumers implement `IConsumer` and add the `ConsumeContext context` parameter to `Consume`. +4. Call `modelBuilder.ConfigureAsyncMonolith()` in `OnModelCreating`, then add and apply a migration (see below). +5. On PostgreSQL, SQL Server, MySQL or MariaDB, make sure every `Produce` is followed by `SaveChangesAsync`: messages are no longer written without it. + **Migration required.** Add a migration (`dotnet ef migrations add AsyncMonolith_11_0_0`). It adds a nullable `last_error` column to `consumer_messages` and `poisoned_messages`. It also adds indexes for finding due messages (`rail_id, available_after`), due schedules (`available_after`), schedules by tag, and poisoned messages by age, which keep processing fast as the tables grow. If you manage the schema by hand, see the [SQL schemas](https://github.com/Timmoth/AsyncMonolith/tree/main/Schemas). They also now include `rail_id`, and their `trace_id` and `span_id` columns are nullable. **Changes** @@ -27,9 +35,9 @@ AsyncMonolith is now a single package. From 11.0.0 the major version follows [Se - Cron expressions can have 5 fields (minute precision) as well as 6 (seconds first). - `AsyncMonolithOptions.SerializerOptions` sets the `JsonSerializerOptions` for payloads. The default is unchanged. - Tables can live in their own schema or have a prefix: `modelBuilder.ConfigureAsyncMonolith(o => { o.Schema = "jobs"; o.TablePrefix = "jobs_"; })`. The row-locking SQL follows the mapping. -- Every database now produces messages the same way: they are added to your `DbContext` and written on `SaveChanges`, in your transaction. The PostgreSQL, SQL Server, MySQL and MariaDB packages used to write immediately. A repeated insert id skips consumers that already have a pending message with it, on every database. +- Every database now produces messages the same way: they are added to your `DbContext` and written on `SaveChanges`, in your transaction. The PostgreSQL, SQL Server, MySQL and MariaDB packages used to write immediately. A repeated deduplication key skips consumers that already have a pending message with it, on every database. - Several app instances can safely share the tables with any database. Claims and schedule occurrences use conditional updates, so a message is processed by one processor at a time and a schedule fires once per occurrence. -- Fetch order is deterministic (oldest first, then by id). See [Ordering](guides/consuming-messages.md#ordering) for what is and isn't guaranteed. +- Fetch order is deterministic (oldest first, then by id). See [Ordering](https://timmoth.github.io/AsyncMonolith/guides/consuming-messages/#ordering) for what is and isn't guaranteed. - Consumers can write to the database on SQLite. Messages are claimed and leased in a short transaction, consumers run outside it, and each message is completed in its own short write. If the app stops mid-message, the message is retried once its consumer timeout plus 30 seconds has passed. - Retries back off exponentially from `AttemptDelay` up to the new `MaxAttemptDelay` option (default 5 minutes). - The last error is stored on retried and poisoned messages. @@ -56,5 +64,4 @@ AsyncMonolith is now a single package. From 11.0.0 the major version follows [Se - `AsyncMonolith.TestHelpers` uses xunit v3, and `ConsumerTestBase.InitializeAsync`/`DisposeAsync` return `ValueTask`. - `IScheduleService` has a new member (`EnsureSchedule`), so custom implementations must add it. - Errors that were thrown as `System.Exception` are now `InvalidOperationException`. -- `ConsumerRegistry` exposes properties instead of public fields. - `TestConsumerMessageProcessor.ProcessNext` now finds the consumer's message. It previously always returned null. From f198587aae857a41bda181af5e5ea3291ddbc63b Mon Sep 17 00:00:00 2001 From: Tim Jones Date: Fri, 20 Nov 2026 10:57:46 +0000 Subject: [PATCH 2/3] Name the aptacode nuget.org account in the release workflow The profile name isn't sensitive, so the workflow names it directly instead of reading a NUGET_USER secret. --- .github/workflows/release.yml | 5 ++--- RELEASING.md | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a573211..ff73db0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,8 +6,7 @@ name: Release # - Push a tag such as v11.0.0 to release. The tag must match in Directory.Build.props. # - Run it manually ("Run workflow") for a dry run: everything except publishing. # -# Needs the NUGET_USER secret (the nuget.org profile name that owns the trusted publishing policy for this -# workflow file). +# The nuget.org account that owns the trusted publishing policy for this workflow file is "aptacode". on: push: tags: @@ -114,7 +113,7 @@ jobs: uses: NuGet/login@v1 id: login with: - user: ${{ secrets.NUGET_USER }} + user: aptacode # nuget.org profile name that owns the trusted publishing policy - name: Push packages run: >- diff --git a/RELEASING.md b/RELEASING.md index 01ea079..5c3e233 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -8,7 +8,7 @@ stored anywhere. The [release workflow](.github/workflows/release.yml) does the - **nuget.org:** a trusted publishing policy for repository `Timmoth/AsyncMonolith`, workflow file `release.yml`, covering `AsyncMonolith*`. If the policy names an environment, it must be `release`. -- **GitHub secret `NUGET_USER`:** the nuget.org profile name (not the email address) that owns the policy. +- **nuget.org account:** the policy belongs to the `aptacode` profile, which the workflow names in its login step. - **GitHub environment `release`:** created on first use. Add required reviewers to it if releases should need an approval before publishing. - The old `NUGET_API_KEY` secret is no longer used and can be deleted. From 3e8839e5f919bfe371d9ab348db1aee4336afcdf Mon Sep 17 00:00:00 2001 From: Tim Jones Date: Fri, 20 Nov 2026 11:02:01 +0000 Subject: [PATCH 3/3] Pack without GeneratePackageOnBuild GeneratePackageOnBuild packed as part of every build, and with an explicit dotnet pack it tried to pack before the assembly was built (NU5026), so packing only worked when an earlier Release build had left the DLL behind. CI's new pack step caught it, and the release workflow's pack job would have failed the same way. Packing is explicit now, so the two published projects are marked with IsAsyncMonolithPackage instead, which Directory.Build.targets uses for the package metadata. Packing from a clean checkout works and the packages keep their licence, README, icon, XML docs and symbols. --- AsyncMonolith.TestHelpers/AsyncMonolith.TestHelpers.csproj | 2 +- AsyncMonolith/AsyncMonolith.csproj | 2 +- Directory.Build.targets | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AsyncMonolith.TestHelpers/AsyncMonolith.TestHelpers.csproj b/AsyncMonolith.TestHelpers/AsyncMonolith.TestHelpers.csproj index 23a2b60..00a34af 100644 --- a/AsyncMonolith.TestHelpers/AsyncMonolith.TestHelpers.csproj +++ b/AsyncMonolith.TestHelpers/AsyncMonolith.TestHelpers.csproj @@ -1,7 +1,7 @@  - true + true true AsyncMonolith.TestHelpers Fakes and helpers for testing AsyncMonolith consumers with xunit v3. diff --git a/AsyncMonolith/AsyncMonolith.csproj b/AsyncMonolith/AsyncMonolith.csproj index 34d3e16..20ce63b 100644 --- a/AsyncMonolith/AsyncMonolith.csproj +++ b/AsyncMonolith/AsyncMonolith.csproj @@ -1,7 +1,7 @@  - true + true true AsyncMonolith Transactional outbox, background consumers and scheduled messages for .NET monoliths on EF Core. diff --git a/Directory.Build.targets b/Directory.Build.targets index 344001c..9748144 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,6 +1,6 @@ - - + + Tim Jones Aptacode Copyright (c) Tim Jones @@ -24,7 +24,7 @@ true - +