release_manager 0.5.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93411362c88f291cac34ce961bc4c40ab7e524af
4
- data.tar.gz: b53bb842f8c4fb2a2990321ccbfc5c6205a46763
3
+ metadata.gz: 03f488ec3c5ca203a22ebc5fdc6c3f35659fc3ab
4
+ data.tar.gz: e0d8bc478030066ccaf0aea96a548bcda45461c1
5
5
  SHA512:
6
- metadata.gz: a09045619e1e27ef1ed4a723326ba7e069b8fb5b1a3b5e342572f06889675f43887addee10028c96a7d19d504c15550c8ee14c532d7693a71db90e912fe012f8
7
- data.tar.gz: 4c4ba1d7e48ddd825397e3e315ffe4d48c2b6e9698dc35cffd303a3b87cb0ce39db7e84a5d91f913daeefdc5f46db3ee90db92336730883935c973b72d7aeaa9
6
+ metadata.gz: bdf95bd7a453b7ae03e108d23808dfce2194e50dfd3a27680d0219ddb32ad05ed45534e282af17f12f3bb8a39e653f905cdc9786b899e6268865a8b5f0a964db
7
+ data.tar.gz: b9af8ec32da6a2743e822e3451b198d3663062d3866519f6fb19bbf1bab3c0703c66925f824c94d4cf8202b5cdeef677a41cd731d76575bbb4a79a774d1a3788
data/.gitignore CHANGED
@@ -8,7 +8,10 @@
8
8
  /pkg/
9
9
  /spec/reports/
10
10
  /tmp/
11
- srv/
11
+ srv/gitlab/data
12
+ srv/gitlab/logs
13
+ .env
14
+ srv2
12
15
  bundl
13
16
  # rspec failure tracking
14
17
  .rspec_status
@@ -2,10 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.6.0
6
+ * Adds the ability to release-mod to dump a specific SemVer release level
7
+ * Fixes issue with changelog file not existing
8
+
5
9
  ## 0.5.3
10
+
6
11
  * Fixes output when applying patch
12
+
7
13
  ## 0.5.2
14
+
8
15
  * Adds proper error handling when missing git author name and email with r10k-deploy
16
+
9
17
  ## 0.5.1
10
18
  * Fixes missing error object when credentials are not present
11
19
  * Fixes error when deploy-r10k is used and remote setting was not set
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  FROM ruby:2.3.4
2
- RUN apt-get update && apt-get install -y libssh2-1-dev tree git zsh libssh2-1 vim cmake && apt-get clean
2
+ RUN apt-get update && apt-get install -y libssh2-1-dev tree git zsh libssh2-1 zlib1g-dev vim cmake && apt-get clean
3
3
  RUN useradd -m appuser && su - appuser -c 'ssh-keygen -t rsa -N "" -f /home/appuser/.ssh/id_rsa' && mkdir /app \
4
4
  && chown appuser:appuser /app
5
5
  COPY ./Gemfile* /app/
@@ -7,8 +7,9 @@ COPY .bash_profile /home/appuser/.bash_profile
7
7
  RUN su - appuser -c 'git config --global user.email "user@example.com"' && \
8
8
  su - appuser -c 'git config --global user.name "Example User"' && \
9
9
  chown -R appuser:appuser /home/appuser/ && \
