gfsm 0.5.0 → 0.6.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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +24 -1
- data/Dockerfile +4 -2
- data/README.md +146 -35
- data/lib/commands/changelog.rb +1 -1
- data/lib/commands/help.rb +1 -1
- data/lib/commands/version.rb +1 -1
- data/lib/tools/current_version_loader.rb +2 -2
- data/lib/tools/version_bumper.rb +10 -3
- metadata +2 -3
- data/.version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e82f5cdce1d37aced2b895cabbc7a9b24019ddfb0838a35b623ff097307c343
|
4
|
+
data.tar.gz: ef83dd15b50de4d9db1e28e92e354864379294f9f8485fd093682e59525afd7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c98d7dce54ec8b5bed5a4a3f328b97778a95fb622d977af7051ad9c034e344fba153da0a495b5288ddf3498e2970b88a6e1b07c0760b67c9dd0da1974e758b
|
7
|
+
data.tar.gz: 67c36f148426d0f397fe076aae8bdcbe1cf94f17d8aef7098221bce59e2f864f63286ceabfa7bc34020c78718b5a96ab9f84ee4fc88e8e872fdc429fbfa2cc05
|
data/.gitlab-ci.yml
CHANGED
@@ -64,6 +64,13 @@ Publish gem:
|
|
64
64
|
- if: "$GEM_HOST_API_KEY == null"
|
65
65
|
when: never
|
66
66
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
67
|
+
changes:
|
68
|
+
- bin/**/*
|
69
|
+
- lib/**/*
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- gfsm.gemspec
|
73
|
+
- .tools-versions
|
67
74
|
|
68
75
|
Upload docker image:
|
69
76
|
stage: docker
|
@@ -72,10 +79,18 @@ Upload docker image:
|
|
72
79
|
- docker:20.10.16-dind
|
73
80
|
script:
|
74
81
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
75
|
-
- docker build -t $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:v$RELEASE_VERSION .
|
82
|
+
- docker build --build-arg="GFSM_VERSION=${RELEASE_VERSION}" -t $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:v$RELEASE_VERSION .
|
76
83
|
- docker push --all-tags $CI_REGISTRY_IMAGE
|
77
84
|
rules:
|
78
85
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
86
|
+
changes:
|
87
|
+
- bin/**/*
|
88
|
+
- lib/**/*
|
89
|
+
- Gemfile
|
90
|
+
- Gemfile.lock
|
91
|
+
- gfsm.gemspec
|
92
|
+
- .tools-versions
|
93
|
+
- Dockerfile
|
79
94
|
|
80
95
|
Create release:
|
81
96
|
stage: release
|
@@ -94,3 +109,11 @@ Create release:
|
|
94
109
|
- if: "$GEM_HOST_API_KEY == null"
|
95
110
|
when: never
|
96
111
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
112
|
+
changes:
|
113
|
+
- bin/**/*
|
114
|
+
- lib/**/*
|
115
|
+
- Gemfile
|
116
|
+
- Gemfile.lock
|
117
|
+
- gfsm.gemspec
|
118
|
+
- .tools-versions
|
119
|
+
- Dockerfile
|
data/Dockerfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# GitLab Flavored Semantic
|
1
|
+
# GitLab Flavored Semantic Versioning
|
2
2
|
|
3
|
-
|
3
|
+
## Goal
|
4
4
|
|
5
5
|
This project tries to achieve automatic semantic versioning not basing the version bump
|
6
6
|
on the conventional commits standars, but rather on a `Changelog` value on the trailer
|
@@ -13,36 +13,40 @@ to get merged through a merge request.
|
|
13
13
|
The beauty of this project is that you don't need to use the conventional commits specification,
|
14
14
|
so you can have commits more similar to
|
15
15
|
|
16
|
-
```
|
16
|
+
```plaintext
|
17
17
|
Added new feature A to address this requirement
|
18
18
|
```
|
19
19
|
|
20
20
|
instead of
|
21
21
|
|
22
|
-
```
|
22
|
+
```plaintext
|
23
23
|
feat(<type>): added new feature A to address this requirement
|
24
24
|
```
|
25
25
|
|
26
26
|
This translates to:
|
27
|
+
|
27
28
|
- _**no "wasted" characters for that message prefix**_
|
28
29
|
- more readable commit messages
|
29
30
|
- a nicer `Changelog`
|
30
|
-
|
31
|
+
|
32
|
+
```plaintext
|
31
33
|
New features:
|
32
34
|
- Added new feature A to address this requirement
|
33
35
|
- Added feature B
|
34
36
|
```
|
37
|
+
|
35
38
|
vs
|
36
|
-
|
39
|
+
|
40
|
+
```plaintext
|
37
41
|
New features:
|
38
42
|
- feat(<type>): added new feature A to address this requirement
|
39
43
|
- feat: added feature B
|
40
44
|
```
|
41
45
|
|
42
|
-
|
46
|
+
## Setup
|
43
47
|
|
44
48
|
The only tool you need to setup this project on your local environment is Ruby, which can be
|
45
|
-
downloaded using `asdf`. The Ruby version required is `2.
|
49
|
+
downloaded using `asdf`. The Ruby version required is `3.2.4`.
|
46
50
|
|
47
51
|
Once Ruby is present on your system you can install the dependencies by running
|
48
52
|
|
@@ -50,11 +54,13 @@ Once Ruby is present on your system you can install the dependencies by running
|
|
50
54
|
bundle install
|
51
55
|
```
|
52
56
|
|
53
|
-
|
57
|
+
## Testing
|
54
58
|
|
55
59
|
At the moment there's no built-in testing platform, but I'm planning to use `rspec` to add unit tests.
|
56
60
|
|
57
|
-
|
61
|
+
## Usage
|
62
|
+
|
63
|
+
### Installation
|
58
64
|
|
59
65
|
This project is available as a Ruby gem, so to be able to use it is enough to run
|
60
66
|
|
@@ -68,33 +74,138 @@ Once that command completes, the gem will be available and you can invoke it fro
|
|
68
74
|
gfsm help
|
69
75
|
```
|
70
76
|
|
71
|
-
|
77
|
+
**Important**: `git` must be avaiable on the system for the gem to work.
|
72
78
|
|
73
|
-
|
79
|
+
The main way this project can be used though, is inside a CI pipeline where you can invoke it to bump
|
80
|
+
the version and/or update the changelog.
|
74
81
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
82
|
+
To facilitate this, a docker image is published with every release of this tool.
|
83
|
+
[Here](https://gitlab.com/zille_marco/gitlab-flavored-semantic-versioning/container_registry/3294324)
|
84
|
+
is a list of all the available images.
|
85
|
+
|
86
|
+
### Available commands
|
87
|
+
|
88
|
+
The main commands available are:
|
89
|
+
|
90
|
+
- `gfsm version`: this command takes care of the project's verioning.
|
91
|
+
- `gfsm changelog`: this command takes care of the project's changelog.
|
92
|
+
- `gfsm help`: this command will display the available commands and their usage.
|
93
|
+
|
94
|
+
To use these commands, you can invoke the `gfsm` executable from the command line. For example:
|
95
|
+
|
96
|
+
```shell
|
97
|
+
gfsm version <subcommand>
|
98
|
+
gfsm changelog <subcommand>
|
99
|
+
```
|
100
|
+
|
101
|
+
#### gfsm version
|
102
|
+
|
103
|
+
The `version` command has its own subcommands:
|
104
|
+
|
105
|
+
- `bump`: used to bump the version to the next one
|
106
|
+
- `current`: used to extract the current version
|
107
|
+
- `help`: used to print the usage of the `vesion` command itself
|
108
|
+
|
109
|
+
All subcommands are configurable through either CLI flags or environment variables, that have precedence
|
110
|
+
over the CLI flags.
|
111
|
+
|
112
|
+
| CLI flag | Environment variable | Accepted values | Default | Description |
|
113
|
+
| ------------------- | -------------------- | ------------------------------ | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
114
|
+
| `--force` | `FORCE_BUMP` | | | If there are no commits with a changelog trailer, the version will still be bumped. |
|
115
|
+
| `--force-version` | `FORCE_BUMP_VERSION` | `major`, `minor`, `patch` | `patch` | If the version needs to be force-bumped, this flag instructs the tool which section of the version to bump. |
|
116
|
+
| `--prerelease` | `PRERELEASE` | | | Turns on prerelease generation, which by default appends `-pre` to the generated version. |
|
117
|
+
| `--prerelease-name` | `PRERELEASE_NAME` | Any string without whitespaces | `pre` | When prerelease generation is enabled, this overrides the default `pre` value appended as suffix to the generated version. |
|
118
|
+
| `--configuration` | `CONFIGURATION_FILE` | A file path | `./gfsmrc.yml` | The path to the YAML configuration file. |
|
119
|
+
| `--path` | `REPOSITORY_PATH` | A folder path | `.` | The path to the folder containing the Git repository. |
|
120
|
+
| `--from` | `FROM_COMMIT` | A commit SHA or a tag name | The latest **reachable** tag | The commit SHA or the tag name from where to start scraping for commit messages. |
|
121
|
+
| `--to` | `TO_COMMIT` | A commit SHA or a tag name | `HEAD` | The commit SHA or the tag name where to stop scraping for commit messages. |
|
122
|
+
| `--initial-version` | `INITIAL_VERSION` | A semantic version value | `0.0.0` | The version used when the project doesn't have one yet, useful for the first initialization of the project. |
|
123
|
+
|
124
|
+
#### gfsm changelog
|
125
|
+
|
126
|
+
The `changelog` command has its own subcommands:
|
127
|
+
|
128
|
+
- `generate`: used to generate a changelog for the latest version
|
129
|
+
- `extract`: used to extract a section from the changelog associated with a specific version
|
130
|
+
- `help`: used to print the usage of the `changelog` command itself
|
131
|
+
|
132
|
+
All subcommands are configurable through either CLI flags or environment variables, that have precedence
|
133
|
+
over the CLI flags.
|
134
|
+
|
135
|
+
The `changelog` command supports all the flags and environment variables of the `version` command, with
|
136
|
+
the following additions.
|
137
|
+
|
138
|
+
| CLI flag | Environment variable | Accepted values | Default | Description |
|
139
|
+
| -------------------- | -------------------- | --------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
140
|
+
| `--output-file` | `OUTPUT_FILE` | A file path | | The path to the CHANGELOG.md file, which will be created if not existing. If not specified the changelog will be written to stdout. **Only usable with `generate`**. |
|
141
|
+
| `--input-file` | `INPUT_FILE` | A file path | `./CHANGELOG.md` | The path to the CHANGELOG.md file. **Only usable with `extract`**. |
|
142
|
+
| `--no-incremental` | `NO_INCREMENTAL` | | | When provided, the output file will always be overridden and will contain only the changelog entries for the latest version. |
|
143
|
+
| `--only-new-entries` | `ONLY_NEW_ENTRIES` | | | When provided, the output will always be written to stdout and will only contain the changelog for the latest changes without the version header. |
|
144
|
+
| `--extract-version` | `EXTRACT_VERSION` | A version name | | When provided, this specifies the version that `extract` will extract the release notes from. If not provided, or set to `latest`, it will extract the release notes from the latest version. |
|
145
|
+
|
146
|
+
### Configuration
|
147
|
+
|
148
|
+
GFSM can be cofigured by providing a YAML configuration file which will contain informations about the
|
149
|
+
supported changelog trailers, the section they belong to and their priority.
|
150
|
+
|
151
|
+
The schema is the following:
|
152
|
+
|
153
|
+
```plaintext
|
154
|
+
change_types:
|
155
|
+
<identifier>:
|
156
|
+
title: string
|
157
|
+
matcher: string
|
158
|
+
bump: major|minor|patch
|
159
|
+
priority: number
|
94
160
|
```
|
95
161
|
|
96
|
-
|
97
|
-
- be able to get the new version form the `RELEASE_VERSION` environment variable
|
98
|
-
- read the `CHANGELOG.md` file to get an updated changelog file
|
162
|
+
Where:
|
99
163
|
|
100
|
-
|
164
|
+
- `<identifier>` is used only to separate the different sections
|
165
|
+
- `title` is the title used when generating the changelog
|
166
|
+
- `matcher` is the string that the commit changelog trailer has to contain in order to match the section
|
167
|
+
- `bump` tells the tool which section of the version to bump when a commit changelog trailer matches
|
168
|
+
the section
|
169
|
+
- `priority` is used to order the sections when generating the changelog, the higher the priority the
|
170
|
+
higher up the section will be in the changelog
|
171
|
+
|
172
|
+
Here is an example:
|
173
|
+
|
174
|
+
```yaml
|
175
|
+
change_types:
|
176
|
+
new_features:
|
177
|
+
title: "New features"
|
178
|
+
matcher: added
|
179
|
+
bump: minor
|
180
|
+
priority: 6
|
181
|
+
feature_removals:
|
182
|
+
title: "Feature removals"
|
183
|
+
matcher: removed
|
184
|
+
bump: major
|
185
|
+
priority: 5
|
186
|
+
deprecations:
|
187
|
+
title: "Deprecations"
|
188
|
+
matcher: deprecated
|
189
|
+
bump: minor
|
190
|
+
priority: 4
|
191
|
+
feature_changes:
|
192
|
+
title: "Feature changes"
|
193
|
+
matcher: changed
|
194
|
+
bump: minor
|
195
|
+
priority: 3
|
196
|
+
fixes:
|
197
|
+
title: "Fixes"
|
198
|
+
matcher: fixed
|
199
|
+
bump: patch
|
200
|
+
priority: 2
|
201
|
+
security_fixes:
|
202
|
+
title: "Security fixes"
|
203
|
+
matcher: security
|
204
|
+
bump: patch
|
205
|
+
priority: 1
|
206
|
+
other:
|
207
|
+
title: "Other"
|
208
|
+
matcher: other
|
209
|
+
bump: patch
|
210
|
+
priority: 0
|
211
|
+
```
|
data/lib/commands/changelog.rb
CHANGED
data/lib/commands/help.rb
CHANGED
data/lib/commands/version.rb
CHANGED
@@ -32,7 +32,7 @@ module GFSM
|
|
32
32
|
GFSM::Output.puts(version)
|
33
33
|
when 'current'
|
34
34
|
settings = GFSM::Tools::VersionBumperSettings.new(args)
|
35
|
-
version = GFSM::Tools::CurrentVersionLoader.load_current_version(settings.repository)
|
35
|
+
version = GFSM::Tools::CurrentVersionLoader.load_current_version(settings.repository, settings.initial_version)
|
36
36
|
|
37
37
|
if settings.prerelease
|
38
38
|
version.add_prerelease_suffix!(settings.prerelease_name)
|
@@ -6,10 +6,10 @@ require_relative '../data/version'
|
|
6
6
|
module GFSM
|
7
7
|
module Tools
|
8
8
|
class CurrentVersionLoader
|
9
|
-
def self.load_current_version(repo)
|
9
|
+
def self.load_current_version(repo, initial_version)
|
10
10
|
last_tag_name = GFSM::Tools::GitUtilities.extract_last_tag_name(repo)
|
11
11
|
|
12
|
-
return GFSM::Data::Version.new(
|
12
|
+
return GFSM::Data::Version.new(initial_version) unless last_tag_name
|
13
13
|
|
14
14
|
if last_tag_name.downcase.start_with?("v")
|
15
15
|
last_tag_name.slice!(0)
|
data/lib/tools/version_bumper.rb
CHANGED
@@ -7,7 +7,7 @@ module GFSM
|
|
7
7
|
module Tools
|
8
8
|
|
9
9
|
class VersionBumperSettings
|
10
|
-
attr_reader :repository, :configuration, :force, :force_version, :prerelease, :prerelease_name, :from, :to
|
10
|
+
attr_reader :repository, :configuration, :force, :force_version, :prerelease, :prerelease_name, :from, :to, :initial_version
|
11
11
|
|
12
12
|
def initialize(cli_args)
|
13
13
|
@repository = GFSM::Tools::GitUtilities.load_repo(get_repository_path(cli_args))
|
@@ -18,6 +18,7 @@ module GFSM
|
|
18
18
|
@prerelease_name = get_prerelease_name(cli_args)
|
19
19
|
@from = get_from(cli_args)
|
20
20
|
@to = get_to(cli_args)
|
21
|
+
@initial_version = get_initial_version(cli_args)
|
21
22
|
@from = GFSM::Tools::GitUtilities.extract_last_tag_name(@repository) if @from.nil?
|
22
23
|
end
|
23
24
|
|
@@ -32,6 +33,7 @@ module GFSM
|
|
32
33
|
--to <hash, tag or HEAD> # The commit hash or tag to stop at when extracting the commits. By default will use HEAD to get to the latest commit on the current branch
|
33
34
|
--configuration <path> # Path to the configuration YAML file
|
34
35
|
--path <path> # Path to the repository. By default will use the current directory
|
36
|
+
--initial-version <x.y.z> # Version to use when no existing version is found, useful when initializing the first one
|
35
37
|
OPTIONS
|
36
38
|
|
37
39
|
environment_variables = <<~ENVVARS
|
@@ -43,10 +45,11 @@ module GFSM
|
|
43
45
|
REPOSITORY_PATH # Equivalent to --path
|
44
46
|
FROM_COMMIT # Equivalent to --from
|
45
47
|
TO_COMMIT # Equivalent to --to
|
48
|
+
INITIAL_VERSION # Equivalent to --initial-version
|
46
49
|
ENVVARS
|
47
50
|
|
48
51
|
return {
|
49
|
-
usage: "[--force] [--force-version <major|minor|patch>] [--configuration <configuration_file_path>] [--prerelease] [--prerelease-name <prerelease_name>] [--from <hash or tag>] [--to <hash, tag or HEAD>] [--path <repository_path]",
|
52
|
+
usage: "[--force] [--force-version <major|minor|patch>] [--configuration <configuration_file_path>] [--prerelease] [--prerelease-name <prerelease_name>] [--from <hash or tag>] [--to <hash, tag or HEAD>] [--path <repository_path] [--initial-version <x.y.z>]",
|
50
53
|
options: options,
|
51
54
|
environment_variables: environment_variables
|
52
55
|
}
|
@@ -88,6 +91,10 @@ module GFSM
|
|
88
91
|
def get_to(args)
|
89
92
|
extract_switch_value(args, "--to", "HEAD", "TO_COMMIT")
|
90
93
|
end
|
94
|
+
|
95
|
+
def get_initial_version(args)
|
96
|
+
extract_switch_value(args, "--initial-version", "0.0.0", "INITIAL_VERSION")
|
97
|
+
end
|
91
98
|
end
|
92
99
|
|
93
100
|
class VersionBumper
|
@@ -100,7 +107,7 @@ module GFSM
|
|
100
107
|
def execute
|
101
108
|
changelog_commits = GFSM::Tools::GitUtilities.extract_commits_with_changelog_trailer(@settings.repository, @settings.from, @settings.to)
|
102
109
|
|
103
|
-
@version = GFSM::Tools::CurrentVersionLoader.load_current_version(@settings.repository)
|
110
|
+
@version = GFSM::Tools::CurrentVersionLoader.load_current_version(@settings.repository, @settings.initial_version)
|
104
111
|
@subdivisions = GFSM::Tools::CommitsSubdivider.subdivide_commits(@settings.configuration, changelog_commits)
|
105
112
|
|
106
113
|
if !@subdivisions || @subdivisions.empty?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gfsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zille Marco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yaml
|
@@ -65,7 +65,6 @@ files:
|
|
65
65
|
- ".gitignore"
|
66
66
|
- ".gitlab-ci.yml"
|
67
67
|
- ".tool-versions"
|
68
|
-
- ".version"
|
69
68
|
- ".vscode/launch.json"
|
70
69
|
- Dockerfile
|
71
70
|
- Gemfile
|
data/.version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.5.0
|