simple-cli 0.3.3 → 0.3.4

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: 43c838ad9921bef80717cd3a61c33d68e794adb84799b7e764cc8f23e8fc30db
4
- data.tar.gz: a3266ec697b770e68add5bbe8511db6253aa9453e4bde36cf86cddecc5577bff
3
+ metadata.gz: 396da74801c8dbe4910923bec2ad720181966e27c543afee855ff15b8e807f28
4
+ data.tar.gz: f2f1d11130bd1b2ac43c40308c71eaec78a148662ab65ce55b5dcbdaa201834c
5
5
  SHA512:
6
- metadata.gz: 198ffc917415a4221f1b2de93ff32f42e55dfb480b0bd8f51b2d191277ac3206c801d0cc14ada5bc6c18e2aad38447ddf93a1b303f0254e9f28e2821907f654b
7
- data.tar.gz: cc2f55d0a681d4376eeff4b76f27f40199e3248b53736fe8f1061307328764477e212cff2e429a01c1dc28b7f214e0eb19f8839acc30e5e65d0d8196115c4c2d
6
+ metadata.gz: 10b9f1865828bba3102bd0a93f711d99449923a6d8159597035dd552174411c0c3286071c69005fe400948f10acb534ed87ba9a7e436647f36b47e49c6337953
7
+ data.tar.gz: 6c36d0894fc438c4058824239db56020b8075193daa6638f93587e712c8e2dfa128999b56bde2802c2d23dace843800cab7f8c98d94cc6c3a1d5ebf4ee5a8d89
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
data/scripts/release ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ $0.rb "$@"
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # -- helpers ------------------------------------------------------------------
4
+
5
+ def sys(cmd)
6
+ STDERR.puts "> #{cmd}"
7
+ system cmd
8
+ return true if $?.success?
9
+
10
+ STDERR.puts "> #{cmd} returned with exitstatus #{$?.exitstatus}"
11
+ $?.success?
12
+ end
13
+
14
+ def sys!(cmd, error: nil)
15
+ return true if sys(cmd)
16
+ STDERR.puts error if error
17
+ exit 1
18
+ end
19
+
20
+ def die!(msg)
21
+ STDERR.puts msg
22
+ exit 1
23
+ end
24
+
25
+ ROOT = File.expand_path("#{File.dirname(__FILE__)}/..")
26
+
27
+ GEMSPEC = Dir.glob("*.gemspec").first || die!("Missing gemspec file.")
28
+
29
+ # -- Version reading and bumping ----------------------------------------------
30
+
31
+ module Version
32
+ extend self
33
+
34
+ VERSION_FILE = "#{Dir.getwd}/VERSION"
35
+
36
+ def read_version
37
+ version = File.exist?(VERSION_FILE) ? File.read(VERSION_FILE) : "0.0.1"
38
+ version.chomp!
39
+ raise "Invalid version number in #{VERSION_FILE}" unless version =~ /^\d+\.\d+\.\d+$/
40
+ version
41
+ end
42
+
43
+ def auto_version_bump
44
+ old_version_number = read_version
45
+ old = old_version_number.split(".")
46
+
47
+ current = old[0..-2] << old[-1].next
48
+ current.join(".")
49
+ end
50
+
51
+ def bump_version
52
+ next_version = ENV["VERSION"] || auto_version_bump
53
+ File.open(VERSION_FILE, "w") { |io| io.write next_version }
54
+ end
55
+ end
56
+
57
+ # -- check, bump, release a new gem version -----------------------------------
58
+
59
+ Dir.chdir ROOT
60
+ $BASE_BRANCH = ENV["BRANCH"] || "master"
61
+
62
+ # ENV["BUNDLE_GEMFILE"] = "#{Dir.getwd}/Gemfile"
63
+ # sys! "bundle install"
64
+
65
+ sys! "git diff --exit-code > /dev/null", error: "There are unstaged changes in your working directory"
66
+ sys! "git diff --cached --exit-code > /dev/null", error: "There are staged but uncommitted changes"
67
+
68
+ sys! "git checkout #{$BASE_BRANCH}"
69
+ sys! "git pull"
70
+
71
+ Version.bump_version
72
+ version = Version.read_version
73
+
74
+ sys! "git add VERSION"
75
+ sys! "git commit -m \"bump gem to v#{version}\""
76
+ sys! "git tag -a v#{version} -m \"Tag #{version}\""
77
+
78
+ sys! "gem build #{GEMSPEC}"
79
+
80
+ sys! "git push origin #{$BASE_BRANCH}"
81
+ sys! "git push --tags --force"
82
+ sys! "gem push #{Dir.glob("*.gem").first}"
83
+
84
+ sys! "mkdir -p pkg"
85
+ sys! "mv *.gem pkg"
86
+
87
+ STDERR.puts <<~MSG
88
+ ================================================================================
89
+ Thank you for releasing a new gem version. You made my day.
90
+ ================================================================================
91
+ MSG
data/simple-cli.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
27
27
  gem.required_ruby_version = '~> 2.3'
