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
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*.cs]
# File copyright headers are not required.
dotnet_diagnostic.SA1633.severity = none
# Match the project's file-scoped namespaces and modern C# conventions.
csharp_using_directive_placement = outside_namespace
# Qualification is unnecessary for unambiguous member access.
dotnet_diagnostic.SA1101.severity = none
csharp_preserve_single_line_blocks = false
csharp_preserve_single_line_statements = false

[tests/**/*.cs]
# Tests and the SDK test double are not a documented public API.
dotnet_diagnostic.CS1591.severity = none
dotnet_diagnostic.SA1600.severity = none
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: build
on:
push:
branches:
- main
pull_request:

concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- run: dotnet test -c Release
- run: dotnet pack src/SolutionExtender.Tool -c Release -o artifacts/packages
- uses: actions/upload-artifact@v4
with:
name: nuget-package
path: artifacts/packages/*.nupkg
94 changes: 94 additions & 0 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Publish NuGet

on:
push:
tags:
- 'v*'

permissions:
contents: read

concurrency:
group: nuget-publish-${{ github.ref }}
cancel-in-progress: false

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Check out release tag
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4

- name: Set up .NET 10
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
with:
dotnet-version: '10.0.x'

- name: Validate release version and publishing configuration
id: release
shell: bash
env:
RELEASE_TAG: ${{ github.ref_name }}
NUGET_USER: ${{ secrets.NUGET_USER }}
run: |
set -euo pipefail
if [[ -z "$NUGET_USER" ]]; then
echo '::error::Configure the NUGET_USER GitHub repository secret.'
exit 1
fi
# Canonical SemVer release or prerelease; reject NuGet normalization ambiguities.
version="${RELEASE_TAG#v}"
if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
echo "::error::Expected a tag such as v0.1.0 or v0.2.0-preview.1, got $RELEASE_TAG"
exit 1
fi
if [[ "$version" == *-* ]]; then
IFS='.' read -ra identifiers <<< "${version#*-}"
for identifier in "${identifiers[@]}"; do
if [[ "$identifier" =~ ^[0-9]+$ && "$identifier" != '0' && "$identifier" == 0* ]]; then
echo '::error::Numeric prerelease identifiers must not have leading zeros.'
exit 1
fi
done
fi
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Test release
env:
RELEASE_VERSION: ${{ steps.release.outputs.version }}
run: dotnet test SolutionExtender.slnx -c Release -p:Version="$RELEASE_VERSION"

- name: Pack release
env:
RELEASE_VERSION: ${{ steps.release.outputs.version }}
run: >-
dotnet pack src/SolutionExtender.Tool/SolutionExtender.Tool.csproj
-c Release --no-restore -o artifacts/packages
-p:Version="$RELEASE_VERSION" -p:ContinuousIntegrationBuild=true

- name: Preserve release package
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: SolutionExtender-${{ steps.release.outputs.version }}
path: artifacts/packages/*.nupkg
if-no-files-found: error

# Exchange GitHub OIDC for a short-lived, package-scoped API key.
# No long-lived NUGET_API_KEY secret is needed.
- name: Authenticate to NuGet using trusted publishing
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}

- name: Publish package
env:
RELEASE_VERSION: ${{ steps.release.outputs.version }}
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: >-
dotnet nuget push "artifacts/packages/SolutionExtender.$RELEASE_VERSION.nupkg"
--api-key "$NUGET_API_KEY"
--source https://api.nuget.org/v3/index.json
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/bin/
**/obj/
artifacts/
TestResults/
18 changes: 18 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Deterministic>true</Deterministic>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" />
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.138" PrivateAssets="All" />
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.17.0.82934" PrivateAssets="All" />
</ItemGroup>
</Project>
Loading
Loading