gfsm 0.1.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02114eeeebd6ba1a3adf4a555b5359bf7ea7920da2d90a07a15fc1c1af24b929
4
- data.tar.gz: 3ce23b247e05df130cd0315c7cb71a187c2f7a5fc8529aced4c0a08063b1e558
3
+ metadata.gz: b9e0ba6497503d24cc631e5a561879a5b8fddd9b0b98243b4b92d2f05f5add90
4
+ data.tar.gz: ac56fb2b77daf823e235cf7c06e6ca8ad29d585f261e83a90506efe7a3f30fd2
5
5
  SHA512:
6
- metadata.gz: 6430792b7dde9fc4d9bffa77ca3957fd85a912ce0aeca0cfdca24e04a870d86d12e44bfbe11d5f35392e03a21a05af2689289a1eb67ff63c16f8bf8582a51c80
7
- data.tar.gz: 38b14dba33e0eccc6e57b657fcdb0caa234a93d2bbe1b8b806dde83cd40629030a15831f31479531de8398c800f8d2d076def5bbd4b64c0f4537884c3d18c3f2
6
+ metadata.gz: 99373328bcc6e18fa2bd4c588a98fca5ff359fa83c2f1281049236a23f5f8631aafb9676ab813461dd2a6b87a89a83a3b595cc81db9d7266f141d412ca0c8f61
7
+ data.tar.gz: 1928c819f0a3bc20d324cacfb038506ed6eaf0cacb425070bcd09c4f85ea65bde18374cd4029aa2808552b2e6a71f4e46169811a3404e034177f9c0c32a2ab66
data/.gitlab-ci.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  stages:
2
2
  - version
3
3
  - deploy
4
+ - docker
4
5
  - release
5
6
 
6
7
  workflow:
@@ -56,19 +57,33 @@ Publish gem:
56
57
  when: never
57
58
  - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
58
59
 
60
+ Upload docker image:
61
+ stage: docker
62
+ image: docker:20.10.16
63
+ services:
64
+ - docker:20.10.16-dind
65
+ script:
66
+ - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
67
+ - docker build -t $CI_REGISTRY/zille_marco/gitlab-flavored-semantic-versioning:latest -t $CI_REGISTRY/zille_marco/gitlab-flavored-semantic-versioning:v$RELEASE_VERSION .
68
+ - docker push --all-tags $CI_REGISTRY/zille_marco/gitlab-flavored-semantic-versioning
69
+ rules:
70
+ - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
71
+ when: never
72
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
73
+
59
74
  Create release:
60
75
  stage: release
61
76
  image: registry.gitlab.com/gitlab-org/release-cli:latest
62
77
  script:
63
78
  - |
64
79
  release-cli create --name "Release v$RELEASE_VERSION" --description CHANGELOG.md --tag-name "v$RELEASE_VERSION"
65
- tags:
66
- - unix
67
80
  needs:
68
81
  - job: "Update version"
69
82
  artifacts: true
70
83
  - job: "Publish gem"
71
84
  artifacts: false
85
+ - job: "Upload docker image"
86
+ artifacts: false
72
87
  rules:
73
88
  - if: '$GEM_HOST_API_KEY == null'
74
89
  when: never
data/Dockerfile ADDED
@@ -0,0 +1,7 @@
1
+ FROM ruby:2.7.5-alpine3.15
2
+
3
+ RUN gem install gfsm
4
+
5
+ COPY ./gfsmrc.yml ./gfsmrc.yml
6
+
7
+ ENTRYPOINT [""]
data/README.md CHANGED
@@ -56,8 +56,45 @@ At the moment there's no built-in testing platform, but I'm planning to use `rsp
56
56
 
57
57
  ### Using
58
58
 
59
- There are two ways to run this tool locally at the moment:
59
+ This project is available as a Ruby gem, so to be able to use it is enough to run
60
60
 
61
61
  ```shell
62
- ./bin/gfsm [args]
63
- ```
62
+ gem install gfsm
63
+ ```
64
+
65
+ Once that command completes, the gem will be available and you can invoke it from the command line with
66
+
67
+ ```shell
68
+ gfsm help
69
+ ```
70
+
71
+ The main way this project can be used though, is inside a CI pipeline where you can invoke it to bump the version and/or update the changelog.
72
+
73
+ In order to use is inside a CI job, the job itself could look something like this:
74
+
75
+ ```yaml
76
+ stages:
77
+ - version
78
+
79
+ update-version:
80
+ stage: version
81
+ image: ruby:2.7.5
82
+ before_script:
83
+ - gem install gfsm
84
+ script:
85
+ - gfsm version bump --force > .version
86
+ - gfsm changelog --force --output-file CHANGELOG.md
87
+ - echo "RELEASE_VERSION=$(<.version)" >> variables.env
88
+ artifacts:
89
+ reports:
90
+ dotenv: variables.env
91
+ paths:
92
+ - .version
93
+ - CHANGELOG.md
94
+ ```
95
+
96
+ With this, subsequent jobs that depend on the `update-version` job will:
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
99
+
100
+ To have a working example of the things described above you can have a look at the `.gitlab-ci.yml` of this project, which implements this exact concept.
@@ -76,11 +76,15 @@ module GFSM
76
76
 
77
77
  version_bumper = GFSM::Tools::VersionBumper.new()
78
78
  version = version_bumper.compute_version!(force, prerelease, prerelease_name, repository_path, configuration_file_path)
79
- subdivisions = version_bumper.subdivisions
79
+ subdivisions = version_bumper.subdivisions.to_a
80
+ subdivisions.sort_by! { |subdivision_data| subdivision_data[0].priority }.reverse!
80
81
 
81
82
  changelog_entries = ""
82
83
 
83
- subdivisions.each do |change_type, commits|
84
+ subdivisions.each do |subdivision_data|
85
+ change_type = subdivision_data[0]
86
+ commits = subdivision_data[1]
87
+
84
88
  changelog_entries += "\n#{change_type.to_changelog_entry}\n\n"
85
89
 
86
90
  commits.each do |commit|
@@ -18,7 +18,7 @@ module GFSM
18
18
  end
19
19
  end
20
20
 
21
- @change_types.sort_by! { |change_type| change_type.priority }.reverse!
21
+ @change_types
22
22
  end
23
23
 
24
24
  def get_change_type_from_category(category)
@@ -11,7 +11,7 @@ module GFSM
11
11
  repo = Git.open(repo_path)
12
12
 
13
13
  begin
14
- last_tag_name = repo.describe(nil, { abbrev: 0 })
14
+ last_tag_name = repo.describe(nil, { :tags => true, :abbrev => 0 })
15
15
  rescue
16
16
  last_tag_name = nil
17
17
  end
@@ -10,7 +10,7 @@ module GFSM
10
10
  repo = Git.open(repo_path)
11
11
 
12
12
  begin
13
- last_tag_name = repo.describe(nil, { abbrev: 0 })
13
+ last_tag_name = repo.describe(nil, { :tags => true, :abbrev => 0 })
14
14
  rescue
15
15
  last_tag_name = nil
16
16
  end
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.1.3
4
+ version: 0.3.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: 2022-07-04 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml
@@ -65,6 +65,7 @@ files:
65
65
  - ".gitlab-ci.yml"
66
66
  - ".tool-versions"
67
67
  - ".vscode/launch.json"
68
+ - Dockerfile
68
69
  - Gemfile
69
70
  - Gemfile.lock
70
71
  - README.md