wooga_wooget 2.1.2 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +20 -0
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +1 -11
- data/README.md +2 -0
- data/Rakefile +8 -0
- data/bin/console +7 -0
- data/bin/setup +8 -0
- data/bin/wooget +5 -2
- data/exe/wooget +12 -0
- data/lib/wooget.rb +4 -3
- data/lib/wooget/build/build_info.rb +8 -0
- data/lib/wooget/build/builder.rb +15 -22
- data/lib/wooget/cli.rb +32 -1
- data/lib/wooget/default.rb +36 -0
- data/lib/wooget/github.rb +109 -0
- data/lib/wooget/releasing.rb +16 -0
- data/lib/wooget/version.rb +1 -1
- data/wooget.gemspec +8 -1
- metadata +84 -4
data/.travis.yml
CHANGED
@@ -1,20 +1,10 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
|
4
|
-
script: bundle exec ruby tests/package_test.rb
|
5
|
-
|
6
4
|
rvm:
|
7
5
|
- 2.3.0
|
8
6
|
- 2.2
|
9
7
|
- 2.1
|
10
8
|
- 2.0
|
11
|
-
- ruby-head
|
12
|
-
- rbx-2
|
13
|
-
- jruby-head
|
14
|
-
- jruby-9000
|
15
|
-
|
16
|
-
cache:
|
17
|
-
- bundler
|
18
9
|
|
19
|
-
|
20
|
-
# fast_finish: true
|
10
|
+
before_install: gem install bundler -v 1.14.3
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# wooget
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/wooga/wooget.svg?branch=master)](https://travis-ci.org/wooga/wooget) [![Code Climate](https://lima.codeclimate.com/github/wooga/wooget/badges/gpa.svg)](https://lima.codeclimate.com/github/wooga/wooget) [![Test Coverage](https://lima.codeclimate.com/github/wooga/wooget/badges/coverage.svg)](https://lima.codeclimate.com/github/wooga/wooget/coverage) [![Issue Count](https://lima.codeclimate.com/github/wooga/wooget/badges/issue_count.svg)](https://lima.codeclimate.com/github/wooga/wooget)
|
4
|
+
|
3
5
|
A cli which allows [Unity3d](http://www.unity3d.com) projects to work with NuGet packages.
|
4
6
|
|
5
7
|
## Features
|
data/Rakefile
CHANGED
@@ -10,6 +10,14 @@ info = "#{gemspec.name} | #{gemspec.version} | " \
|
|
10
10
|
"#{gemspec.runtime_dependencies.size} dependencies | " \
|
11
11
|
"#{gemspec.files.size} files"
|
12
12
|
|
13
|
+
require "bundler/gem_tasks"
|
14
|
+
require "rspec/core/rake_task"
|
15
|
+
|
16
|
+
RSpec::Core::RakeTask.new(:spec)
|
17
|
+
task :default => :spec do
|
18
|
+
`bundle exec codeclimate-test-reporter`
|
19
|
+
end
|
20
|
+
|
13
21
|
|
14
22
|
# # #
|
15
23
|
# Gem build and install task
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/bin/wooget
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "bundler/setup"
|
4
|
+
require_relative '../lib/wooget'
|
4
5
|
|
5
6
|
begin
|
6
7
|
Wooget::CLI.start ARGV
|
@@ -8,5 +9,7 @@ rescue Wooget::WoogetError => e
|
|
8
9
|
$stderr.puts e.message
|
9
10
|
exit e.exit_code
|
10
11
|
rescue => e
|
11
|
-
|
12
|
+
$stderr.puts e.message
|
13
|
+
$stderr.puts e.backtrace * "\n"
|
14
|
+
exit e.exit_code
|
12
15
|
end
|
data/exe/wooget
ADDED
data/lib/wooget.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative "wooget/version"
|
2
2
|
require_relative "wooget/cli"
|
3
|
+
require_relative "wooget/github"
|
3
4
|
require_relative "wooget/releasing"
|
4
5
|
require_relative "wooget/build/build_info"
|
5
6
|
require_relative "wooget/build/builder"
|
@@ -11,7 +12,7 @@ require_relative "wooget/util/package_list_formatter"
|
|
11
12
|
require_relative "wooget/template/visual_studio"
|
12
13
|
require_relative "wooget/template/unity"
|
13
14
|
require_relative "wooget/util/build_error"
|
14
|
-
|
15
|
+
require_relative "wooget/default"
|
15
16
|
|
16
17
|
|
17
18
|
# Gem.find_files("wooget/**/*.rb").each { |path| require path }
|
@@ -26,8 +27,8 @@ module Wooget
|
|
26
27
|
msg.start_with?("[quiet]") ? "#{msg.sub("[quiet]","")}" : "[#{severity} #{datetime}] : #{msg}"
|
27
28
|
end
|
28
29
|
|
29
|
-
@@credentials =
|
30
|
-
@@repos =
|
30
|
+
@@credentials = Default.credentials
|
31
|
+
@@repos = Default.repos
|
31
32
|
|
32
33
|
def self.log
|
33
34
|
@@log
|
data/lib/wooget/build/builder.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'octokit'
|
2
|
+
require 'time'
|
3
|
+
|
2
4
|
module Wooget
|
3
5
|
module Build
|
4
6
|
class Builder < Thor
|
@@ -52,38 +54,29 @@ module Wooget
|
|
52
54
|
|
53
55
|
def commit_and_push build_info
|
54
56
|
Util.run_cmd "git commit -am '#{build_info.build_name}'"
|
55
|
-
Util.run_cmd "git tag '#{build_info.
|
56
|
-
Util.run_cmd "git push origin --tags"
|
57
|
+
# Util.run_cmd "git tag '#{build_info.version}'"
|
58
|
+
# Util.run_cmd "git push origin --tags"
|
57
59
|
Util.run_cmd "git push origin"
|
58
60
|
end
|
59
61
|
|
60
62
|
def github_release build_info, built_packages
|
61
|
-
if Wooget.credentials[:github_token].nil? or Wooget.credentials[:github_token].empty?
|
62
|
-
Wooget.log.error "Github Release Error - Couldn't find a value for github_token in the provided config"
|
63
|
+
if ENV['OCTOKIT_ACCESS_TOKEN'].nil? and (Wooget.credentials[:github_token].nil? or Wooget.credentials[:github_token].empty?)
|
64
|
+
Wooget.log.error "Github Release Error - Couldn't find a value for github_token in the provided config or environment"
|
63
65
|
return
|
64
66
|
end
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
repo_name = url.split('/').last(2).join("/")
|
68
|
+
access_token = Wooget.credentials[:github_token]
|
69
|
+
if access_token.empty?
|
70
|
+
access_token = nil
|
71
|
+
end
|
71
72
|
|
72
|
-
|
73
|
-
client = Octokit::Client.new access_token: Wooget.credentials[:github_token]
|
73
|
+
github = Wooget::Github.new(options[:path], access_token)
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
github.do_release build_info.version, built_packages, **{
|
76
|
+
name: build_info.version_name,
|
77
|
+
body: build_info.release_notes,
|
78
|
+
prerelease: build_info.prerelease?
|
79
79
|
}
|
80
|
-
|
81
|
-
Wooget.log.info "Creating release '#{release_options[:name]}' on repo #{repo_name}"
|
82
|
-
release = client.create_release repo_name, build_info.build_name, release_options
|
83
|
-
Wooget.log.info "Uploading assets..."
|
84
|
-
built_packages.each { |package| client.upload_asset release.url, package, {content_type: "application/zip" }}
|
85
|
-
Wooget.log.info "Publishing release.."
|
86
|
-
client.update_release release.url, {draft: false}
|
87
80
|
end
|
88
81
|
|
89
82
|
def build_native_extensions
|
data/lib/wooget/cli.rb
CHANGED
@@ -32,6 +32,9 @@ module Wooget
|
|
32
32
|
option :version, desc:"Version number to prepend to release notes", type: :string, required: true
|
33
33
|
option :output, desc: "Dir to place built packages", type: :string, default: "bin"
|
34
34
|
option :release_notes, desc: "Release notes to include in the package", type: :string, default: ""
|
35
|
+
option :git, desc: "Use git functionality", type: :boolean, default: true
|
36
|
+
option :git_push, desc: "Auto push to git", type: :boolean, default: true
|
37
|
+
option :git_release, desc: "Create github release", type: :boolean, default: true
|
35
38
|
option :native, desc: "Invoke native build functionality", type: :boolean, default: true
|
36
39
|
def build
|
37
40
|
package_release_checks
|
@@ -53,7 +56,10 @@ module Wooget
|
|
53
56
|
release_notes: options[:release_notes],
|
54
57
|
templates: templates,
|
55
58
|
path: options[:path],
|
56
|
-
native: options[:native]
|
59
|
+
native: options[:native],
|
60
|
+
git: options[:git],
|
61
|
+
git_push: options[:git_push],
|
62
|
+
git_release: options[:git_release],
|
57
63
|
}
|
58
64
|
|
59
65
|
built_packages = invoke "wooget:packager:build", [], build_options
|
@@ -61,11 +67,32 @@ module Wooget
|
|
61
67
|
p "#{built_packages.join " & "} built to #{File.expand_path File.join(options[:path],options[:output])}" if built_packages
|
62
68
|
end
|
63
69
|
|
70
|
+
desc "build-name", "Prints the build name for the current dir"
|
71
|
+
def build_name
|
72
|
+
build_name = invoke "wooget:packager:build_name", [], options
|
73
|
+
p build_name
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "version", "Prints the wooget's version information"
|
77
|
+
def version
|
78
|
+
puts "wooget version #{Wooget::VERSION}"
|
79
|
+
end
|
80
|
+
map %w(-v --version) => :version
|
81
|
+
|
82
|
+
option :include_version_identifier, desc: "Return version with version identifier", type: :boolean, default: false
|
83
|
+
desc "latest-version", "return latest version of package"
|
84
|
+
def latest_version
|
85
|
+
version = invoke "wooget:packager:latest_version", [], options
|
86
|
+
p version
|
87
|
+
end
|
88
|
+
|
64
89
|
option :repo, desc: "Which repo to use"
|
65
90
|
option :push, desc: "Should built package be pushed to repo", default: true, type: :boolean
|
66
91
|
option :confirm, desc: "Ask for confirmation before pushing", default: true, type: :boolean
|
67
92
|
option :output, desc: "Dir to place built packages", type: :string, default: "bin"
|
68
93
|
option :git, desc: "Use git functionality", type: :boolean, default: true
|
94
|
+
option :git_push, desc: "Auto push to git", type: :boolean, default: true
|
95
|
+
option :git_release, desc: "Create github release", type: :boolean, default: true
|
69
96
|
option :native, desc: "Invoke native build functionality", type: :boolean, default: true
|
70
97
|
desc "release", "release package in current dir"
|
71
98
|
|
@@ -82,6 +109,8 @@ module Wooget
|
|
82
109
|
option :confirm, desc: "Ask for confirmation before pushing", default: true, type: :boolean
|
83
110
|
option :output, desc: "Dir to place built packages", type: :string, default: "bin"
|
84
111
|
option :git, desc: "Use git functionality", type: :boolean, default: true
|
112
|
+
option :git_push, desc: "Auto push to git", type: :boolean, default: true
|
113
|
+
option :git_release, desc: "Create github release", type: :boolean, default: true
|
85
114
|
option :native, desc: "Invoke native build functionality", type: :boolean, default: true
|
86
115
|
desc "prerelease", "prerelease package in current dir"
|
87
116
|
|
@@ -257,6 +286,8 @@ module Wooget
|
|
257
286
|
Wooget.repos[:default] = overridden_repo
|
258
287
|
end
|
259
288
|
|
289
|
+
#override settings with values from environment
|
290
|
+
|
260
291
|
Wooget.log.debug "Acting as #{Wooget.credentials[:username]}"
|
261
292
|
Wooget.log.debug "Default repo is #{Wooget.repo}"
|
262
293
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Wooget
|
2
|
+
module Default
|
3
|
+
|
4
|
+
DEFAULT_REPO = "legacy".freeze
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def github_token
|
8
|
+
ENV['GITHUB_TOKEN'] || ENV['OCTOKIT_ACCESS_TOKEN']
|
9
|
+
end
|
10
|
+
|
11
|
+
def user_name
|
12
|
+
ENV['WOOGET_USERNAME'] || ENV['WOOGET_USR']
|
13
|
+
end
|
14
|
+
|
15
|
+
def user_password
|
16
|
+
ENV['WOOGET_PASSWORD'] || ENV['WOOGET_PSW']
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_repo
|
20
|
+
ENV['WOOGET_DEFAULT_REPO'] || DEFAULT_REPO
|
21
|
+
end
|
22
|
+
|
23
|
+
def credentials
|
24
|
+
{
|
25
|
+
"username" => user_name,
|
26
|
+
"password" => user_password,
|
27
|
+
"github_token" => github_token
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def repos
|
32
|
+
{ default: default_repo }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
|
3
|
+
module Wooget
|
4
|
+
|
5
|
+
class Github
|
6
|
+
|
7
|
+
attr_reader :working_dir, :git_command
|
8
|
+
attr_accessor :access_token, :logger
|
9
|
+
|
10
|
+
def initialize(working_dir=Dir.pwd, access_token=nil, logger=nil)
|
11
|
+
@working_dir = working_dir
|
12
|
+
@git_command = "git -C #{working_dir}"
|
13
|
+
@github_client = nil
|
14
|
+
@access_token = access_token
|
15
|
+
@logger = (logger.nil?) ? Wooget.log : logger
|
16
|
+
end
|
17
|
+
|
18
|
+
def github_client
|
19
|
+
if @github_client.nil?
|
20
|
+
token = @access_token
|
21
|
+
if ENV['OCTOKIT_ACCESS_TOKEN'] and token.nil?
|
22
|
+
token = ENV['OCTOKIT_ACCESS_TOKEN']
|
23
|
+
end
|
24
|
+
|
25
|
+
unless token.nil?
|
26
|
+
@github_client = Octokit::Client.new access_token: token
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
@github_client
|
31
|
+
end
|
32
|
+
|
33
|
+
def repo
|
34
|
+
if @repo.nil?
|
35
|
+
@repo = Octokit::Repository.new repo_name
|
36
|
+
end
|
37
|
+
@repo
|
38
|
+
end
|
39
|
+
|
40
|
+
def repo_name
|
41
|
+
remote_url = `#{git_command} config --get remote.origin.url`.strip.chomp '.git'
|
42
|
+
remote_url.split(':').last.split('/')[-2..-1].join('/')
|
43
|
+
end
|
44
|
+
|
45
|
+
def inside_working_tree?
|
46
|
+
inside_working_tree = `#{git_command} rev-parse --is-inside-work-tree`.strip
|
47
|
+
inside_working_tree.eql? "true"
|
48
|
+
end
|
49
|
+
|
50
|
+
def current_commit_sha
|
51
|
+
`#{git_command} rev-parse --verify HEAD`.strip
|
52
|
+
end
|
53
|
+
|
54
|
+
def do_release release_name, artifacts=nil, **options
|
55
|
+
release_status = true
|
56
|
+
options = {} if options.nil?
|
57
|
+
artifacts = [] if artifacts.nil?
|
58
|
+
|
59
|
+
default_options = {
|
60
|
+
target_commitish: current_commit_sha(),
|
61
|
+
name: release_name,
|
62
|
+
body: "",
|
63
|
+
prerelease: false
|
64
|
+
}
|
65
|
+
|
66
|
+
options = default_options.merge! options
|
67
|
+
options[:draft] = true
|
68
|
+
|
69
|
+
logger.info "Check releases"
|
70
|
+
releases = github_client.releases(repo).map {|release| release.name }
|
71
|
+
unless releases.include? release_name
|
72
|
+
create_release release_name, artifacts, options
|
73
|
+
else
|
74
|
+
logger.error "Release #{options[:name]} already exist"
|
75
|
+
release_status = false
|
76
|
+
end
|
77
|
+
release_status
|
78
|
+
end
|
79
|
+
|
80
|
+
def create_release tag_name, artifacts=nil, options
|
81
|
+
logger.info "Creating release '#{options[:name]}' on repo #{repo_name}"
|
82
|
+
release = github_client.create_release repo, tag_name, options
|
83
|
+
|
84
|
+
logger.info "Uploading assets..." unless artifacts.empty?
|
85
|
+
artifacts.each { |artifact|
|
86
|
+
logger.info "--> Upload asset: #{artifact}"
|
87
|
+
github_client.upload_asset release.url, artifact, {content_type: "application/zip" }
|
88
|
+
}
|
89
|
+
|
90
|
+
logger.info "Publishing release.."
|
91
|
+
github_client.update_release release.url, {draft: false}
|
92
|
+
end
|
93
|
+
|
94
|
+
def create_tag tag_name, sha=nil, message=nil
|
95
|
+
sha = current_commit_sha if sha.nil?
|
96
|
+
message = tag_name if message.nil?
|
97
|
+
|
98
|
+
commit = github_client.commit(repo, sha).commit
|
99
|
+
|
100
|
+
#TODO check if sha is upstream available
|
101
|
+
user = commit.author.name
|
102
|
+
email = commit.author.email
|
103
|
+
|
104
|
+
logger.info "Create tag #{tag_name} with info from last committer"
|
105
|
+
t = github_client.create_tag repo, tag_name, message, sha ,"commit", user, email, Time.now.iso8601
|
106
|
+
github_client.create_ref repo, "tags/#{t.tag}", t.sha
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/wooget/releasing.rb
CHANGED
@@ -66,6 +66,22 @@ module Wooget
|
|
66
66
|
builder.perform_build build_info
|
67
67
|
end
|
68
68
|
|
69
|
+
option :include_version_identifier, desc: "Return version with version identifier", type: :boolean, default: false
|
70
|
+
desc "latest-version", "return latest version of package"
|
71
|
+
def latest_version
|
72
|
+
version, version_identifier = get_version_from_release_notes
|
73
|
+
if(options[:include_version_identifier])
|
74
|
+
version = version + "-" + version_identifier unless version_identifier.empty?
|
75
|
+
end
|
76
|
+
version
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "build-name", "Prints the build name for the current dir"
|
80
|
+
def build_name
|
81
|
+
build_info = get_build_info_from_template_files
|
82
|
+
build_info.build_name
|
83
|
+
end
|
84
|
+
|
69
85
|
private
|
70
86
|
|
71
87
|
def clean
|