Skip to content

Add from-scratch quickstart tutorial + NuGet publish workflow#19

Merged
ancongui merged 1 commit intomainfrom
feat/quickstart-tutorial-publish-workflow
May 7, 2026
Merged

Add from-scratch quickstart tutorial + NuGet publish workflow#19
ancongui merged 1 commit intomainfrom
feat/quickstart-tutorial-publish-workflow

Conversation

@ancongui
Copy link
Copy Markdown
Contributor

@ancongui ancongui commented May 7, 2026

Summary

The README previously had a "Run the Orders sample" quickstart but no end-to-end tutorial for spinning up a brand-new service from scratch. This PR adds that tutorial alongside a release-publish workflow so the packages it tells readers to `dotnet add` actually resolve once the maintainer cuts a release.

README

"Build your first Firefly service" — new section right after the sample quickstart

Walks the reader from `dotnet new webapi` to a runnable hello-world service in six numbered steps:

  1. Prerequisites — .NET 10 SDK, `curl`.
  2. Create the project — `dotnet new webapi -n HelloFirefly`.
  3. Install the framework — `dotnet add package FireflyFramework.Starter.Core`.
  4. `Program.cs` — 40-line bootstrap showing `AddFireflyCore` + `UseFireflyWeb` + a minimal CQRS command/handler against the real `ICommand` / `ICommandHandler<TCommand, TResult>` interfaces.
  5. `appsettings.json` — matching `Firefly:*` config snippet.
  6. Smoke-test — `dotnet run` + curl exercising the happy path and the `X-Idempotency-Key` replay path.

Plus a follow-up checklist (add a query, promote to the canonical 5-project layout, pick a richer starter) and links to `docs/SERVICE-SCAFFOLDING.md` + `docs/CONFIGURATION.md`.

"Releases & publishing" — new section right after "Versioning"

Documents the CI / publish split, where packages land (NuGet.org + GitHub Packages + release assets), and how to cut a release (`git tag` + `gh release create` for the common path; `workflow_dispatch` for hotfix / pre-release cuts).

Workflows

`.github/workflows/ci.yml` — fix .NET version

Bumped `dotnet-version` from `9.0.x` to `10.0.x`. The projects target `net10.0`; the wrong runtime would have failed on a fresh runner. Pack job is unchanged: it uploads every `src/*` `.nupkg` as a workflow artifact for preview, but does not push to a registry.

`.github/workflows/publish.yml` — new

Triggers on a published GitHub Release (tag `vX.Y.Z` → package version `X.Y.Z`) or by manual `workflow_dispatch` with an explicit version. Steps:

  1. Setup .NET 10.
  2. Resolve version (release tag or manual input).
  3. Restore + build + test.
  4. `dotnet pack` with `-p:PackageVersion=$VERSION -p:Version=$VERSION -p:ContinuousIntegrationBuild=true` so symbol packages embed the right repo URL.
  5. Upload `.nupkg` + `.snupkg` as a workflow artifact (audit trail).
  6. Push to NuGet.org via `secrets.NUGET_API_KEY` — skipped with a warning if the secret isn't configured (useful for first-time setup).
  7. Push to GitHub Packages via the workflow's `GITHUB_TOKEN` (always present, no extra setup).
  8. Attach packages to the GitHub Release as downloadable assets (only on release events).

Both pushes use `--skip-duplicate`, so re-running on the same version is a safe no-op.

Verification

  • `dotnet pack FireflyFramework.sln --configuration Release` packs 51 NuGet packages (52 `src/*` projects minus `FireflyFramework.ConfigServer`, which is an executable Web host with `false`). Sample projects and the test project carry the same opt-out.
  • The CQRS interface signatures used in the tutorial (`ICommand`, `ICommandHandler<in TCommand, TResult>`, `HandleAsync(command, context, ct)`) match the real surface in `src/FireflyFramework.Cqrs/Commands/`.

Test plan

  • `dotnet build FireflyFramework.sln` — 0 errors / 0 warnings
  • `dotnet test FireflyFramework.sln --no-build` — 346 / 346 pass (unchanged)
  • `dotnet pack FireflyFramework.sln --configuration Release` — 51 `.nupkg` produced; samples + tests + ConfigServer correctly excluded

