kameleon-builder 2.6.0 → 2.6.1

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.
data/.bumpversion.cfg CHANGED
@@ -1,7 +1,7 @@
1
1
  [bumpversion]
2
2
  commit = True
3
3
  tag = True
4
- current_version = 2.6.0
4
+ current_version = 2.6.1
5
5
  parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+))?
6
6
  serialize =
7
7
  {major}.{minor}.{patch}.{release}
data/CHANGES CHANGED
@@ -1,6 +1,13 @@
1
1
  Kameleon CHANGELOG
2
2
  ==================
3
3
 
4
+ Version 2.6.1
5
+ -------------
6
+
7
+ Released on August 12th 2015
8
+
9
+ - Cli global parameters overwrite all recipe key:value parameters
10
+
4
11
  Version 2.6.0
5
12
  -------------
6
13
 
@@ -298,7 +298,7 @@ module Kameleon
298
298
  raise AbortError, "Execution aborted..." if answer.nil?
299
299
  answer.chomp!
300
300
  if responses.keys.include?(answer)
301
- Kameleon.ui.info("User choice : [#{answer}] #{responses[answer]}")
301
+ Kameleon.ui.info("User choice: [#{answer}] #{responses[answer]}")
302
302
  if ["o", "i", "l"].include?(answer)
303
303
  if answer.eql? "l"
304
304
  @local_context.start_shell
@@ -17,6 +17,7 @@ module Kameleon
17
17
  attr_accessor :base_recipes_files
18
18
  attr_accessor :data_files
19
19
  attr_accessor :env_files
20
+ attr_accessor :cli_global
20
21
 
21
22
  def initialize(path, kwargs = {})
22
23
  @path = Pathname.new(File.expand_path(path))
@@ -4,7 +4,7 @@ module Kameleon
4
4
 
5
5
  def self.resolve_vars(raw, yaml_path, initial_variables, recipe, kwargs = {})
6
6
  raw = resolve_data_dir_vars(raw, yaml_path, initial_variables, recipe, kwargs)
7
- return resolve_simple_vars(raw, yaml_path, initial_variables, kwargs)
7
+ return resolve_simple_vars(raw, yaml_path, initial_variables, recipe, kwargs)
8
8
  end
9
9
 
10
10
  def self.resolve_data_dir_vars(raw, yaml_path, initial_variables, recipe, kwargs)
@@ -12,7 +12,7 @@ module Kameleon
12
12
  matches = raw.to_enum(:scan, reg).map { Regexp.last_match }
13
13
  matches.each do |m|
14
14
  unless m.nil?
15
- path = resolve_simple_vars(m[1], yaml_path, initial_variables, kwargs)
15
+ path = resolve_simple_vars(m[1], yaml_path, initial_variables, recipe, kwargs)
16
16
  resolved_path = recipe.resolve_data_path(path, yaml_path)
17
17
  raw.gsub!(m[0], "\"#{resolved_path}\"")
18
18
  end
@@ -20,7 +20,8 @@ module Kameleon
20
20
  return raw
21
21
  end
22
22
 
23
- def self.resolve_simple_vars(raw, yaml_path, initial_variables, kwargs)
23
+ def self.resolve_simple_vars(raw, yaml_path, initial_variables, recipe, kwargs)
24
+ initial_variables.merge! recipe.cli_global
24
25
  raw.to_s.gsub(/\$\$\{[a-zA-Z0-9\-_]+\}|\$\$[a-zA-Z0-9\-_]+/) do |var|
25
26
  # remove the dollars
26
27
  if var.include? "{"
@@ -36,7 +37,7 @@ module Kameleon
36
37
  fail RecipeError, "#{yaml_path}: variable #{var} not found in local or global"
37
38
  end
38
39
  end
39
- return $` + resolve_simple_vars(value.to_s + $', yaml_path, initial_variables, kwargs)
40
+ return $` + resolve_simple_vars(value.to_s + $', yaml_path, initial_variables, recipe, kwargs)
40
41
  end
41
42
  end
42
43
 
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+ from __future__ import unicode_literals, print_function
4
+ import os
5
+ import re
6
+
7
+ from io import open
8
+ import datetime
9
+ import subprocess
10
+
11
+ from argparse import RawTextHelpFormatter, ArgumentParser, FileType
12
+
13
+
14
+ def generate_changelog_title(version):
15
+ version_title = "Version %s" % version
16
+ return version_title + "\n" + "-" * len(version_title)
17
+
18
+
19
+ def get_release_date():
20
+ dt = datetime.date.today()
21
+ if 4 <= dt.day <= 20 or 24 <= dt.day <= 30:
22
+ suffix = "th"
23
+ else:
24
+ suffix = ["st", "nd", "rd"][dt.day % 10 - 1]
25
+ return dt.strftime("%%B %%d%s %%Y" % suffix)
26
+
27
+
28
+ def bump_release_version(args):
29
+ """Automated software release workflow
30
+
31
+ * Bumps the release version number (with .bumpversion.cfg)
32
+ * Preloads the correct changelog template for editing
33
+ * Builds a source distribution
34
+ * Sets release date
35
+ * Tags the release
36
+
37
+ You can run it like::
38
+
39
+ $ python bumpversion.py
40
+
41
+ which will create a 'release' version (Eg. 0.7.2-dev => 0.7.2).
42
+
43
+ """
44
+ # Dry run 'bumpversion' to find out what the new version number
45
+ # would be. Useful side effect: exits if the working directory is not
46
+ # clean.
47
+ changelog = args.changelog.name
48
+ bumpver = subprocess.check_output(
49
+ ['bumpversion', 'release', '--dry-run', '--verbose'],
50
+ stderr=subprocess.STDOUT)
51
+ m = re.search(r'Parsing version \'(\d+\.\d+\.\d+)\.dev\'', bumpver)
52
+ current_version = m.groups(0)[0] + ".dev"
53
+ m = re.search(r'New version will be \'(\d+\.\d+\.\d+)\'', bumpver)
54
+ release_version = m.groups(0)[0]
55
+
56
+ date = get_release_date()
57
+
58
+ current_version_title = generate_changelog_title(current_version)
59
+ release_version_title = generate_changelog_title(release_version)
60
+ changes = ""
61
+ with open(changelog) as fd:
62
+ changes += fd.read()
63
+
64
+ changes = changes.replace(current_version_title, release_version_title)\
65
+ .replace("**unreleased**", "Released on %s" % date)
66
+
67
+ with open(changelog, "w") as fd:
68
+ fd.write(changes)
69
+
70
+ # Tries to load the EDITOR environment variable, else falls back to vim
71
+ editor = os.environ.get('EDITOR', 'vim')
72
+ os.system("{} {}".format(editor, changelog))
73
+
74
+ subprocess.check_output(['gem', 'build', 'kameleon-builder.gemspec'])
75
+
76
+ # Have to add it so it will be part of the commit
77
+ subprocess.check_output(['git', 'add', changelog])
78
+ subprocess.check_output(
79
+ ['git', 'commit', '-m', 'Changelog for {}'.format(release_version)])
80
+
81
+ # Really run bumpver to set the new release and tag
82
+ bv_args = ['bumpversion', 'release']
83
+
84
+ bv_args += ['--new-version', release_version]
85
+
86
+ subprocess.check_output(bv_args)
87
+
88
+
89
+ def bump_new_version(args):
90
+ """Increment the version number to the next development version
91
+
92
+ * Bumps the development version number (with .bumpversion.cfg)
93
+ * Preloads the correct changelog template for editing
94
+
95
+ You can run it like::
96
+
97
+ $ python bumpversion.py newversion
98
+
99
+ which, by default, will create a 'patch' dev version (0.0.1 => 0.0.2-dev).
100
+
101
+ You can also specify a patch level (patch, minor, major) to change to::
102
+
103
+ $ python bumpversion.py newversion major
104
+
105
+ which will create a 'major' release (0.0.2 => 1.0.0-dev)."""
106
+ pass
107
+ # Dry run 'bumpversion' to find out what the new version number
108
+ # would be. Useful side effect: exits if the working directory is not
109
+ # clean.
110
+ changelog = args.changelog.name
111
+ part = args.part
112
+ bumpver = subprocess.check_output(
113
+ ['bumpversion', part, '--dry-run', '--verbose'],
114
+ stderr=subprocess.STDOUT)
115
+ m = re.search(r'Parsing version \'(\d+\.\d+\.\d+)\'', bumpver)
116
+ current_version = m.groups(0)[0]
117
+ m = re.search(r'New version will be \'(\d+\.\d+\.\d+)\.dev\'', bumpver)
118
+ next_version = m.groups(0)[0] + ".dev"
119
+
120
+ current_version_title = generate_changelog_title(current_version)
121
+ next_version_title = generate_changelog_title(next_version)
122
+
123
+ next_release_template = "%s\n\n**unreleased**\n\n" % next_version_title
124
+
125
+ changes = ""
126
+ with open(changelog) as fd:
127
+ changes += fd.read()
128
+
129
+ changes = changes.replace(current_version_title,
130
+ next_release_template + current_version_title)
131
+
132
+ with open(changelog, "w") as fd:
133
+ fd.write(changes)
134
+
135
+ # Tries to load the EDITOR environment variable, else falls back to vim
136
+ editor = os.environ.get('EDITOR', 'vim')
137
+ os.system("{} {}".format(editor, changelog))
138
+
139
+ # Have to add it so it will be part of the commit
140
+ subprocess.check_output(['git', 'add', changelog])
141
+ subprocess.check_output(
142
+ ['git', 'commit', '-m', 'Changelog for {}'.format(next_version)])
143
+
144
+ # Really run bumpver to set the new release and tag
145
+ bv_args = ['bumpversion', part, '--no-tag', '--new-version', next_version]
146
+
147
+ subprocess.check_output(bv_args)
148
+
149
+
150
+ def main():
151
+ '''Parse command-line arguments and execute bumpversion command.'''
152
+
153
+ parser = ArgumentParser(prog='bumpversion',
154
+ description='Bumpversion wrapper')
155
+
156
+ default_changelog = os.path.join(os.getcwd(), 'CHANGES')
157
+
158
+ subparsers = parser.add_subparsers(title='bumpversion wrapper commands')
159
+ # release command
160
+ release_doc = bump_release_version.__doc__
161
+ subparser = subparsers.add_parser("release",
162
+ description=release_doc,
163
+ formatter_class=RawTextHelpFormatter)
164
+ subparser.add_argument('--changelog', help='Project changelog',
165
+ type=FileType(),
166
+ default=default_changelog)
167
+ subparser.set_defaults(func=bump_release_version)
168
+ # newversion command
169
+ newversion_doc = bump_new_version.__doc__
170
+ subparser = subparsers.add_parser("newversion",
171
+ description=newversion_doc,
172
+ formatter_class=RawTextHelpFormatter)
173
+ subparser.add_argument('--changelog', help='Project changelog',
174
+ type=FileType(),
175
+ default=default_changelog)
176
+ subparser.add_argument('part', help='Part of the version to be bumped',
177
+ choices=['patch', 'minor', 'major'])
178
+ subparser.set_defaults(func=bump_new_version)
179
+ # Parse argv arguments
180
+ args = parser.parse_args()
181
+ args.func(args)
182
+
183
+ if __name__ == '__main__':
184
+ main()
data/version.txt CHANGED
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.6.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kameleon-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2015-05-13 00:00:00.000000000 Z
16
+ date: 2015-08-12 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: childprocess
@@ -153,8 +153,7 @@ files:
153
153
  - lib/kameleon/ui.rb
154
154
  - lib/kameleon/utils.rb
155
155
  - lib/kameleon/version.rb
156
- - scripts/bump-dev-version.py
157
- - scripts/bump-release-version.py
156
+ - scripts/bumpversion.py
158
157
  - tests/helper.rb
159
158
  - tests/recipes/steps/aliases/defaults.yaml
160
159
  - tests/recipes/steps/bootstrap/linux/bootstrap.yaml
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env python
2
- # coding: utf-8
3
- from __future__ import unicode_literals, print_function
4
- import argparse
5
- import re
6
- import os
7
- import subprocess
8
-
9
-
10
- def generate_changelog_title(version):
11
- version_title = "Version %s" % version
12
- return version_title + "\n" + "-" * len(version_title)
13
-
14
-
15
- def bump_dev_version(part='patch'):
16
- """ Increment the version number to the next development version
17
-
18
- * (Configurably) bumps the development dev version number
19
- * Preloads the correct changelog template for editing
20
-
21
- You can run it like::
22
-
23
- $ python scripts/next_release.py
24
-
25
- which, by default, will create a 'patch' dev version (0.0.1 => 0.0.2-dev).
26
-
27
- You can also specify a patch level (patch, minor, major) to change to::
28
-
29
- $ python scripts/make_release.py major
30
-
31
- which will create a 'major' release (0.0.2 => 1.0.0-dev).
32
-
33
- """
34
-
35
- # Dry run 'bumpversion' to find out what the new version number
36
- # would be. Useful side effect: exits if the working directory is not
37
- # clean.
38
-
39
- bumpver = subprocess.check_output(
40
- ['bumpversion', part, '--dry-run', '--verbose'],
41
- stderr=subprocess.STDOUT)
42
- m = re.search(r'Parsing version \'(\d+\.\d+\.\d+)\'', bumpver)
43
- current_version = m.groups(0)[0]
44
- m = re.search(r'New version will be \'(\d+\.\d+\.\d+)\.dev\'', bumpver)
45
- next_version = m.groups(0)[0] + ".dev"
46
-
47
- current_version_title = generate_changelog_title(current_version)
48
- next_version_title = generate_changelog_title(next_version)
49
-
50
- next_release_template = "%s\n\n**unreleased**\n\n" % next_version_title
51
-
52
- changes = ""
53
- with open('CHANGES') as fd:
54
- changes += fd.read()
55
-
56
- changes = changes.replace(current_version_title,
57
- next_release_template + current_version_title)
58
-
59
- with open('CHANGES', "w") as fd:
60
- fd.write(changes)
61
-
62
- # Tries to load the EDITOR environment variable, else falls back to vim
63
- editor = os.environ.get('EDITOR', 'vim')
64
- os.system("{} CHANGES".format(editor))
65
-
66
- subprocess.check_output(['python', 'setup.py', 'sdist'])
67
-
68
- # Have to add it so it will be part of the commit
69
- subprocess.check_output(['git', 'add', 'CHANGES'])
70
- subprocess.check_output(
71
- ['git', 'commit', '-m', 'Changelog for {}'.format(next_version)])
72
-
73
- # Really run bumpver to set the new release and tag
74
- bv_args = ['bumpversion', part, '--no-tag', '--new-version', next_version]
75
-
76
- subprocess.check_output(bv_args)
77
-
78
-
79
- if __name__ == '__main__':
80
- parser = argparse.ArgumentParser(
81
- description=bump_dev_version.__doc__,
82
- formatter_class=argparse.RawTextHelpFormatter
83
- )
84
- parser.add_argument("part", help="Part of the version to be bumped",
85
- choices=["patch", "minor", "major"])
86
- args = parser.parse_args()
87
- bump_dev_version(args.part)
@@ -1,92 +0,0 @@
1
- #!/usr/bin/env python
2
- # coding: utf-8
3
- from __future__ import unicode_literals, print_function
4
- import os
5
- import re
6
-
7
- from io import open
8
-
9
- import argparse
10
- import datetime
11
- import subprocess
12
-
13
-
14
- def generate_changelog_title(version):
15
- version_title = "Version %s" % version
16
- return version_title + "\n" + "-" * len(version_title)
17
-
18
-
19
- def get_release_date():
20
- dt = datetime.date.today()
21
- if 4 <= dt.day <= 20 or 24 <= dt.day <= 30:
22
- suffix = "th"
23
- else:
24
- suffix = ["st", "nd", "rd"][dt.day % 10 - 1]
25
- return dt.strftime("%%B %%d%s %%Y" % suffix)
26
-
27
-
28
- def bumpversion():
29
- """ Automated software release workflow
30
-
31
- * (Configurably) bumps the release version number
32
- * Preloads the correct changelog template for editing
33
- * Builds a source distribution
34
- * Sets release date
35
- * Tags the release
36
-
37
- You can run it like::
38
-
39
- $ python scripts/bumpversion.py
40
-
41
- """
42
-
43
- # Dry run 'bumpversion' to find out what the new version number
44
- # would be. Useful side effect: exits if the working directory is not
45
- # clean.
46
-
47
- bumpver = subprocess.check_output(
48
- ['bumpversion', 'release', '--dry-run', '--verbose'],
49
- stderr=subprocess.STDOUT)
50
- m = re.search(r'Parsing version \'(\d+\.\d+\.\d+)\.dev\'', bumpver)
51
- current_version = m.groups(0)[0] + ".dev"
52
- m = re.search(r'New version will be \'(\d+\.\d+\.\d+)\'', bumpver)
53
- release_version = m.groups(0)[0]
54
-
55
- date = get_release_date()
56
-
57
- current_version_title = generate_changelog_title(current_version)
58
- release_version_title = generate_changelog_title(release_version)
59
- changes = ""
60
- with open('CHANGES') as fd:
61
- changes += fd.read()
62
-
63
- changes = changes.replace(current_version_title, release_version_title)\
64
- .replace("**unreleased**", "Released on %s" % date)
65
-
66
- with open('CHANGES', "w") as fd:
67
- fd.write(changes)
68
-
69
- # Tries to load the EDITOR environment variable, else falls back to vim
70
- editor = os.environ.get('EDITOR', 'vim')
71
- os.system("{} CHANGES".format(editor))
72
-
73
- # Have to add it so it will be part of the commit
74
- subprocess.check_output(['git', 'add', 'CHANGES'])
75
- subprocess.check_output(
76
- ['git', 'commit', '-m', 'Changelog for {}'.format(release_version)])
77
-
78
- # Really run bumpver to set the new release and tag
79
- bv_args = ['bumpversion', 'release']
80
-
81
- bv_args += ['--new-version', release_version]
82
-
83
- subprocess.check_output(bv_args)
84
-
85
-
86
- if __name__ == '__main__':
87
- parser = argparse.ArgumentParser(
88
- description=bumpversion.__doc__,
89
- formatter_class=argparse.RawTextHelpFormatter
90
- )
91
- args = parser.parse_args()
92
- bumpversion()