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

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

[*.{cs,csproj,props,targets,sln}]
charset = utf-8-bom

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

[*.md]
trim_trailing_whitespace = false
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
updates:
- package-ecosystem: nuget
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 10
commit-message:
prefix: chore
include: scope
groups:
tests:
patterns: ["xunit*", "AwesomeAssertions"]
ignore:
# Never reintroduce FluentAssertions (commercial license since v8)
- dependency-name: "FluentAssertions"

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
commit-message:
prefix: ci
105 changes: 49 additions & 56 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: NetDevPack Brasil - MASTER Deploy

on:
push:
branches: [ master ]
workflow_dispatch:
inputs:
version:
description: Existing release to publish again (e.g. 2.0.0). Builds tag v<version> and pushes it to nuget.org.
description: Existing release to publish again (e.g. 3.0.0). Builds tag v<version> and pushes it to nuget.org.
required: true

env:
REPOSITORY_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
CURRENT_REPO_URL: https://github.com/${{ github.repository }}

permissions:
Expand All @@ -23,66 +23,59 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.version && format('v{0}', inputs.version) || github.sha }}

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ inputs.version && format('v{0}', inputs.version) || github.sha }}

- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json

- name: Restore dependencies
run: dotnet restore
- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore
- name: Build
run: dotnet build --no-restore -c Release

- name: Test
run: dotnet test
- name: Test
run: dotnet test --no-build -c Release

- name: Semantic Release
id: semantic
if: github.event_name == 'push'
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Semantic Release
id: semantic
if: github.event_name == 'push'
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 24
extra_plugins: |
@semantic-release/changelog@6
@semantic-release/git@10
conventional-changelog-conventionalcommits@8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Resolve version
id: version
if: github.event_name == 'workflow_dispatch' || steps.semantic.outputs.new_release_published == 'true'
env:
VERSION: ${{ inputs.version || steps.semantic.outputs.new_release_version }}
run: |
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || { echo "::error::Invalid version '$VERSION'"; exit 1; }
echo "value=$VERSION" >> "$GITHUB_OUTPUT"
- name: Resolve version
id: version
if: github.event_name == 'workflow_dispatch' || steps.semantic.outputs.new_release_published == 'true'
env:
VERSION: ${{ inputs.version || steps.semantic.outputs.new_release_version }}
run: |
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || { echo "::error::Invalid version '$VERSION'"; exit 1; }
echo "value=$VERSION" >> "$GITHUB_OUTPUT"

- name: Generate Package
if: steps.version.outputs.value != ''
run: dotnet pack -c Release -o out -p:PackageVersion=${{ steps.version.outputs.value }} -p:RepositoryUrl=${{env.CURRENT_REPO_URL}}
- name: Generate Package
if: steps.version.outputs.value != ''
run: dotnet pack src/NetDevPack.Brasil/NetDevPack.Brasil.csproj -c Release -o out -p:PackageVersion=${{ steps.version.outputs.value }} -p:RepositoryUrl=${{ env.CURRENT_REPO_URL }}

- name: NuGet login (trusted publishing)
id: nuget
if: steps.version.outputs.value != ''
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}
- name: NuGet login (trusted publishing)
id: nuget
if: steps.version.outputs.value != ''
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}

