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

[*]
charset = utf-8
end_of_line = crlf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.{cs,csx}]
indent_size = 4
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false

# C# code style
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_prefer_braces = true:suggestion
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_properties = true:suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = file_scoped:suggestion

# Naming conventions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
dotnet_naming_style.camel_case_style.capitalization = camel_case
dotnet_naming_style.underscore_camel_style.required_prefix = _
dotnet_naming_style.underscore_camel_style.capitalization = camel_case

dotnet_naming_rule.private_fields_should_be_underscore_camel.severity = suggestion
dotnet_naming_rule.private_fields_should_be_underscore_camel.symbols = private_fields
dotnet_naming_rule.private_fields_should_be_underscore_camel.style = underscore_camel_style

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

[*.{xml,csproj,props,targets,config,nuspec}]
indent_size = 2

[*.{json,yaml,yml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.{sh,bash}]
end_of_line = lf

[Makefile]
indent_style = tab
45 changes: 45 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Auto detect text files and perform LF normalization
* text=auto eol=crlf

# Source files
*.cs text eol=crlf diff=csharp
*.vb text eol=crlf
*.csproj text eol=crlf
*.sln text eol=crlf
*.props text eol=crlf
*.targets text eol=crlf
*.config text eol=crlf
*.json text eol=crlf
*.xml text eol=crlf
*.yaml text eol=crlf
*.yml text eol=crlf
*.md text eol=crlf
*.txt text eol=crlf
*.csv text eol=crlf
*.editorconfig text eol=crlf
*.gitattributes text eol=crlf
*.gitignore text eol=crlf

# Shell scripts - keep LF
*.sh text eol=lf
*.bash text eol=lf

# Binary files
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.pdf binary
*.docx binary
*.doc binary
*.xls binary
*.xlsx binary
*.zip binary
*.7z binary
*.gz binary
*.nupkg binary
*.snupkg binary
*.dll binary
*.exe binary
*.pdb binary
83 changes: 83 additions & 0 deletions .github/WORKFLOWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# GitHub Actions Workflows

This repository uses GitHub Actions for CI/CD automation.

## Workflows

### 1. **CI** (`ci.yml`)
Runs on every push and pull request to `develop` and `master` branches.
- ✅ Builds the solution (.NET 9)
- ✅ Runs all unit tests
- ✅ Collects code coverage
- ✅ Uploads test results as artifacts

### 2. **CodeQL Security Scan** (`codeql.yml`)
Runs on push, pull request, and weekly schedule (Monday 03:00 UTC).
- 🔒 Analyzes C# code for security vulnerabilities
- 🔍 Detects code quality issues
- 📊 Uploads results to GitHub Security tab

### 3. **Publish to NuGet** (`nuget-publish.yml`)
Automatically publishes to NuGet.org when a new release is created.
- 📦 Extracts version from release tag (e.g., `v1.8.0`)
- 🔨 Builds and tests the library
- 📤 Publishes to NuGet.org
- 💾 Saves package as artifact

## Setup Instructions

### Required Secrets

To enable NuGet publishing, add the following secret to your repository:

1. Go to **Settings** → **Secrets and variables** → **Actions**
2. Click **New repository secret**
3. Add:
- **Name:** `NUGET_API_KEY`
- **Value:** Your NuGet API key from https://www.nuget.org/account/apikeys

### Creating a Release

To publish a new version to NuGet:

1. Update version in `src/FileConversionLibrary/FileConversionLibrary.csproj`
2. Commit and push changes
3. Create a new release on GitHub:
```bash
git tag v1.8.0
git push origin v1.8.0
```
4. Go to GitHub → **Releases** → **Draft a new release**
5. Choose the tag `v1.8.0`
6. Add release notes
7. Click **Publish release**

The `nuget-publish.yml` workflow will automatically:
- Extract version from the tag
- Build and test the project
- Publish to NuGet.org

### Manual Publishing

You can also trigger publishing manually:

1. Go to **Actions** → **Publish to NuGet**
2. Click **Run workflow**
3. Enter version (e.g., `1.8.0`)
4. Click **Run workflow**

## Status Badges

Add these to your README.md:

```markdown
[![CI](https://github.com/TheMysteriousStranger90/FileConversionLibrary/actions/workflows/ci.yml/badge.svg)](https://github.com/TheMysteriousStranger90/FileConversionLibrary/actions/workflows/ci.yml)
[![CodeQL](https://github.com/TheMysteriousStranger90/FileConversionLibrary/actions/workflows/codeql.yml/badge.svg)](https://github.com/TheMysteriousStranger90/FileConversionLibrary/actions/workflows/codeql.yml)
[![NuGet](https://img.shields.io/nuget/v/FileConversionLibrary.svg)](https://www.nuget.org/packages/FileConversionLibrary/)
```

## Requirements

- **.NET 9.0** SDK
- **Ubuntu latest** runner
- **NuGet API Key** (for publishing)
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]

jobs:
build-and-test:
name: Build & Test (.NET 9)
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Restore dependencies
run: dotnet restore FileConversionLibrary.sln

- name: Build (Release)
run: dotnet build FileConversionLibrary.sln -c Release --no-restore

- name: Run unit tests
run: |
dotnet test FileConversionLibrary.sln \
-c Release \
--no-build \
--logger "trx;LogFileName=test-results.trx" \
--results-directory ./TestResults \
--collect:"XPlat Code Coverage" \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: ./TestResults/*.trx
retention-days: 30

- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: ./TestResults/**/coverage.opencover.xml
retention-days: 30

- name: Build summary
if: always()
run: |
echo "### Build Summary :rocket:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **.NET Version:** 9.0" >> $GITHUB_STEP_SUMMARY
echo "- **Status:** ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
57 changes: 57 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CodeQL Security Scan

on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]
schedule:
# Run weekly on Monday at 03:00 UTC
- cron: '0 3 * * 1'

jobs:
analyze:
name: Analyze (C#)
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
security-events: write
actions: read
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: csharp
queries: security-and-quality

- name: Restore dependencies
run: dotnet restore FileConversionLibrary.sln

- name: Build for CodeQL analysis
run: dotnet build FileConversionLibrary.sln -c Release --no-restore

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:csharp"

- name: Security scan summary
if: always()
run: |
echo "### Security Scan Summary :shield:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Language:** C#" >> $GITHUB_STEP_SUMMARY
echo "- **Status:** ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
echo "- **Scan Date:** $(date -u +''%Y-%m-%d %H:%M UTC'')" >> $GITHUB_STEP_SUMMARY
52 changes: 0 additions & 52 deletions .github/workflows/dotnet.yml

This file was deleted.

Loading
Loading