-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.md.template
214 lines (150 loc) · 6.04 KB
/
README.md.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# Gommitizen
{{ .Description }}
## Installation
To install **gommitizen**, run the following command:
```bash
curl -s https://raw.githubusercontent.com/freepik-company/gommitizen/main/scripts/get-gommitizen.sh | sudo bash
```
This script will download the latest release of the **gommitizen** binary and install it in the `/usr/local/bin` directory.
To verify the installation, run the following command:
```bash
gommitizen --version
```
You should see the version of **gommitizen** that you installed.
## Compilation
To compile the project, run the following command:
```bash
make bin
```
This will generate a binary in the `bin/` directory.
```bash
make install
```
This will install the binary in the `/usr/local/bin` directory.
## Usage
Next a list of the available commands and their description:
{{- range .RootCommand.Commands }}
- `{{ .Name }}`: {{ .ShortDescription }}
{{ end }}
{{- range .RootCommand.Commands }}
### {{ .Name }} command
{{ .LongDescription }}
{{- if .Flags }}
**Flags:**
{{- end }}
{{- range .Flags }}
- `-{{ .ShortHand }}`, `--{{ .Name }}`: {{ .Description }}
{{ end }}
{{ if .Example }}
**Examples of usage:**
```shell
{{ .Example }}
```
{{ end }}
{{ if .Commands }}
**Subcommands:**
{{ end }}
{{ range .Commands }}
- `{{ .Name }}`: {{ .LongDescription }}
{{ end }}
{{- end }}
### Docker
To run Gommitizen in a Docker container, run:
```bash
docker run --rm \
-e GIT_USER_NAME=user.name \
-e GIT_USER_EMAIL=user@email \
-v $(pwd):/source \
ghcr.io/freepik-company/gommitizen:<tag> [retrieveCommandFlags]
```
Replace `<tag>` with the tag of the image you want to use. Select the command and retrieveCommandFlags you want to use.
Example:
```bash
docker run --rm \
-e GIT_USER_NAME=user.name \
-e GIT_USER_EMAIL=user@email \
-v $(pwd):/source \
ghcr.io/freepik-company/gommitizen:latest [retrieveCommandFlags]
```
## Types of commits
There are two types of commits: version commits and regular commits. Version commits are those that change the version of the software, while regular commits are those that do not change the version.
Those that change the version of the software are those that have a commit message with a prefix that indicates the type of change. The prefixes are the following:
- `BREAKING CHANGE:` or `bc`: Indicates a breaking change in the software.
- `feat:`: Indicates a new feature in the software.
- `fix:`: Indicates a bug fix in the software.
Those that do not change the version of the software are those that have a commit message with a prefix that indicates the type of change. The prefixes are the following:
- `perf:`: Indicates a performance improvement in the software.
- `refactor:`: Indicates a code refactoring in the software.
- `docs:`: Indicates a documentation change in the software.
- `test:`: Indicates a test change in the software.
- `chore:`: Indicates a change in the build process or auxiliary tools in the software.
- `ci:`: Indicates a change in the CI configuration files and scripts in the software.
- `style:`: Indicates a change in the style of the code in the software.
## Version files structure
Each project in the monorepo has a `.version.json` file that contains the version of the software.
The version files are structured as follows:
```json
{
"version": "0.18.1",
"commit": "72929b90547b8527e22e402b6784e0c7f5812428",
"version_files": [
"Chart.yaml:version",
"other-version.txt:version",
"a-file-that-need-a-regex.txt:^version=([0-9]+\\.[0-9]+\\.[0-9]+)$"
],
"prefix": "my_prj"
}
```
The `version` field contains the current version of the software. The `commit` field contains the commit where the version was changed. The `version_files` field contains the list of files that contain the version of the software and the bump process will upgrade too. The `prefix` field contains the prefix of the tag message that changed the version of the software.
The `version` and `commit` fields are managed by Gommitizen. The `version_files` and `prefix` fields are managed by the user.
`version_files` is a list of strings. Each string contains the path of the file and the name of the variable that contains the version. The path and the name of the variable are separated by a colon (`:`). The path is relative to the root of the project. Tha name of the variable can be replace by a regular expression to find the version in the file (remember to scape the special characters and group the version part of the expression with parentheses like in the example).
### Hooks
Example:
```json
{
"version": "0.18.1",
"commit": "72929b90547b8527e22e402b6784e0c7f5812428",
"version_files": [
"Chart.yaml:version",
"other-version.txt:version",
"a-file-that-need-a-regex.txt:^version=([0-9]+\\.[0-9]+\\.[0-9]+)$"
],
"prefix": "my-prj",
"hooks": {
"pre-bump": "echo 'pre-bump hook'",
"post-bump": "echo 'post-bump hook'",
"post-changelog": "echo 'post-changelog hook'",
"pre-changelog": "echo 'pre-changelog hook'"
}
}
```
There are four hooks available:
- `pre-bump`: Runs before the bump process.
- `post-bump`: Runs after the bump process.
- `pre-changelog`: Runs before the changelog generation.
- `post-changelog`: Runs after the changelog generation.
The hooks are shell getCommands that are executed in the root of the project. These are all optional fields.
## Development
To run the project in development mode, run:
```bash
go run ./cmd/gommitizen/main.go
```
To run a new release locally, run:
```bash
make release
```
If you want to run the release in pipeline, run:
```bash
make bump
```
to bump the version of the project and changelog. Then push the changes and tag to the repository to trigger the pipeline. That will generate the release and publish the binaries and docker image.
If you want to increase the version manually, run:
```bash
cz bump --increment (MAJOR|MINOR|PATCH) --changelog
```
Then push the tag to the repository:
```bash
git push && git push --tags
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.