Skip to content

Commit 07d1acc

Browse files
feat: conventional commits semantic release
Feat/conventional commits semantic release
2 parents 4222d38 + 10893f3 commit 07d1acc

9 files changed

Lines changed: 140 additions & 10 deletions

File tree

.github/hooks/commit-msg

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to check the commit log message.
4+
# Called by "git commit" with one argument, the name of the file
5+
# that has the commit message. The hook should exit with non-zero
6+
# status after issuing an appropriate message if it wants to stop the
7+
# commit. The hook is allowed to edit the commit message file.
8+
#
9+
# To enable this hook, rename this file to "commit-msg".
10+
11+
# Uncomment the below to add a Signed-off-by line to the message.
12+
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
13+
# hook is more suited to it.
14+
#
15+
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
16+
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
17+
18+
# This example catches duplicate Signed-off-by lines.
19+
20+
test "" = "$(grep '^Signed-off-by: ' "$1" |
21+
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
22+
echo >&2 Duplicate Signed-off-by lines.
23+
exit 1
24+
}
25+
if ! head -1 "$1" | grep -qE "^(feat|fix|ci|chore|docs|test|style|refactor|chk)(\(.+?\))?: .{1,}$"; then
26+
echo "Aborting commit. Your commit message is invalid. See some examples below:" >&2
27+
echo "feat(logging): added logs for failed signups" >&2
28+
echo "fix(homepage): fixed image gallery" >&2
29+
echo "test(homepage): updated tests" >&2
30+
echo "docs(readme): added new logging table information" >&2
31+
echo "For more information check https://www.conventionalcommits.org/en/v1.0.0/ for more details" >&2
32+
exit 1
33+
fi
34+
if ! head -1 "$1" | grep -qE "^.{1,50}$"; then
35+
echo "Aborting commit. Your commit message is too long." >&2
36+
exit 1
37+
fi

