-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a smart CI so that it would bump the version only if there is su…
…ch a need (#57)
- Loading branch information
Showing
7 changed files
with
79 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'git' | ||
|
||
module CI | ||
# Class for bump version in CI | ||
class Bumper | ||
def initialize | ||
repo = Git.open('.') | ||
@commit = repo.log.first | ||
end | ||
|
||
def bump? | ||
commit.diff_parent.name_status.each_key do |file| | ||
return false if file == 'VERSION' | ||
|
||
path = file.split('/').first | ||
case path | ||
when 'lib', 'app', 'config', 'tasks', 'app.rb', 'config.ru', 'Dockerfile' | ||
return true | ||
end | ||
end | ||
|
||
false | ||
end | ||
|
||
def bump_pathc_version | ||
version = File.read('VERSION').gsub('v', '') | ||
semver = version.split('.') | ||
new_pathc = semver.last.to_i + 1 | ||
semver[2] = new_pathc.to_s | ||
new_version = "v#{semver.join('.')}" | ||
File.write('VERSION', new_version) | ||
end | ||
|
||
private | ||
|
||
attr_reader :commit | ||
end | ||
end | ||
|
||
namespace :ci do | ||
desc 'bump pathc version' | ||
task :bump_pathc_version do | ||
bumper = CI::Bumper.new | ||
|
||
bumper.bump_pathc_version if bumper.bump? | ||
end | ||
end |