Repositório com passo-a-passo de como gerar um CHANGELOG automaticamente.
Esse passo-a-passo é a versão muito resumida do artigo: Como gerar CHANGELOG automaticamente
npm install --global commitizen
# dentro do seu projeto
npm install --save-dev husky @commitlint/cli @commitlint/config-conventional standard-version
# dentro do seu projeto
commitizen init cz-conventional-changelog --save-dev --save-exact
module.exports = {
extends: ['@commitlint/config-conventional']
};
{
...,
// opcional
"repository": {
"url": "git@gitlab.com:meu-usuario/meu-repo.git"
},
...,
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"scripts": {
"release": "standard-version"
}
}
{
"types": [
{"type": "feat", "section": "Funcionalidades"},
{"type": "fix", "section": "Errors Corrigidos"},
{"type": "chore", "hidden": true},
{"type": "docs", "hidden": true},
{"type": "style", "hidden": true},
{"type": "refactor", "hidden": true},
{"type": "perf", "section": "Melhorias de Performance"},
{"type": "test", "hidden": true}
],
"releaseCommitMessageFormat": "chore(release): {{currentTag}} [skip ci]"
}
Caso queira, pode criar uma release com a versão atual do projeto, antes de adicionar um processo de automatização.
npm run release -- --first-release
name: Gerador de CHANGELOG
# só executa no push de commit da branch master
on:
push:
branches:
- master
jobs:
build:
# só deixa executar se o último commit não conter 'skip ci' na mensagem
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
# configura o GITHUB_TOKEN
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token
- name: Configura o GitHub token
uses: fregante/setup-git-token@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Gerador de changelog"
email: "changelog@users.noreply.github.com"
# instala a versão 11.x do Node.js
- name: Instala o Node.js 11.x
uses: actions/setup-node@v1
with:
node-version: 11.x
# instala as dependências, vai para a master
# executa o standard-version, e envia o commit e tag
- name: Gera o CHANGELOG
run: |
npm ci
git checkout master
npm run release
git push origin master --follow-tags
https://github.com/<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_NAME>/badge.svg