@govbr-ds/release-config 4.6.1 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -16
- package/package.json +10 -5
- package/src/index.js +31 -46
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
# GovBR-DS - Config
|
|
1
|
+
# GovBR-DS - Release Config
|
|
2
2
|
|
|
3
3
|
## Objetivo
|
|
4
4
|
|
|
5
|
-
Compartilhar
|
|
5
|
+
Compartilhar a política de versionamento, changelog e publicação entre os projetos do [GovBR-DS](https://gitlab.com/govbr-ds 'GovBR-DS').
|
|
6
|
+
|
|
7
|
+
O pacote fornece a configuração comum do Semantic Release. Ele não executa comandos específicos de Nx, não escolhe o registry do consumidor e não publica mensagens em serviços externos por conta própria.
|
|
6
8
|
|
|
7
9
|
## Como instalar
|
|
8
10
|
|
|
@@ -16,25 +18,94 @@ Configurações para o [Semantic Release](https://github.com/semantic-release/se
|
|
|
16
18
|
|
|
17
19
|
## Como configurar
|
|
18
20
|
|
|
19
|
-
1. Crie um arquivo `release.config.js` na raiz do seu projeto e importe
|
|
21
|
+
1. Crie um arquivo `release.config.js` na raiz do seu projeto e importe a configuração base:
|
|
20
22
|
|
|
21
23
|
```javascript
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
import releaseConfig from '@govbr-ds/release-config'
|
|
25
|
+
|
|
26
|
+
export default releaseConfig
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Para adicionar ou sobrescrever alguma configuração, crie uma cópia da configuração base:
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
import releaseConfig from '@govbr-ds/release-config'
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
...releaseConfig,
|
|
36
|
+
plugins: [...releaseConfig.plugins, '@semantic-release/npm'],
|
|
34
37
|
}
|
|
35
38
|
```
|
|
36
39
|
|
|
37
|
-
Para
|
|
40
|
+
Para configurações específicas de monorepos Nx, componha os plugins base com o fluxo Nx no projeto consumidor. A configuração publicada não executa comandos Nx por conta própria.
|
|
41
|
+
|
|
42
|
+
A ordem dos plugins define a ordem de execução dentro de cada etapa do [Semantic Release](https://github.com/semantic-release/semantic-release).
|
|
43
|
+
|
|
44
|
+
## Política de versionamento
|
|
45
|
+
|
|
46
|
+
O Semantic Release calcula a próxima versão a partir dos commits desde a última tag:
|
|
47
|
+
|
|
48
|
+
| Tipo | Uso | Versão padrão |
|
|
49
|
+
| ---------- | -------------------------------------------------- | ------------- |
|
|
50
|
+
| `feat` | Nova capacidade compatível com a API existente | `minor` |
|
|
51
|
+
| `fix` | Correção de comportamento | `patch` |
|
|
52
|
+
| `docs` | Atualização de documentação ou exemplos | `patch` |
|
|
53
|
+
| `perf` | Melhoria de desempenho sem quebra de API | `patch` |
|
|
54
|
+
| `refactor` | Reorganização interna sem mudança de comportamento | `patch` |
|
|
55
|
+
| `removed` | Remoção de API ou recurso público | `major` |
|
|
56
|
+
| `revert` | Reversão de uma mudança publicada | `minor` |
|
|
57
|
+
|
|
58
|
+
Os tipos `build`, `chore`, `ci`, `lint`, `ops`, `test`, `wip` e `site` são aceitos para manter o histórico consistente, mas não geram release automaticamente. `deprecated` aparece no changelog, porém também não gera versão por si só.
|
|
59
|
+
|
|
60
|
+
Uma mudança incompatível deve ser marcada como breaking change. Ela gera `major` independentemente do tipo:
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
feat(api)!: alterar contrato de autenticação
|
|
64
|
+
|
|
65
|
+
BREAKING CHANGE: o campo token agora é obrigatório e precisa ser enviado no cabeçalho Authorization.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
O escopo identifica a área alterada, não o impacto da versão:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
fix(button): corrigir foco após o clique
|
|
72
|
+
feat(tokens): adicionar cor semântica de informação
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Não use `minor` ou `patch` como escopo para forçar uma versão. O impacto deve ser expresso pelo tipo ou por uma breaking change.
|
|
76
|
+
|
|
77
|
+
## Estrutura para monorepos Nx
|
|
78
|
+
|
|
79
|
+
O pacote exporta `basePlugins` para que o projeto consumidor acrescente seu próprio fluxo de preparação e publicação:
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { basePlugins, branches } from '@govbr-ds/release-config'
|
|
83
|
+
|
|
84
|
+
export default {
|
|
85
|
+
branches,
|
|
86
|
+
plugins: [
|
|
87
|
+
...basePlugins,
|
|
88
|
+
// Plugins específicos do monorepo entram aqui.
|
|
89
|
+
],
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Isso mantém a configuração publicada independente de Nx e evita que um projeto simples instale ou execute ferramentas que não utiliza.
|
|
94
|
+
|
|
95
|
+
## Validação local
|
|
96
|
+
|
|
97
|
+
Antes de publicar uma release, valide a configuração sem executar `prepare`, `publish` ou notificações:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pnpm exec semantic-release --dry-run
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
No CI, use o lockfile congelado e a versão instalada no projeto:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pnpm install --frozen-lockfile
|
|
107
|
+
pnpm exec semantic-release
|
|
108
|
+
```
|
|
38
109
|
|
|
39
110
|
## Method Date.prototype.toString called on incompatible receiver
|
|
40
111
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@govbr-ds/release-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Configuração compartilhada do semantic-release para projetos do GovBR-DS",
|
|
6
6
|
"keywords": [
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"author": "SERPRO (http://serpro.gov.br/)",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
21
24
|
"type": "module",
|
|
22
25
|
"exports": "./src/index.js",
|
|
23
26
|
"main": "./src/index.js",
|
|
@@ -25,10 +28,12 @@
|
|
|
25
28
|
"src"
|
|
26
29
|
],
|
|
27
30
|
"dependencies": {
|
|
28
|
-
"@
|
|
31
|
+
"@govbr-ds/commit-types": "5.0.1",
|
|
32
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
29
33
|
"@semantic-release/git": "^10.0.1",
|
|
30
|
-
"@semantic-release/gitlab": "^13.
|
|
31
|
-
"
|
|
32
|
-
"
|
|
34
|
+
"@semantic-release/gitlab": "^13.3.3",
|
|
35
|
+
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
36
|
+
"conventional-changelog-conventionalcommits": "10.2.1",
|
|
37
|
+
"semantic-release": "^25.0.7"
|
|
33
38
|
}
|
|
34
39
|
}
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import commitTypesModule from '@govbr-ds/commit-types'
|
|
2
|
+
|
|
3
|
+
const { commitTypes } = commitTypesModule
|
|
4
|
+
|
|
5
|
+
// Branches that receive stable releases, maintenance releases or prereleases.
|
|
6
|
+
// Keep this list aligned with the branches protected by the consumer's CI.
|
|
1
7
|
const branches = [
|
|
2
8
|
'main',
|
|
3
9
|
'+([0-9])?(.{+([0-9]),x}).x', //1.x.x
|
|
@@ -11,54 +17,32 @@ const branches = [
|
|
|
11
17
|
// { name: 'rc', prerelease: true },
|
|
12
18
|
]
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{ type: 'ci', hidden: true },
|
|
27
|
-
{ type: 'lint', hidden: true },
|
|
28
|
-
{ type: 'test', hidden: true },
|
|
29
|
-
{ type: 'wip', hidden: true },
|
|
30
|
-
{ type: 'site', hidden: true },
|
|
31
|
-
{ type: 'bump', section: '🆙 Bump' },
|
|
32
|
-
]
|
|
20
|
+
// Types shown in generated changelogs. Types marked as hidden remain valid in
|
|
21
|
+
// commits but are omitted from release notes because they are implementation
|
|
22
|
+
// or maintenance details.
|
|
23
|
+
const types = commitTypes.map(({ value, changelog }) => ({
|
|
24
|
+
type: value,
|
|
25
|
+
...(changelog ? { section: changelog.title } : { hidden: true }),
|
|
26
|
+
}))
|
|
27
|
+
|
|
28
|
+
const releaseRules = commitTypes.map(({ value, semverBump }) => ({
|
|
29
|
+
type: value,
|
|
30
|
+
release: semverBump === 'none' ? false : semverBump,
|
|
31
|
+
}))
|
|
33
32
|
|
|
34
33
|
const commitAnalyzer = [
|
|
35
34
|
'@semantic-release/commit-analyzer',
|
|
36
35
|
{
|
|
37
36
|
preset: 'conventionalcommits',
|
|
38
37
|
releaseRules: [
|
|
38
|
+
// Uma mudança incompatível (breaking change) sempre tem prioridade sobre o tipo do commit e gera uma versão major.
|
|
39
39
|
{ breaking: true, release: 'major' },
|
|
40
|
-
{
|
|
40
|
+
{ type: '*!', release: 'major' },
|
|
41
|
+
// Estes escopos são exclusões explícitas para alterações que não devem gerar publicação.
|
|
41
42
|
{ scope: 'monorepo', release: false },
|
|
42
43
|
{ scope: 'no-release', release: false },
|
|
43
|
-
{ scope: 'patch', release: 'patch' },
|
|
44
44
|
{ scope: 'site', release: false },
|
|
45
|
-
|
|
46
|
-
{ type: 'build', release: false },
|
|
47
|
-
{ type: 'bump', release: 'minor' },
|
|
48
|
-
{ type: 'chore', release: false },
|
|
49
|
-
{ type: 'ci', release: false },
|
|
50
|
-
{ type: 'deprecated', release: false },
|
|
51
|
-
{ type: 'docs', release: 'patch' },
|
|
52
|
-
{ type: 'feat', release: 'minor' },
|
|
53
|
-
{ type: 'fix', release: 'patch' },
|
|
54
|
-
{ type: 'lint', release: false },
|
|
55
|
-
{ type: 'ops', release: false },
|
|
56
|
-
{ type: 'perf', release: 'patch' },
|
|
57
|
-
{ type: 'refactor', release: 'patch' },
|
|
58
|
-
{ type: 'removed', release: 'minor' },
|
|
59
|
-
{ type: 'revert', release: 'minor' },
|
|
60
|
-
{ type: 'test', release: false },
|
|
61
|
-
{ type: 'wip', release: false },
|
|
45
|
+
...releaseRules,
|
|
62
46
|
],
|
|
63
47
|
parserOpts: {
|
|
64
48
|
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'],
|
|
@@ -173,13 +157,6 @@ const releaseNotesGenerator = [
|
|
|
173
157
|
},
|
|
174
158
|
]
|
|
175
159
|
|
|
176
|
-
const changelog = [
|
|
177
|
-
'@semantic-release/changelog',
|
|
178
|
-
{
|
|
179
|
-
changelogTitle: '# CHANGELOG',
|
|
180
|
-
},
|
|
181
|
-
]
|
|
182
|
-
|
|
183
160
|
const gitlab = [
|
|
184
161
|
'@semantic-release/gitlab',
|
|
185
162
|
{
|
|
@@ -201,4 +178,12 @@ const git = [
|
|
|
201
178
|
},
|
|
202
179
|
]
|
|
203
180
|
|
|
204
|
-
|
|
181
|
+
const basePlugins = [commitAnalyzer, releaseNotesGenerator, gitlab]
|
|
182
|
+
|
|
183
|
+
const releaseConfig = {
|
|
184
|
+
branches,
|
|
185
|
+
plugins: [...basePlugins, git],
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { basePlugins, branches, commitAnalyzer, git, gitlab, releaseConfig, releaseNotesGenerator }
|
|
189
|
+
export default releaseConfig
|