.github/workflows/dotnet.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: NetDevPack Brasil - MASTER Deploy
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
types: [closed]
7+
branches: [ master ]
8+
9+
env:
10+
REPOSITORY_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
11+
CURRENT_REPO_URL: https://github.com/${{ github.repository }}
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v1
23+
with:
24+
dotnet-version: 5.0.x
25+
26+
- name: Restore dependencies
27+
run: dotnet restore
28+
29+
- name: Build
30+
run: dotnet build --no-restore
31+
32+
- name: Test
33+
run: dotnet test
34+
35+
- name: Semantic Release
36+
id: semantic
37+
uses: cycjimmy/semantic-release-action@v2
38+
with:
39+
semantic_version: 17.4.4
40+
extra_plugins: |
41+
@semantic-release/changelog
42+
@semantic-release/github
43+
@semantic-release/git
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Generate Package
48+
run: dotnet pack -c Release -o out -p:PackageVersion=${{ steps.semantic.outputs.new_release_version }} -p:RepositoryUrl=${{env.CURRENT_REPO_URL}}
49+
50+
- name: Publish the package to nuget.org
51+
run: dotnet nuget push ./out/*.nupkg --skip-duplicate --no-symbols true -k ${{ secrets.NUGET_AUTH_TOKEN}} -s https://api.nuget.org/v3/index.json

.github/workflows/pull-request.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: NetDevPack Brasil - MASTER PR
2+
on:
3+
pull_request:
4+
branches: [ master ]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Setup .NET
13+
uses: actions/setup-dotnet@v1
14+
with:
15+
dotnet-version: 5.0.x
16+
17+
- name: Restore dependencies
18+
run: dotnet restore
19+
20+
- name: Build
21+
run: dotnet build --no-restore
22+
23+
- name: Test
24+
run: dotnet test --no-build --verbosity normal

.releaserc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"branches": ["master"],
3+
4+
"plugins": [
5+
"@semantic-release/commit-analyzer",
6+
"@semantic-release/release-notes-generator",
7+
"@semantic-release/changelog",
8+
"@semantic-release/github",
9+
"@semantic-release/git"
10+
]
11+
}

src/NetDevPack.Brasil/Documentos/CNPJ.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
1+
using NetDevPack.Brasil.Documentos.Validacao;
22
using NetDevPack.Domain;
33
using NetDevPack.Utilities;
4-
using NetDevPack.Brasil.Documentos.Validacao;
4+
using System;
55

66
namespace NetDevPack.Brasil.Documentos
77
{
@@ -12,7 +12,7 @@ public class Cnpj
1212
public Cnpj(string numero)
1313
{
1414
Numero = numero.OnlyNumbers(numero);
15-
if (!EstaValido()) throw new DomainException("CNPJ Inválido");
15+
if (!EstaValido()) throw new DomainException("CNPJ Invalido");
1616
}
1717

1818
public override string ToString() => SemMascara();

src/NetDevPack.Brasil/Documentos/Cpf.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
1+
using NetDevPack.Brasil.Documentos.Validacao;
22
using NetDevPack.Domain;
33
using NetDevPack.Utilities;
4-
using NetDevPack.Brasil.Documentos.Validacao;
4+
using System;
55

66
namespace NetDevPack.Brasil.Documentos
77
{
@@ -12,7 +12,7 @@ public class Cpf
1212
public Cpf(string numero)
1313
{
1414
Numero = numero.OnlyNumbers(numero);
15-
if (!EstaValido()) throw new DomainException("CPF Inválido");
15+
if (!EstaValido()) throw new DomainException("CPF Invalido");
1616
}
1717

1818
public override string ToString() => SemMascara();

src/NetDevPack.Brasil/NetDevPack.Brasil.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@
2929
</None>
3030
</ItemGroup>
3131

32+
<Target Name="CopyHook" AfterTargets="AfterBuild" Condition=" '$(Configuration)' == 'Debug' ">
33+
<ItemGroup>
34+
<_CustomFiles Include="../../.github/hooks/commit-msg" />
35+
</ItemGroup>
36+
<Copy SourceFiles="@(_CustomFiles)" DestinationFolder="../../../.git/hooks" />
37+
</Target>
38+
3239
</Project>

tests/NetDevPack.Brasil.Tests/Documentos/CnpjValidadorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void Cnpj_PossuiDigitosRepetidos_ShouldReturnDomainException(string value
2727
Action act = () => new Cnpj(value);
2828

2929
// Assert
30-
act.Should().ThrowExactly<DomainException>().WithMessage("CNPJ Inválido");
30+
act.Should().ThrowExactly<DomainException>().WithMessage("CNPJ Invalido");
3131
}
3232

3333
[Fact(DisplayName = "Cnpj ReturnTrue")]
@@ -38,7 +38,7 @@ public void Cnpj_NewCnpj_ShouldReturnNewCnpj()
3838
var cnpj = new Cnpj("30.221.805/0001-26");
3939

4040
// Act
41-
var result = new CnpjValidador(cnpj.Numero).EstaValido();
41+
var result = new CnpjValidador(cnpj.Numero).EstaValido();
4242

4343
// Assert
4444
result.Should().BeTrue();

tests/NetDevPack.Brasil.Tests/Documentos/CpfValidadorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void Cpf_PossuiDigitosRepetidos_ShouldReturnDomainException(string value)
2727
Action act = () => new Cpf(value);
2828

2929
// Assert
30-
act.Should().ThrowExactly<DomainException>().WithMessage("CPF Inválido");
30+
act.Should().ThrowExactly<DomainException>().WithMessage("CPF Invalido");
3131
}
3232

3333
[Fact(DisplayName = "Cpf ReturnTrue")]
@@ -38,7 +38,7 @@ public void Cpf_NewCpf_ShouldReturnNewCpf()
3838
var cpf = new Cpf("915.212.540-87");
3939

4040
// Act
41-
var result = new CpfValidador(cpf.Numero).EstaValido();
41+
var result = new CpfValidador(cpf.Numero).EstaValido();
4242

4343
// Assert
4444
result.Should().BeTrue();

0 commit comments

Comments
 (0)