From 0461a24f765694a46f7fdc5f3dc5b15f1867b4e7 Mon Sep 17 00:00:00 2001 From: Thomas Bruderer Date: Wed, 21 Oct 2026 16:21:54 +0200 Subject: [PATCH] Release 1.2.0: update StyleCop.Analyzers, add release pipeline - Update StyleCop.Analyzers from 1.2.0-beta.556 to 1.3.149-beta (C# 14 extension blocks and other newer syntax are now analyzed) - Enable new rules SA1143, SA1315, SA1317, SA1653, SA1654 as errors; list SX1412 as disabled alongside SA1412 - Update Microsoft.Build.NoTargets SDK to 3.7.134 - Add publish-release workflow that pushes to nuget.org via trusted publishing when a version tag is pushed - Document the release process in the README Co-Authored-By: Claude Fable 5.1 --- .github/workflows/publish-release.yml | 46 +++++++++++++++++++++++++++ .gitignore | 2 +- CodeStyle/CodeStyle.csproj | 4 +-- CodeStyle/build/StyleCop.ruleset | 6 ++++ README.md | 6 ++++ changelog.md | 19 +++++++++++ global.json | 2 +- 7 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..f221ad6 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,46 @@ +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+-*' + +name: Publish Release Packages + +jobs: + publish: + name: Pack and Push to nuget.org + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # lets the job request the GitHub OIDC token that nuget.org exchanges for a short-lived API key + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + name: Install Current .NET SDK + - name: Verify that the tag matches the package version + run: | + version="$(sed -n 's:.*\(.*\).*:\1:p' CodeStyle/CodeStyle.csproj)" + if [ "$version" != "${{github.ref_name}}" ]; then + echo "::error::Tag '${{github.ref_name}}' does not match $version in CodeStyle/CodeStyle.csproj" + exit 1 + fi + - name: Pack Packages + run: dotnet pack --configuration Release --output nupkg /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=true + - name: List Packages + run: ls -l nupkg + # Trusted Publishing: no long-lived API key is stored. nuget.org validates the OIDC token against the + # trusted publishing policy of the package owner (repository polyadic/code-style, workflow publish-release.yml) + # and returns an API key that is valid for one hour, so the login runs right before the push. + - name: NuGet login (OIDC) + uses: NuGet/login@v1 + id: login + with: + user: ${{vars.NUGET_USER}} # nuget.org profile name of the policy's creator, a member of the polyadic organization + - name: Push Packages + # --skip-duplicate makes a re-run after a partial failure idempotent: + # versions that are already on nuget.org are reported, not rejected. + run: dotnet nuget push 'nupkg/*.nupkg' --source https://api.nuget.org/v3/index.json --api-key ${{steps.login.outputs.NUGET_API_KEY}} --skip-duplicate + - uses: actions/upload-artifact@v4 + with: + name: nupkg + path: nupkg/* diff --git a/.gitignore b/.gitignore index 63ee390..b7f7663 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /artifacts/ - +/.vs/ diff --git a/CodeStyle/CodeStyle.csproj b/CodeStyle/CodeStyle.csproj index 1c6d114..81d75b7 100644 --- a/CodeStyle/CodeStyle.csproj +++ b/CodeStyle/CodeStyle.csproj @@ -1,7 +1,7 @@ - 1.1.0 + 1.2.0 Polyadic.CodeStyle analyzers Various analyzers bundled with opinionated configuration @@ -16,7 +16,7 @@ - + diff --git a/CodeStyle/build/StyleCop.ruleset b/CodeStyle/build/StyleCop.ruleset index ee220b4..1ac1e09 100644 --- a/CodeStyle/build/StyleCop.ruleset +++ b/CodeStyle/build/StyleCop.ruleset @@ -77,6 +77,7 @@ + @@ -114,7 +115,9 @@ + + @@ -211,10 +214,13 @@ + + + diff --git a/README.md b/README.md index 21d77c8..e577991 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,12 @@ Shared Code Style for all Polyadic/Funcky projects. The rules are configured with the expectation that you build with `/p:TreatWarningsAsErrors=true` on CI. +## Releasing +1. Bump `` in `CodeStyle/CodeStyle.csproj` and add a changelog entry. +2. Merge to `main`, then create and push a tag matching the version (e.g. `1.2.0`). +3. The [Publish Release Packages](.github/workflows/publish-release.yml) workflow packs + and pushes the package to nuget.org via trusted publishing. + ## Credits The `Polyadic.CodeStyle` package started as a direct copy of [`Messerli.CodeStyle`](https://github.com/messerli-informatik-ag/code-style), licensed under either Apache 2.0 or MIT. diff --git a/changelog.md b/changelog.md index 01d7453..0187d77 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,23 @@ # Changelog +## 1.2.0 +* Update `StyleCop.Analyzers` from 1.2.0-beta.556 to 1.3.149-beta. \ + See their [Release Notes](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/releases) for details. Highlights: + * Support for C# 8 through C# 15 syntax, including records, primary constructors, collection expressions, + the `field` keyword and C# 14 extension blocks. Rules used to skip these constructs, so expect new diagnostics. + * `SA1600` no longer treats extension blocks as private, so their public members must be documented. + * `SA1407` now covers bitwise and unsigned shift operators, `SA1408` now covers `??` mixed with `&&`/`||`. + * `SA1017` now requires a space after a parameter attribute list, e.g. `[NotNullWhen(true)] out string? foo`. + * Code fixes for `SA1201`–`SA1204` and `SA1214` (member ordering) are now enabled. + * All settings can now be configured via `.editorconfig` in addition to `stylecop.json`. +* Enable new StyleCop rules as errors: + * `SA1143`: Conditional expressions must be formatted consistently. + * `SA1315`: Parameter names must match inherited names. + * `SA1317`: Identifiers must use Latin letters. + * `SA1653`: Only one part of a partial type may have a ``. + * `SA1654`: Use `{T}` rather than escaped `<T>` in `cref` attributes. +* `SX1412` (UTF-8 without BOM) is listed but disabled, like `SA1412`. +* Update `Microsoft.Build.NoTargets` SDK from 3.7.56 to 3.7.134. + ## 1.1.0 * Disallow packing without enabling `ContinuousIntegrationBuild`. * Update `IDisposableAnalyzers` from 4.0.2 to 4.0.8. \ diff --git a/global.json b/global.json index 71cf3fc..278ef4b 100644 --- a/global.json +++ b/global.json @@ -4,6 +4,6 @@ "rollForward": "feature" }, "msbuild-sdks": { - "Microsoft.Build.NoTargets": "3.7.56" + "Microsoft.Build.NoTargets": "3.7.134" } }