|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
| 3 | +require 'bundler/gem_tasks' |
3 | 4 | require 'rubocop/rake_task' |
4 | 5 | require 'fileutils' |
5 | 6 | require 'github_changelog_generator/task' |
@@ -44,61 +45,6 @@ task default: :spec |
44 | 45 |
|
45 | 46 | YARD::Rake::YardocTask.new do |t| |
46 | 47 | end |
47 | | - |
48 | | -# Executes a command locally. |
49 | | -# |
50 | | -# @param command [String] command to execute. |
51 | | -# @return [Object] the standard out stream. |
52 | | -def run_local_command(command) |
53 | | - stdout, stderr, status = Open3.capture3(command) |
54 | | - error_message = "Attempted to run\ncommand:'#{command}'\nstdout:#{stdout}\nstderr:#{stderr}" |
55 | | - raise error_message unless status.to_i.zero? |
56 | | - |
57 | | - stdout |
58 | | -end |
59 | | - |
60 | | -# Build the gem |
61 | | -desc 'Build the gem' |
62 | | -task :build do |
63 | | - gemspec_path = File.join(Dir.pwd, 'ruby-pwsh.gemspec') |
64 | | - run_local_command("bundle exec gem build '#{gemspec_path}'") |
65 | | -end |
66 | | - |
67 | | -# Tag the repo with a version in preparation for the release |
68 | | -# |
69 | | -# @param :version [String] a semantic version to tag the code with |
70 | | -# @param :sha [String] the sha at which to apply the version tag |
71 | | -desc 'Tag the repo with a version in preparation for release' |
72 | | -task :tag, [:version, :sha] do |_task, args| |
73 | | - raise "Invalid version #{args[:version]} - must be like '1.2.3'" unless args[:version] =~ /^\d+\.\d+\.\d+$/ |
74 | | - |
75 | | - run_local_command('git fetch upstream') |
76 | | - run_local_command("git tag -a #{args[:version]} -m #{args[:version]} #{args[:sha]}") |
77 | | - run_local_command('git push upstream --tags') |
78 | | -end |
79 | | - |
80 | | -# Push the built gem to RubyGems |
81 | | -# |
82 | | -# @param :path [String] optional, the full or relative path to the built gem to be pushed |
83 | | -desc 'Push to RubyGems' |
84 | | -task :push, [:path] do |_task, args| |
85 | | - raise 'No discoverable gem for pushing' if Dir.glob("ruby-pwsh*\.gem").empty? && args[:path].nil? |
86 | | - raise "No file found at specified path: '#{args[:path]}'" unless File.exist?(args[:path]) |
87 | | - |
88 | | - path = args[:path] || File.join(Dir.pwd, Dir.glob("ruby-pwsh*\.gem")[0]) |
89 | | - run_local_command("bundle exec gem push #{path}") |
90 | | -end |
91 | | - |
92 | | -desc 'Build for Puppet' |
93 | | -task :build_module do |
94 | | - actual_readme_content = File.read('README.md') |
95 | | - FileUtils.copy_file('pwshlib.md', 'README.md') |
96 | | - # Build |
97 | | - run_local_command('pdk build --force') |
98 | | - # Cleanup |
99 | | - File.open('README.md', 'wb') { |file| file.write(actual_readme_content) } |
100 | | -end |
101 | | - |
102 | 48 | # Used in vendor_dsc_module |
103 | 49 | TAR_LONGLINK = '././@LongLink' |
104 | 50 |
|
|
0 commit comments