- name: Publish the package to nuget.org
if: steps.version.outputs.value != ''
run: dotnet nuget push ./out/*.nupkg --skip-duplicate -n -d -k ${{ steps.nuget.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: Publish the package to nuget.org
if: steps.version.outputs.value != ''
run: dotnet nuget push ./out/*.nupkg --skip-duplicate -k ${{ steps.nuget.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
43 changes: 22 additions & 21 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
name: NetDevPack Brasil - MASTER PR

on:
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
pull-request:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json

- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore

- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release

- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build -c Release

- name: Test
run: dotnet test --no-build --verbosity normal
- name: Check vulnerable packages
run: |
dotnet list package --vulnerable --include-transitive 2>&1 | tee vulnerable.txt
! grep -q "has the following vulnerable packages" vulnerable.txt
31 changes: 21 additions & 10 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
{
"branches": ["master"],

"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/github",
"@semantic-release/git"
]
}
"branches": [
"master"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/changelog",
"@semantic-release/github",
"@semantic-release/git"
]
}
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<!-- Shared settings for every project under this repository -->
<PropertyGroup>
<LangVersion>latest</LangVersion>
<!-- Fail the build when a dependency has a known vulnerability (NuGet Audit) -->
<NuGetAudit>true</NuGetAudit>
<NuGetAuditMode>all</NuGetAuditMode>
<WarningsAsErrors>$(WarningsAsErrors);NU1901;NU1902;NU1903;NU1904</WarningsAsErrors>
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>
</Project>
17 changes: 17 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project>
<!--
Central Package Management: every version lives here, csproj files only declare <PackageReference Include="..." />.
-->
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="NetDevPack" Version="9.0.0" />

<!-- Tests -->
<PackageVersion Include="AwesomeAssertions" Version="9.6.0" />
<PackageVersion Include="xunit.v3" Version="4.0.3" />
</ItemGroup>
</Project>
59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@

<img src="https://repository-images.githubusercontent.com/269783213/ded11000-a765-11ea-8590-6ed700685675" alt=".NET DevPack" width="300px" />

What is the .NET DevPack?
O que é o .NET DevPack Brasil?
=====================
A smart set of common classes and implementations to improve your development productivity.
Uma coleção de utilidades para o Brasil: documentos nacionais (CPF, CNPJ, Título de Eleitor) e CEP, com validação e formatação. Foi feito para ser usado junto com o [NetDevPack](https://github.com/NetDevPack/NetDevPack).

## Give a Star! :star:
If you liked the project or if NetDevPack helped you, please give a star ;)
## Dê uma estrela! :star:
Se você gostou do projeto ou se o NetDevPack te ajudou, deixe uma estrela ;)

## Get Started
.NET DevPack can be installed using the Nuget package manager or the `dotnet` CLI.
## Como começar

```
dotnet add package NetDevPack
dotnet add package NetDevPack.Brasil
```

For ASP.NET Core Identity Pack:
```
dotnet add package NetDevPack.Identity
```
| Pacote | Versão | Downloads |
| ------ | ------ | --------- |
| `NetDevPack.Brasil` | [![NuGet](https://img.shields.io/nuget/v/NetDevPack.Brasil.svg)](https://nuget.org/packages/NetDevPack.Brasil) | [![Nuget](https://img.shields.io/nuget/dt/NetDevPack.Brasil.svg)](https://nuget.org/packages/NetDevPack.Brasil) |

### Compatibilidade

---
| Versão | Target framework | NetDevPack |
| ------ | ---------------- | ---------- |
| 3.x | .NET 10 (LTS) | 9.x |
| 2.x | .NET Standard 2.1, .NET 8, 9 e 10 | 8.x |

| Package | Version | Popularity |
| ------- | ----- | ----- |
| `NetDevPack` | [![NuGet](https://img.shields.io/nuget/v/NetDevPack.svg)](https://nuget.org/packages/NetDevPack) | [![Nuget](https://img.shields.io/nuget/dt/NetDevPack.svg)](https://nuget.org/packages/NetDevPack) |
| `NetDevPack.Identity` | [![NuGet](https://img.shields.io/nuget/v/NetDevPack.Identity.svg)](https://nuget.org/packages/NetDevPack.Identity) | [![Nuget](https://img.shields.io/nuget/dt/NetDevPack.Identity.svg)](https://nuget.org/packages/NetDevPack.Identity)
| `NetDevPackBr` | [![NuGet](https://img.shields.io/nuget/v/NetDevPackBr.svg)](https://nuget.org/packages/NetDevPackBr) | [![Nuget](https://img.shields.io/nuget/dt/NetDevPackBr.svg)](https://nuget.org/packages/NetDevPackBr)
## Exemplos

Os construtores validam o valor e lançam `NetDevPack.Domain.DomainException` quando ele é inválido. Máscara e caracteres não numéricos são ignorados.

### Examples
- Coming soon.
```csharp
using NetDevPack.Brasil.Documentos;
using NetDevPack.Brasil.Localizacao;

### Documentation
var cpf = new Cpf("915.212.540-87");
cpf.SemMascara(); // "91521254087"
cpf.ComMascara(); // "915.212.540-87"

- Coming soon.
var cnpj = new Cnpj("11.444.777/0001-61");
cnpj.ComMascara(); // "11.444.777/0001-61"

var titulo = new TituloEleitor("1023 8501 0671");

var cep = new Cep("01310-100");
cep.EstaValido(); // true
cep.ComMascara(); // "01310-100"
```

Também dá para validar sem criar o objeto, com `CpfValidador`, `CnpjValidador` e `TituloEleitorValidator` (namespace `NetDevPack.Brasil.Documentos.Validacao`) e `CepValidador` (`NetDevPack.Brasil.Localizacao.Validacao`).

## About
.NET DevPack was developed by [Eduardo Pires](http://eduardopires.net.br) under the [MIT license](LICENSE).
## Sobre
O .NET DevPack Brasil foi desenvolvido por [Eduardo Pires](http://eduardopires.net.br) sob a [licença MIT](LICENSE).
9 changes: 9 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestFeature"
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
Loading
Loading