@govbr-ds/release-config 4.6.0 → 5.0.0

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.
Files changed (3) hide show
  1. package/README.md +87 -16
  2. package/package.json +10 -4
  3. package/src/index.js +32 -40
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # GovBR-DS - Config Tools
1
+ # GovBR-DS - Release Config
2
2
 
3
3
  ## Objetivo
4
4
 
5
- Compartilhar os padrões de geração de release entre os projetos do [GovBR-DS](https://gitlab.com/govbr-ds 'GovBR-DS').
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 os plugins que deseja usar:
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 { branches, commitAnalyzer, releaseNotesGenerator, changelog, gitlab, git } from './node_modules/@govbr-ds/config-tools/src/semantic-release.cjs'
23
-
24
- export default {
25
- branches: branches,
26
- plugins: [
27
- commitAnalyzer,
28
- releaseNotesGenerator,
29
- changelog,
30
- gitlab,
31
- git,
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 sobrescrever alguma configuração siga o padrão do [Semantic Release](https://github.com/semantic-release/semantic-release). A ordem definida será a ordem de execução!
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": "4.6.0",
3
+ "version": "5.0.0",
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,13 @@
25
28
  "src"
26
29
  ],
27
30
  "dependencies": {
31
+ "@govbr-ds/commit-types": "5.0.0",
28
32
  "@semantic-release/changelog": "^6.0.3",
33
+ "@semantic-release/commit-analyzer": "^13.0.1",
29
34
  "@semantic-release/git": "^10.0.1",
30
- "@semantic-release/gitlab": "^13.2.6",
31
- "conventional-changelog-conventionalcommits": "9.1.0",
32
- "semantic-release": "^24.2.7"
35
+ "@semantic-release/gitlab": "^13.3.3",
36
+ "@semantic-release/release-notes-generator": "^14.1.1",
37
+ "conventional-changelog-conventionalcommits": "10.2.1",
38
+ "semantic-release": "^25.0.7"
33
39
  }
34
40
  }
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
- const types = [
15
- { type: 'deprecated', section: '👎 DEPRECIADO' },
16
- { type: 'feat', section: '✨ NOVIDADES' },
17
- { type: 'removed', section: '🚧 REMOVIDO' },
18
- { type: 'docs', section: '📚 DOCUMENTAÇÃO' },
19
- { type: 'fix', section: '🐛 CORREÇÕES' },
20
- { type: 'ops', section: '🔧 ATIVIDADES OPERACIONAIS' },
21
- { type: 'perf', section: '🚀 PERFORMANCE' },
22
- { type: 'refactor', section: '🔁 REFATORADO' },
23
- { type: 'revert', section: '⏪ REVERTIDO' },
24
- { type: 'build', hidden: true },
25
- { type: 'chore', hidden: true },
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
- { scope: 'minor', release: 'minor' },
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
- { type: '*!', release: 'major' },
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'],
@@ -195,10 +179,18 @@ const gitlab = [
195
179
  const git = [
196
180
  '@semantic-release/git',
197
181
  {
198
- assets: ['package.json'],
182
+ assets: ['package.json', 'CHANGELOG.md'],
199
183
  message:
200
184
  'chore(release): v${nextRelease.version} [skip ci] \n\n${nextRelease.notes} \n\nCommit gerado automaticamente durante o processo de release',
201
185
  },
202
186
  ]
203
187
 
204
- export { branches, changelog, commitAnalyzer, git, gitlab, releaseNotesGenerator }
188
+ const basePlugins = [commitAnalyzer, releaseNotesGenerator, changelog, gitlab]
189
+
190
+ const releaseConfig = {
191
+ branches,
192
+ plugins: [...basePlugins, git],
193
+ }
194
+
195
+ export { basePlugins, branches, changelog, commitAnalyzer, git, gitlab, releaseConfig, releaseNotesGenerator }
196
+ export default releaseConfig