28
28
 
29
29
  # optional gems (required by some of the parts)
30
- gem.add_dependency "simple-service", "~> 0.1.2"
30
+ gem.add_dependency "simple-service", "~> 0.1.4"
31
31
 
32
32
  # development gems
33
33
  gem.add_development_dependency 'rake', '~> 12'
data/tasks/release.rake CHANGED
@@ -1,89 +1,3 @@
1
- require 'bundler'
2
- Bundler.setup
3
-
4
- GEM_ROOT = File.expand_path('../../', __FILE__)
5
- GEM_SPEC = "simple-cli.gemspec"
6
-
7
- require 'simple/cli/version'
8
- VERSION_FILE_PATH = 'lib/simple/cli/version.rb'
9
-
10
- class VersionNumberTracker
11
- class << self
12
- def update_version_file(old_version_number, new_version_number)
13
- old_line = "VERSION = \"#{old_version_number}\""
14
- new_line = "VERSION = \"#{new_version_number}\""
15
- update = File.read(VERSION_FILE_PATH).gsub(old_line, new_line)
16
- File.open(VERSION_FILE_PATH, 'w') { |file| file.puts update }
17
- new_version_number
18
- end
19
-
20
- def auto_version_bump
21
- old_version_number = Simple::CLI::VERSION
22
- old = old_version_number.split('.')
23
- current = old[0..-2] << old[-1].next
24
- new_version_number = current.join('.')
25
-
26
- update_version_file(old_version_number, new_version_number)
27
- end
28
-
29
- def manual_version_bump
30
- update_version_file(Simple::CLI::VERSION, ENV['VERSION'])
31
- end
32
-
33
- def update_version_number
34
- @version = ENV['VERSION'] ? manual_version_bump : auto_version_bump
35
- end
36
-
37
- attr_reader :version
38
- end
1
+ task :release do
2
+ sh "scripts/release"
39
3
  end
40
-
41
- namespace :release do
42
- task :version do
43
- VersionNumberTracker.update_version_number
44
- end
45
-
46
- task :build do
47
- Dir.chdir(GEM_ROOT) do
48
- sh("gem build #{GEM_SPEC}")
49
- end
50
- end
51
-
52
- desc "Commit changes"
53
- task :commit do
54
- Dir.chdir(GEM_ROOT) do
55
- version = VersionNumberTracker.version
56
- sh("git add #{VERSION_FILE_PATH}")
57
- sh("git commit -m \"bump to v#{version}\"")
58
- sh("git tag -a v#{version} -m \"Tag\"")
59
- end
60
- end
61
-
62
- desc "Push code and tags"
63
- task :push do
64
- sh('git push origin master')
65
- sh('git push --tags')
66
- end
67
-
68
- desc "Cleanup"
69
- task :clean do
70
- Dir.glob(File.join(GEM_ROOT, '*.gem')).each { |f| FileUtils.rm_rf(f) }
71
- end
72
-
73
- desc "Push Gem to gemfury"
74
- task :push_to_rubygems do
75
- Dir.chdir(GEM_ROOT) { sh("gem push #{Dir.glob('*.gem').first}") }
76
- end
77
-
78
- task default: [
79
- 'version',
80
- 'clean',
81
- 'build',
82
- 'commit',
83
- 'push',
84
- 'push_to_rubygems'
85
- ]
86
- end
87
-
88
- desc "Clean, build, commit and push"
89
- task release: 'release:default'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-11-29 00:00:00.000000000 Z
12
+ date: 2019-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: simple-service
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.1.2
20
+ version: 0.1.4
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.1.2
27
+ version: 0.1.4
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -109,6 +109,8 @@ files:
109
109
  - lib/simple/cli/runner.rb
110
110
  - lib/simple/cli/version.rb
111
111
  - log/.gitkeep
112
+ - scripts/release
113
+ - scripts/release.rb
112
114
  - simple-cli.gemspec
113
115
  - spec/.keep
114
116
  - spec/spec_helper.rb