mirror of
https://github.com/ivuorinen/actions.git
synced 2026-01-30 19:40:46 +00:00
Replace language-version-detect dependency with inline version detection
for all three C# actions (csharp-build, csharp-lint-check, csharp-publish).
Detection logic checks (in priority order):
- .tool-versions file (dotnet key)
- Dockerfile (FROM dotnet: image)
- devcontainer.json (dotnet: image)
- global.json (.sdk.version field)
Implementation details:
- POSIX sh compliant with `set -eu`
- Validates version format: X, X.Y, or X.Y.Z
- Normalizes versions: strips 'v' prefix, whitespace, line endings
- Uses `sed -E` for portable extended regex
- Conditional jq usage with diagnostic messages
- Maintains output contract (detected-version)
Fixed issues from code review:
- devcontainer.json sed regex: malformed wildcard ('. */' → '.*')
- Dockerfile sed regex: removed unintended leading space (' \1' → '\1')
- Added stderr diagnostics when jq is not found
- Applied fixes to all three actions for consistency
Changes:
- csharp-build: ~100 lines of inline detection + jq diagnostics
- csharp-lint-check: ~100 lines of inline detection + jq diagnostics
- csharp-publish: ~100 lines of inline detection + jq diagnostics
- All READMEs regenerated with action-docs
Benefits:
- Eliminates external dependency for .NET version detection
- Reduces action initialization time
- Improved debugging (diagnostic messages, all logic in one file)
- Consistent with go-build pattern
ivuorinen/actions/csharp-lint-check
C# Lint Check
Description
Runs linters like StyleCop or dotnet-format for C# code style checks.
Inputs
| name | description | required | default |
|---|---|---|---|
dotnet-version |
Version of .NET SDK to use. |
false |
"" |
token |
GitHub token for authentication |
false |
"" |
Outputs
| name | description |
|---|---|
lint_status |
Overall lint status (success/failure) |
errors_count |
Number of formatting errors found |
warnings_count |
Number of formatting warnings found |
Runs
This action is a composite action.
Usage
- uses: ivuorinen/actions/csharp-lint-check@main
with:
dotnet-version:
# Version of .NET SDK to use.
#
# Required: false
# Default: ""
token:
# GitHub token for authentication
#
# Required: false
# Default: ""