mirror of
https://github.com/ivuorinen/actions.git
synced 2026-01-30 10:40:41 +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-build
C# Build
Description
Builds and tests C# projects.
Inputs
| name | description | required | default |
|---|---|---|---|
dotnet-version |
Version of .NET SDK to use. |
false |
"" |
max-retries |
Maximum number of retry attempts for dotnet restore operations |
false |
3 |
token |
GitHub token for authentication |
false |
"" |
Outputs
| name | description |
|---|---|
build_status |
Build completion status (success/failure) |
test_status |
Test execution status (success/failure/skipped) |
dotnet_version |
Version of .NET SDK used |
artifacts_path |
Path to build artifacts |
test_results_path |
Path to test results |
Runs
This action is a composite action.
Usage
- uses: ivuorinen/actions/csharp-build@main
with:
dotnet-version:
# Version of .NET SDK to use.
#
# Required: false
# Default: ""
max-retries:
# Maximum number of retry attempts for dotnet restore operations
#
# Required: false
# Default: 3
token:
# GitHub token for authentication
#
# Required: false
# Default: ""