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
46 changes: 46 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -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:.*<Version>\(.*\)</Version>.*:\1:p' CodeStyle/CodeStyle.csproj)"
if [ "$version" != "${{github.ref_name}}" ]; then
echo "::error::Tag '${{github.ref_name}}' does not match <Version>$version</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/*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/artifacts/

/.vs/
4 changes: 2 additions & 2 deletions CodeStyle/CodeStyle.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<Version>1.1.0</Version>
<Version>1.2.0</Version>
<PackageId>Polyadic.CodeStyle</PackageId>
<PackageTags>analyzers</PackageTags>
<Description>Various analyzers bundled with opinionated configuration</Description>
Expand All @@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IDisposableAnalyzers" Version="4.0.8" PrivateAssets="none" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="none" />
<PackageReference Include="StyleCop.Analyzers" Version="1.3.149-beta" PrivateAssets="none" />
</ItemGroup>
<ItemGroup>
<None Include="build\**\*" Pack="true" PackagePath="%(Identity)" />
Expand Down
6 changes: 6 additions & 0 deletions CodeStyle/build/StyleCop.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<Rule Id="SA1139" Action="Error" /><!-- UseLiteralsSuffixNotationInsteadOfCasting -->
<Rule Id="SA1141" Action="Error" /><!-- UseTupleSyntax -->
<Rule Id="SA1142" Action="Error" /><!-- ReferToTupleElementsByName -->
<Rule Id="SA1143" Action="Error" /><!-- ConditionalExpressionsMustBeFormattedConsistently -->

<!-- Ordering Rules -->
<Rule Id="SA1200" Action="Error" /><!-- UsingDirectivesMustBePlacedCorrectly -->
Expand Down Expand Up @@ -114,7 +115,9 @@
<Rule Id="SA1312" Action="Error" /><!-- VariableNamesMustBeginWithLowerCaseLetter -->
<Rule Id="SA1313" Action="Error" /><!-- ParameterNamesMustBeginWithLowerCaseLetter -->
<Rule Id="SA1314" Action="Error" /><!-- TypeParameterNamesMustBeginWithT -->
<Rule Id="SA1315" Action="Error" /><!-- ParameterNamesMustMatchInheritedNames -->
<Rule Id="SA1316" Action="Error" /><!-- TupleElementNamesShouldUseCorrectCasing -->
<Rule Id="SA1317" Action="Error" /><!-- IdentifiersMustUseLatinLetters -->

<!-- Maintainability Rules -->
<Rule Id="SA1119" Action="None" /><!-- StatementMustNotUseUnnecessaryParenthesis -->
Expand Down Expand Up @@ -211,10 +214,13 @@
<Rule Id="SA1650" Action="None" /><!-- ElementDocumentationMustBeSpelledCorrectly (Removed rule) -->
<Rule Id="SA1651" Action="Error" /><!-- DoNotUsePlaceholderElements -->
<Rule Id="SA1652" Action="None" /><!-- EnableXmlDocumentationOutput (Removed rule) -->
<Rule Id="SA1653" Action="Error" /><!-- PartialTypesMustHaveOnlyOneSummary -->
<Rule Id="SA1654" Action="Error" /><!-- UseGenericBracesInCref -->

<!-- Alternative Rules -->
<Rule Id="SX1101" Action="Error" /><!-- DoNotPrefixLocalMembersWithThis -->
<Rule Id="SX1309" Action="Error" /><!-- FieldNamesMustBeginWithUnderscore -->
<Rule Id="SX1309S" Action="Error" /><!-- StaticFieldNamesMustBeginWithUnderscore -->
<Rule Id="SX1412" Action="None" /><!-- StoreFilesAsUtf8WithoutBom (opt-in alternative to SA1412) -->
</Rules>
</RuleSet>
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<Version>` 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.
Expand Down
19 changes: 19 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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 `<summary>`.
* `SA1654`: Use `{T}` rather than escaped `&lt;T&gt;` 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. \
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"rollForward": "feature"
},
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.7.56"
"Microsoft.Build.NoTargets": "3.7.134"
}
}
Loading