Skip to content

Add build and release workflows - #2

Merged
mos379 merged 2 commits into
mainfrom
ci/release-workflow
Oct 15, 2026
Merged

mos379 merged 2 commits into
mainfrom
ci/release-workflow

Conversation

@mos379

@mos379 mos379 commented Oct 15, 2026

Copy link
Copy Markdown
Owner

The repo had no CI — which is why the Android targets in #1 went unverified — and releases were packed by hand.

Why both run on windows-latest

The Windows TFMs are conditioned on the host OS:

<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0;net10.0-windows10.0.19041.0</TargetFrameworks>

So packing anywhere else silently drops them. I hit this packing 2.1.0 on a Mac:

published 2.0.0 macOS-packed 2.1.0
android / ios / maccatalyst (net9 + net10) ✅ ✅
net9.0-windows / net10.0-windows ✅ ❌

Publishing that would have removed Windows support for existing users, and NuGet versions can't be deleted. Both workflows now unzip the package they just built and fail if an Android, iOS, MacCatalyst or Windows target is missing.

What each does

  • Build — pushes to main and PRs: builds, packs, verifies targets, uploads the .nupkg as an artifact.
  • Release — on a v* tag: builds, packs, verifies, pushes to NuGet, creates the GitHub release. workflow_dispatch takes an explicit version for a re-run.

The version comes from the tag (v2.1.0 → 2.1.0) and is passed as -p:PackageVersion, so the csproj value and the published package can't disagree.

Before the first release

Add a NUGET_API_KEY secret under Settings → Secrets and variables → Actions. Without it the publish step stops with a clear message rather than failing obscurely. Then:

git tag v2.1.0 && git push origin v2.1.0

🤖 Generated with Claude Code

https://claude.ai/code/session_012fvKRoJiVhmmARSE8k7Vtf

The repository had no CI, which is why the Android targets in #1 went
unverified, and releases were packed by hand.

Both workflows run on windows-latest, and that matters: the Windows target
frameworks are conditioned on the host OS in the csproj, so packing on
macOS or Linux produces a package without them. Published 2.0.0 carries
net9.0-windows and net10.0-windows; a Mac-built 2.1.0 would have dropped
both and taken Windows support away from anyone already on the library.
Each workflow therefore inspects the package it just built and fails if an
Android, iOS, MacCatalyst or Windows target is missing.

Build runs on pushes to main and on pull requests, and uploads the package
so it can be inspected before release. Release runs on a v* tag, takes the
version from the tag so the csproj and the published package cannot
disagree, pushes to NuGet and creates the GitHub release. It needs a
NUGET_API_KEY secret and says so plainly if it is missing.
nuget.org recommends trusted publishing, and it is the better fit here:
the workflow exchanges this run's OIDC token for an API key that lives
minutes, so there is no long-lived secret in the repository to leak or
rotate, and a key cannot be used from anywhere else.

The job gains id-token: write, NuGet/login@v1 performs the exchange, and
the push uses the temporary key it returns. The nuget.org side needs a
policy naming this repository and release.yml, and the workflow reads the
nuget.org username from a NUGET_USER repository variable — a username is
not a secret.
@mos379

mos379 commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

Switched the publish step to trusted publishing as you suggested — pushed to this branch.

The job now carries id-token: write, NuGet/login@v1 exchanges the run's OIDC token for a short-lived key, and the push uses that. No NUGET_API_KEY secret any more: nothing long-lived in the repo to leak or rotate, and the credential can't be used from anywhere else.

Two bits of setup instead, both documented in the README:

  1. nuget.org → Trusted Publishing — add a policy for owner mos379, repository Particles.Maui, workflow release.yml, environment empty.
  2. Repository variable NUGET_USER — your nuget.org username. A variable rather than a secret, since a username isn't one.

@mos379
mos379 merged commit fd2cbb6 into main Oct 15, 2026
1 check passed
@mos379
mos379 deleted the ci/release-workflow branch October 15, 2026 19:01
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