Maintainer setup (one-time)

To enable NuGet.org publishing, configure a repository secret named `NUGET_API_KEY` at https://github.com/fireflyframework/fireflyframework-dotnet/settings/secrets/actions. Until then, the workflow only pushes to GitHub Packages and attaches `.nupkg` to the release.

The README previously had a "Run the Orders sample" quickstart but no
end-to-end tutorial for spinning up a brand-new service from a blank
repository. This PR adds that tutorial alongside a release-publish
workflow so the packages it tells readers to `dotnet add` actually
resolve once the maintainer cuts a release.

## README — "Build your first Firefly service"

A new section right after the sample quickstart walks the reader from
`dotnet new webapi` to a runnable hello-world service in six numbered
steps:

1. Prerequisites (.NET 10 SDK, curl).
2. `dotnet new webapi -n HelloFirefly` + cleanup.
3. `dotnet add package FireflyFramework.Starter.Core`.
4. A 40-line `Program.cs` showing `AddFireflyCore` + `UseFireflyWeb`,
   a minimal `[POST /api/v1/greet]` endpoint, and an in-line CQRS
   command + handler exercising the real `ICommand<T>` /
   `ICommandHandler<TCommand, TResult>` interfaces from
   `FireflyFramework.Cqrs`.
5. `appsettings.json` with the matching `Firefly:*` config.
6. `dotnet run` + a curl that exercises both the happy path and the
   `X-Idempotency-Key` replay path.

The section also points to follow-up moves — adding a query, promoting
to the canonical 5-project layout, picking a richer starter — and
links to `docs/SERVICE-SCAFFOLDING.md` and `docs/CONFIGURATION.md`.

A new "Releases & publishing" section right after "Versioning"
describes the CI / publish split: what runs on PR vs. main vs.
release-published, where packages land (NuGet.org + GitHub Packages +
release assets), how to cut a release with `git tag` + `gh release
create`, and how to use `workflow_dispatch` for hotfix / pre-release
cuts.

## Workflows

* `.github/workflows/ci.yml` — bumped `dotnet-version` from `9.0.x`
  to `10.0.x` (the projects target `net10.0`; the wrong runtime would
  have failed on a fresh runner). Pack job is unchanged: it uploads
  every `src/*` `.nupkg` as a workflow artifact for preview, but does
  not push.

* `.github/workflows/publish.yml` — new. Triggers on a published
  GitHub Release (tag `vX.Y.Z` → package version `X.Y.Z`) or by
  manual `workflow_dispatch` with an explicit version. Steps:

    1. Setup .NET 10.
    2. Resolve the package version (release tag or manual input).
    3. Restore + build + test.
    4. Upload `.trx` test results as an artifact.
    5. `dotnet pack` with `-p:PackageVersion=$VERSION
       -p:Version=$VERSION -p:ContinuousIntegrationBuild=true` so the
       symbol packages embed the right repo URL.
    6. Upload the `.nupkg` + `.snupkg` as a workflow artifact.
    7. Push to NuGet.org via `secrets.NUGET_API_KEY` (skipped with a
       warning if the secret isn't configured, instead of failing
       — useful for first-time setup).
    8. Push to GitHub Packages via the workflow's `GITHUB_TOKEN`
       (always present, no extra setup).
    9. On a release event, attach every produced `.nupkg` + `.snupkg`
       to the GitHub Release as downloadable assets.

  Both pushes use `--skip-duplicate`, so re-running the workflow on
  the same version is a safe no-op.

## Verification

* `dotnet pack FireflyFramework.sln --configuration Release` packs
  51 NuGet packages (52 `src/*` projects minus `FireflyFramework.ConfigServer`,
  which is an executable Web host with `<IsPackable>false</IsPackable>`).
  Sample projects and the test project carry the same opt-out.

* The CQRS interface signatures used in the tutorial code
  (`ICommand<out TResult>`, `ICommandHandler<in TCommand, TResult>`,
  `HandleAsync(command, context, ct)`) match the real surface in
  `src/FireflyFramework.Cqrs/Commands/`.
@ancongui ancongui merged commit e36dee4 into main May 7, 2026
1 check passed
@ancongui ancongui deleted the feat/quickstart-tutorial-publish-workflow branch May 7, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant