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
|
# File 'lib/release_manager/cli/release_mod_cli.rb', line 21
def self.run
options = {}
OptionParser.new do |opts|
opts.program_name = 'release-mod'
opts.version = ReleaseManager::VERSION
opts.on_head("\nSummary: Bumps the module version to the next revision and\n updates the changelog.md file with the new\n version by reading the metadata.json file. This should\n be run inside a module directory.\n\n Examples:\n release-mod -l minor\n release-mod -l patch -s patch1\n release-mod -m ~/repos/r10k-control\n \n\nConfiguration:\n\nThis script uses the following environment variables to automatically set some options, please ensure \nthey exist in your shell environment. You can set an environment variable in the shell or define \nin your shell startup files.\n\nShell: export VARIABLE_NAME=value\n\nR10K_REPO_URL - The git repo url to r10k-control (ie. [email protected]:devops/r10k-control.git)\nGITLAB_API_ENDPOINT - The api path to the gitlab server (ie. https://gitlab_server/api/v4)\n replace gitlab_server with your server hostname\nGITLAB_API_PRIVATE_TOKEN - The gitlab user api token. \n You can get a token here (\#{ReleaseManager.gitlab_server}/profile/personal_access_tokens), \n Ensure api box is checked.\n\nOptions:\n EOF\n )\n opts.on(\"-d\", \"--dry-run\", \"Do a dry run, without making changes\") do |c|\n options[:dry_run] = c\n end\n opts.on('-a', '--auto', 'Run this script without interaction') do |c|\n options[:auto] = c \n end\n opts.on('-l', '--level [LEVEL]', 'Semantic versioning level to bump (major,minor,patch), defaults to patch') do |c|\n options[:level] = c \n end\n opts.on('-m', '--module-path [MODULEPATH]', \"The path to the module, defaults to \#{Dir.getwd}\") do |c|\n options[:path] = c\n end\n opts.on('-b', '--no-bump', \"Do not bump the version in metadata.json\") do |c|\n options[:bump] = c\n end\n opts.on('-r', '--repo [REPO]', \"The repo to use, defaults to repo found in the metadata source\") do |c|\n options[:repo] = c\n end\n opts.on('--verbose', \"Extra logging\") do |c|\n options[:verbose] = c\n end\n opts.on('-s', '--src-branch [BRANCH]', 'The branch you want to base the release from, defaults to dev or master') do |c|\n options[:src_branch] = c\n end\n opts.on('-r', '--remote-release', \"Perform a remote release (For CI systems)\") do |c|\n options[:remote] = true\n end\n end.parse!\n\n unless ENV['GITLAB_API_ENDPOINT']\n puts \"Please set the GITLAB_API_ENDPOINT environment variable\".fatal\n puts \"Example: export GITLAB_API_ENDPOINT=https://gitlab.com/api/v4\".fatal\n exit 1\n end\n\n unless ENV['GITLAB_API_PRIVATE_TOKEN']\n puts \"Please set the GITLAB_API_PRIVATE_TOKEN environment variable\".fatal\n puts \"Example: export GITLAB_API_PRIVATE_TOKEN=kdii2ljljijsldjfoa\".fatal\n exit 1\n end\n\n # default to patch\n options[:level] ||= 'patch'\n\n # validate -l, --level input\n unless %w(major minor patch).include?(options[:level])\n puts \"expected major minor or patch for parameter -l, --level. You supplied \#{options[:level]}.\".fatal\n exit 1\n end\n ReleaseManager::VCSManager.default_instance.validate_authorization\n r = options[:remote] ?\n RemoteRelease.new(options[:path], options) : Release.new(options[:path], options)\n r.run\nend\n"
|