10
- chown -R appuser:appuser /app
11
- RUN su - appuser -c "BUNDLE_PATH='/home/appuser/.bundle' GEM_HOME='/home/appuser/.gems' bundle install --gemfile=/app/Gemfile" \
10
+ chown -R appuser:appuser /app && \
11
+ gem install gitlab rugged
12
+ RUN su - appuser -c "BUNDLE_PATH=/home/appuser/.bundle GEM_HOME=/home/appuser/.gems bundle install --gemfile=/app/Gemfile" \
12
13
  && rm -f /app/*
13
14
  # update PATH to find local gems
14
15
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- release_manager (0.5.3)
4
+ release_manager (0.6.0)
5
5
  gitlab (~> 4.2.0)
6
6
  highline (~> 1.7)
7
7
  rugged (~> 0.26)
@@ -10,27 +10,26 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  ast (2.3.0)
13
- coderay (1.1.1)
13
+ coderay (1.1.2)
14
14
  diff-lcs (1.3)
15
15
  gitlab (4.2.0)
16
16
  httparty
17
17
  terminal-table
18
18
  highline (1.7.8)
19
- httparty (0.15.5)
19
+ httparty (0.15.6)
20
20
  multi_xml (>= 0.5.2)
21
- method_source (0.8.2)
21
+ method_source (0.9.0)
22
22
  multi_xml (0.6.0)
23
- parallel (1.11.2)
23
+ parallel (1.12.0)
24
24
  parser (2.4.0.0)
25
25
  ast (~> 2.2)
26
26
  powerpack (0.1.1)
27
- pry (0.10.4)
27
+ pry (0.11.1)
28
28
  coderay (~> 1.1.0)
29
- method_source (~> 0.8.1)
30
- slop (~> 3.4)
29
+ method_source (~> 0.9.0)
31
30
  rainbow (2.2.2)
32
31
  rake
33
- rake (12.0.0)
32
+ rake (12.1.0)
34
33
  rspec (3.6.0)
35
34
  rspec-core (~> 3.6.0)
36
35
  rspec-expectations (~> 3.6.0)
@@ -44,16 +43,15 @@ GEM
44
43
  diff-lcs (>= 1.2.0, < 2.0)
45
44
  rspec-support (~> 3.6.0)
46
45
  rspec-support (3.6.0)
47
- rubocop (0.49.1)
46
+ rubocop (0.50.0)
48
47
  parallel (~> 1.10)
49
48
  parser (>= 2.3.3.1, < 3.0)
50
49
  powerpack (~> 0.1)
51
- rainbow (>= 1.99.1, < 3.0)
50
+ rainbow (>= 2.2.2, < 3.0)
52
51
  ruby-progressbar (~> 1.7)
53
52
  unicode-display_width (~> 1.0, >= 1.0.1)
54
- ruby-progressbar (1.8.1)
53
+ ruby-progressbar (1.8.3)
55
54
  rugged (0.26.0)
56
- slop (3.6.0)
57
55
  terminal-table (1.8.0)
58
56
  unicode-display_width (~> 1.1, >= 1.1.1)
59
57
  unicode-display_width (1.3.0)
@@ -73,4 +71,4 @@ DEPENDENCIES
73
71
  rugged (~> 0.26)
74
72
 
75
73
  BUNDLED WITH
76
- 1.15.2
74
+ 1.15.4
data/README.md CHANGED
@@ -202,6 +202,7 @@ Summary: Bumps the module version to the next revision and
202
202
 
203
203
  -d, --dry-run Do a dry run, without making changes
204
204
  -a, --auto Run this script without interaction
205
+ -l, --level Semantic versioning level to bump (major.minor.patch), defaults to patch
205
206
  -m, --module-path The path to the module, defaults to current working directory
206
207
  -b, --no-bump Do not bump the version in metadata.json
207
208
  -r, --repo [REPO] The repo to use, defaults to repo found in the metadata source
@@ -311,6 +312,50 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
311
312
 
312
313
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
313
314
 
315
+
316
+ ## Develpment Environment Setup
317
+ ### Setting up your Gitlab Instance
318
+ 1. Ensure you have docker installed
319
+ 2. `docker-compose up`
320
+ 3. Visit http://localhost:8000/
321
+ 4. Create a password (password123)
322
+ 5. Login (root/password123)
323
+ 6. Create a user account for yourself (add Admin role)
324
+ 7. Logout as Admin and login as the new user account
325
+ 8. Add a group named devops and add yourself to this group
326
+ 9. Add another group called mirrors and add yourself to this group
327
+ 10. Create a `.env` file in the repo directory and paste these contents in it
328
+ ```ruby
329
+ GITLAB_API_ENDPOINT='http://web/api/v4'
330
+ GITLAB_API_PRIVATE_TOKEN='your token goes here'
331
+ R10K_REPO_URL="git@web:devops/control-repo.git"
332
+
333
+ ```
334
+ 11. Create an Personal Access Token (API) token for your user account
335
+ 12. Replace the token in your .env file
336
+
337
+ ### Configure your release manager client
338
+ 1. run `docker-compose run client`
339
+ 2. From the container run source .env
340
+ 3. From client container `source .bash_profile`
341
+ 4. Add the ~/.ssh/id_rsa.pub key to your gitlab account
342
+ 5. From the new client container session, run `bundle exec bash app_startup_script.sh`
343
+ 6. From the client container, run `bundle exec ruby setup_repos.rb`
344
+ 7. From the client container attempt to connect to the git server and accept the key `ssh git@web`
345
+ 8. Test to ensure you can clone a repository inside the container `git clone git@web:devops/docker.git /tmp/docker`
346
+
347
+ ### Testing the cli commands
348
+ 1. `bundle exec exe/sandbox-create -n my_sandbox -m docker` # example
349
+ 2. `bundle exec exe/release-mod --level minor -m ~/repos/docker`
350
+
351
+ ### Debugging
352
+ if you cannot connect to the gitlab server via ssh you see errros about private key
353
+ has wrong permission you will need to do the following:
354
+
355
+ `chmod 600 srv/gitlab/config/ssh_host_ecdsa_key srv/gitlab/config/ssh_host_ed25519_key srv/gitlab/config/ssh_host_rsa_key`
356
+
357
+ If the sandbox create command freezes after the first output make sure you can connect
358
+ to the git server using git clone or running `ssh-add` to add your ssh key to the ssh agent.
314
359
  ## Contributing
315
360
 
316
361
  Bug reports and pull requests are welcome on release_manager.
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  bundle install
4
- ssh-add
4
+ ssh-add
@@ -1,48 +1,49 @@
1
- version: '2'
1
+ version: '3'
2
2
  services:
3
- app:
4
- image: nwops/release_manager
3
+ client:
4
+ image: nwops/release_manager:latest
5
5
  build: .
6
6
  entrypoint:
7
7
  - ssh-agent
8
8
  - /bin/bash
9
9
  environment:
10
- GEM_HOME: '/home/appuser/.gems'
11
- BUNDLE_PATH: '/home/appuser/.bundle'
12
- GITLAB_API_ENDPOINT: 'http://web/api/v4'
13
- # the token may change so this really needs to be more dynamic
14
- GITLAB_API_PRIVATE_TOKEN: 'A_zJJfgE8P-8mFGK2_r9'
15
- R10K_REPO_URL: "git@web:devops/control-repo.git"
10
+ - GEM_HOME=/home/appuser/.gems
11
+ - BUNDLE_PATH=/home/appuser/.bundle
12
+ - GITLAB_API_ENDPOINT=http://web/api/v4
13
+ - GITLAB_API_PRIVATE_TOKEN
14
+ - R10K_REPO_URL="git@web:devops/control-repo.git"
16
15
  working_dir: /app
17
16
  # command:
18
17
  # - app_startup_script.sh
19
18
  volumes:
20
19
  - .:/app
21
20
  runner:
22
- image: 'registry.gitlab.com/gitlab-org/gitlab-ci-multi-runner:ubuntu-v9.3.0'
21
+ depends_on:
22
+ - web
23
+ image: 'gitlab/gitlab-runner:ubuntu-v9.5.0'
23
24
  volumes:
24
25
  - './srv/gitlab-runner/config:/etc/gitlab-runner'
25
26
  - '/var/run/docker.sock:/var/run/docker.sock'
26
27
  environment:
27
- DOCKER_NETWORK_MODE: 'releasemanager_default'
28
- RUNNER_TAG_LIST: 'ruby'
29
- REGISTRATION_TOKEN: 'W_nSSWTvuYmGUmUbh65y'
30
- RUNNER_NAME: 'test-runner'
31
- CI_SERVER_URL: 'http://web/ci'
32
- RUNNER_EXECUTOR: 'docker'
33
- GITLAB_API_ENDPOINT: 'http://web/api/v4'
34
- REGISTER_RUN_UNTAGGED: 'true'
35
- DOCKER_IMAGE: 'ruby:2.1'
36
- REGISTER_LOCKED: 'false'
28
+ - DOCKER_NETWORK_MODE=releasemanager_default
29
+ - RUNNER_TAG_LIST=ruby
30
+ - REGISTRATION_TOKEN=W_nSSWTvuYmGUmUbh65y
31
+ - RUNNER_NAME=test-runner
32
+ - CI_SERVER_URL=http://web/ci
33
+ - RUNNER_EXECUTOR=docker
34
+ - GITLAB_API_ENDPOINT=http://web/api/v4
35
+ - REGISTER_RUN_UNTAGGED=true
36
+ - DOCKER_IMAGE=ruby:2.1
37
+ - REGISTER_LOCKED=false
37
38
  # the token may change so this really needs to be more dynamic
38
- GITLAB_API_PRIVATE_TOKEN: 'A_zJJfgE8P-8mFGK2_r9'
39
+ - GITLAB_API_PRIVATE_TOKEN
39
40
  #entrypoint:
40
41
  web:
41
- image: 'gitlab/gitlab-ce:latest'
42
+ image: 'gitlab/gitlab-ce:9.5.5-ce.0'
42
43
  restart: always
43
- environment:
44
- GITLAB_OMNIBUS_CONFIG: |
45
- external_url 'http://web'
44
+ # environment:
45
+ # GITLAB_OMNIBUS_CONFIG: |
46
+ # external_url http://web
46
47
  ports:
47
48
  - '8000:80'
48
49
  - '4433:443'
@@ -110,7 +110,7 @@ class Changelog < WorkflowAction
110
110
  # checks to make sure the unreleased line is valid, and the file exists
111
111
  def self.check_requirements(path)
112
112
  log = new(path, nil)
113
- log.unreleased_index if File.exists?(log.changelog_file)
113
+ log.unreleased_index
114
114
  end
115
115
 
116
116
  private
@@ -25,10 +25,10 @@ module ReleaseManager
25
25
  opts.version = ReleaseManager::VERSION
26
26
  opts.on_head(<<-EOF
27
27
 
28
- Summary: Bumps the module version to the next revision and
28
+ Summary: Bumps the module version to the next revision and
29
29
  updates the changelog.md file with the new
30
30
  version by reading the metadata.json file. This should
31
- be run inside a module directory.
31
+ be run inside a module directory.
32
32
 
33
33
  EOF
34
34
  )
@@ -36,7 +36,10 @@ Summary: Bumps the module version to the next revision and
36
36
  options[:dry_run] = c
37
37
  end
38
38
  opts.on('-a', '--auto', 'Run this script without interaction') do |c|
39
- options[:auto] = c
39
+ options[:auto] = c
40
+ end
41
+ opts.on('-l', '--level [LEVEL]', 'Semantic versioning level to bump (major,minor,patch), defaults to patch') do |c|
42
+ options[:level] = c
40
43
  end
41
44
  opts.on('-m', '--module-path [MODULEPATH]', "The path to the module, defaults to #{Dir.getwd}") do |c|
42
45
  options[:path] = c
@@ -54,6 +57,15 @@ Summary: Bumps the module version to the next revision and
54
57
  options[:remote] = true
55
58
  end
56
59
  end.parse!
60
+
61
+ # default to patch
62
+ options[:level] ||= 'patch'
63
+
64
+ # validate -l, --level input
65
+ unless %w(major minor patch).include?(options[:level])
66
+ puts "expected major minor or patch for parameter -l, --level. You supplied #{options[:level]}.".fatal
67
+ exit 1
68
+ end
57
69
  r = options[:remote] ?
58
70
  RemoteRelease.new(options[:path], options) : Release.new(options[:path], options)
59
71
  r.run
@@ -16,7 +16,7 @@ class PuppetModule < WorkflowAction
16
16
  def initialize(mod_path, upstream = nil)
17
17
  raise ModNotFoundException.new("#{mod_path} is not a valid puppet module path") if mod_path.nil?
18
18
  @path = mod_path
19
- @upstream = upstream
19
+ @upstream = upstream
20
20
  @metadata_file = File.join(mod_path, 'metadata.json')
21
21
  end
22
22
 
@@ -33,8 +33,8 @@ class PuppetModule < WorkflowAction
33
33
  def name
34
34
  namespaced_name.split(/\/|\-/).last
35
35
  end
36
-
37
- def namespaced_name
36
+
37
+ def namespaced_name
38
38
  metadata['name']
39
39
  end
40
40
 
@@ -105,6 +105,28 @@ class PuppetModule < WorkflowAction
105
105
  metadata['version']
106
106
  end
107
107
 
108
+ # @returns [String] the next version based on the release level
109
+ def next_version(level = 'patch')
110
+ return unless version
111
+ pieces = version.split('.')
112
+ raise "invalid semver structure #{version}" if pieces.count != 3
113
+
114
+ case level
115
+ when 'major'
116
+ pieces[2] = '0'
117
+ pieces[1] = '0'
118
+ pieces[0] = pieces[0].next
119
+ when 'minor'
120
+ pieces[2] = '0'
121
+ pieces[1] = pieces[1].next
122
+ when 'patch'
123
+ pieces[2] = pieces[2].next
124
+ else
125
+ raise "expected semver release level major, minor or patch"
126
+ end
127
+ pieces.join('.')
128
+ end
129
+
108
130
  # @param remote [Boolean] - create the tag remotely using the remote VCS
109
131
  # @param id [String] - the commit id to tag to
110
132
  def tag_module(remote = false, id = nil)
@@ -120,32 +142,17 @@ class PuppetModule < WorkflowAction
120
142
 
121
143
  # Updates the version in memory
122
144
  def bump_patch_version
123
- return unless version
124
- pieces = version.split('.')
125
- raise "invalid semver structure #{version}" if pieces.count != 3
126
- pieces[2] = pieces[2].next
127
- metadata['version'] = pieces.join('.')
145
+ metadata['version'] = next_version('patch')
128
146
  end
129
147
 
130
148
  # Updates the version in memory
131
149
  def bump_minor_version
132
- return unless version
133
- pieces = version.split('.')
134
- raise "invalid semver structure #{version}" if pieces.count != 3
135
- pieces[2] = '0'
136
- pieces[1] = pieces[1].next
137
- metadata['version'] = pieces.join('.')
150
+ metadata['version'] = next_version('minor')
138
151
  end
139
152
 
140
153
  # Updates the version in memory
141
154
  def bump_major_version
142
- return unless version
143
- pieces = version.split('.')
144
- raise "invalid semver structure #{version}" if pieces.count != 3
145
- pieces[2] = '0'
146
- pieces[1] = '0'
147
- pieces[0] = pieces[0].next
148
- metadata['version'] = pieces.join('.')
155
+ metadata['version'] = next_version('major')
149
156
  end
150
157
 
151
158
  def to_s
@@ -6,16 +6,16 @@ class Release
6
6
  include ReleaseManager::Logger
7
7
 
8
8
  def initialize(path = Dir.getwd, options = {})
9
- @path = path || Dir.getwd
9
+ @path = path || Dir.getwd
10
10
  @options = options
11
11
  end
12
-
12
+
13
13
  def puppet_module
14
14
  @puppet_module ||= PuppetModule.new(path, upstream_repo)
15
15
  end
16
16
 
17
- def upstream_repo
18
- options[:repo] || ENV['UPSTREAM_REPO']
17
+ def upstream_repo
18
+ options[:repo] || ENV['UPSTREAM_REPO']
19
19
  end
20
20
 
21
21
  # @returns [String] the version found in the metadata file
@@ -23,8 +23,13 @@ class Release
23
23
  dry_run? ? next_version : puppet_module.version
24
24
  end
25
25
 
26
+ # @returns [String] the release level
27
+ def level
28
+ options[:level] || 'patch'
29
+ end
30
+
26
31
  def next_version
27
- puppet_module.version.next
32
+ puppet_module.next_version(level)
28
33
  end
29
34
 
30
35
  def tag(id)
@@ -41,7 +46,9 @@ class Release
41
46
  return
42
47
  end
43
48
  raise TagExists.new("Tag v#{version} already exists") if puppet_module.tag_exists?("v#{next_version}", options[:remote])
44
- version = puppet_module.bump_patch_version unless options[:bump]
49
+ if puppet_module.respond_to?("bump_#{level}_version".to_sym)
50
+ version = puppet_module.public_send("bump_#{level}_version".to_sym) unless options[:bump]
51
+ end
45
52
  # save the update version to the metadata file, then commit
46
53
  puppet_module.commit_metadata(options[:remote])
47
54
  end
@@ -95,9 +102,9 @@ class Release
95
102
  end
96
103
  end
97
104
 
98
- # runs all the required steps to release the software
105
+ # runs all the required steps to release the software
99
106
  # currently this must be done manually by a release manager
100
- #
107
+ #
101
108
  def release
102
109
  unless auto_release?
103
110
  print "Have you merged your code? Did you fetch and rebase against the upstream? Want to continue (y/n)?: ".yellow
@@ -114,7 +121,7 @@ class Release
114
121
  # tags the r10k-module with the version found in the metadata.json file
115
122
  tag(id)
116
123
  # pushes the updated code and tags to the upstream repo
117
- if auto_release?
124
+ if auto_release?
118
125
  push
119
126
  return
120
127
  end
@@ -125,8 +132,8 @@ class Release
125
132
  $?.success?
126
133
  else
127
134
  puts "Nah, forget it, this release wasn't that cool anyways.".yellow
128
- false
129
- end
135
+ false
136
+ end
130
137
  end
131
138
 
132
139
  def add_upstream_remote