Skip to content

Commit c9fc175

Browse files
authored
Merge pull request #9372 from joshcooper/backport_PA-6427
[Backport 7.x] Add rake tasks for building nightly gem
2 parents 0fedb08 + b2f3cd1 commit c9fc175

File tree

2 files changed

+65
-39
lines changed

2 files changed

+65
-39
lines changed

Rakefile

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,43 @@ end
4747

4848
namespace :pl_ci do
4949
desc 'Build puppet gems'
50-
task :gem_build do
51-
stdout, stderr, status = Open3.capture3('gem build puppet.gemspec --platform x86-mingw32 && gem build puppet.gemspec --platform x64-mingw32 && gem build puppet.gemspec --platform universal-darwin && gem build puppet.gemspec')
50+
task :gem_build, [:gemspec] do |t, args|
51+
args.with_defaults(gemspec: 'puppet.gemspec')
52+
stdout, stderr, status = Open3.capture3(<<~END)
53+
gem build #{args.gemspec} --platform x86-mingw32 && \
54+
gem build #{args.gemspec} --platform x64-mingw32 && \
55+
gem build #{args.gemspec} --platform universal-darwin && \
56+
gem build #{args.gemspec}
57+
END
5258
if !status.exitstatus.zero?
53-
puts "Error building facter.gemspec \n#{stdout} \n#{stderr}"
59+
puts "Error building #{args.gemspec}\n#{stdout} \n#{stderr}"
5460
exit(1)
5561
else
5662
puts stdout
5763
end
5864
end
65+
66+
desc 'build the nightly puppet gems'
67+
task :nightly_gem_build do
68+
# this is taken from `rake package:nightly_gem`
69+
extended_dot_version = %x{git describe --tags --dirty --abbrev=7}.chomp.tr('-', '.')
70+
71+
# we must create tempfile in the same directory as puppetg.gemspec, since
72+
# it uses __dir__ to determine which files to include
73+
require 'tempfile'
74+
Tempfile.create('gemspec', __dir__) do |dst|
75+
File.open('puppet.gemspec', 'r') do |src|
76+
src.readlines.each do |line|
77+
if line.match?(/version\s*=\s*['"][0-9.]+['"]/)
78+
line = "spec.version = '#{extended_dot_version}'"
79+
end
80+
dst.puts line
81+
end
82+
end
83+
dst.flush
84+
Rake::Task['pl_ci:gem_build'].invoke(dst.path)
85+
end
86+
end
5987
end
6088

6189
task :spec do

puppet.gemspec

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
1-
Gem::Specification.new do |s|
2-
s.name = "puppet"
3-
version = "7.31.0"
4-
mdata = version.match(/(\d+\.\d+\.\d+)/)
5-
s.version = mdata ? mdata[1] : version
6-
s.license = 'Apache-2.0'
1+
Gem::Specification.new do |spec|
2+
spec.name = "puppet"
3+
spec.version = "7.31.0"
4+
spec.license = 'Apache-2.0'
75

8-
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1")
9-
s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
10-
s.authors = ["Puppet Labs"]
11-
s.date = "2012-08-17"
12-
s.description = <<~EOF
6+
spec.required_rubygems_version = Gem::Requirement.new("> 1.3.1")
7+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
8+
spec.authors = ["Puppet Labs"]
9+
spec.date = "2012-08-17"
10+
spec.description = <<~EOF
1311
Puppet, an automated administrative engine for your Linux, Unix, and Windows systems, performs administrative tasks
1412
(such as adding users, installing packages, and updating server configurations) based on a centralized specification.
1513
EOF
16-
s.email = "[email protected]"
17-
s.executables = ["puppet"]
18-
s.files = Dir['[A-Z]*'] + Dir['install.rb'] + Dir['bin/*'] + Dir['lib/**/*'] + Dir['conf/*'] + Dir['man/**/*'] + Dir['tasks/*'] + Dir['locales/**/*'] + Dir['ext/**/*'] + Dir['examples/**/*']
19-
s.homepage = "https://github.com/puppetlabs/puppet"
20-
s.rdoc_options = ["--title", "Puppet - Configuration Management", "--main", "README", "--line-numbers"]
21-
s.require_paths = ["lib"]
22-
s.summary = "Puppet, an automated configuration management tool"
23-
s.specification_version = 4
24-
s.add_runtime_dependency(%q<facter>, ["> 2.0.1", "< 5"])
25-
s.add_runtime_dependency(%q<hiera>, [">= 3.2.1", "< 4"])
26-
s.add_runtime_dependency(%q<semantic_puppet>, "~> 1.0")
27-
s.add_runtime_dependency(%q<fast_gettext>, ">= 1.1", "< 3")
28-
s.add_runtime_dependency(%q<locale>, "~> 2.1")
29-
s.add_runtime_dependency(%q<multi_json>, "~> 1.10")
30-
s.add_runtime_dependency(%q<puppet-resource_api>, "~> 1.5")
31-
s.add_runtime_dependency(%q<concurrent-ruby>, "~> 1.0")
32-
s.add_runtime_dependency(%q<deep_merge>, "~> 1.0")
33-
s.add_runtime_dependency(%q<scanf>, "~> 1.0")
14+
spec.email = "[email protected]"
15+
spec.executables = ["puppet"]
16+
spec.files = Dir['[A-Z]*'] + Dir['install.rb'] + Dir['bin/*'] + Dir['lib/**/*'] + Dir['conf/*'] + Dir['man/**/*'] + Dir['tasks/*'] + Dir['locales/**/*'] + Dir['ext/**/*'] + Dir['examples/**/*']
17+
spec.homepage = "https://github.com/puppetlabs/puppet"
18+
spec.rdoc_options = ["--title", "Puppet - Configuration Management", "--main", "README", "--line-numbers"]
19+
spec.require_paths = ["lib"]
20+
spec.summary = "Puppet, an automated configuration management tool"
21+
spec.specification_version = 4
22+
spec.add_runtime_dependency(%q<facter>, ["> 2.0.1", "< 5"])
23+
spec.add_runtime_dependency(%q<hiera>, [">= 3.2.1", "< 4"])
24+
spec.add_runtime_dependency(%q<semantic_puppet>, "~> 1.0")
25+
spec.add_runtime_dependency(%q<fast_gettext>, ">= 1.1", "< 3")
26+
spec.add_runtime_dependency(%q<locale>, "~> 2.1")
27+
spec.add_runtime_dependency(%q<multi_json>, "~> 1.10")
28+
spec.add_runtime_dependency(%q<puppet-resource_api>, "~> 1.5")
29+
spec.add_runtime_dependency(%q<concurrent-ruby>, "~> 1.0")
30+
spec.add_runtime_dependency(%q<deep_merge>, "~> 1.0")
31+
spec.add_runtime_dependency(%q<scanf>, "~> 1.0")
3432

3533
# For building platform specific puppet gems...the --platform flag is only supported in newer Ruby versions
36-
platform = s.platform.to_s
34+
platform = spec.platform.to_s
3735
if platform == 'universal-darwin'
38-
s.add_runtime_dependency('CFPropertyList', '~> 2.2')
36+
spec.add_runtime_dependency('CFPropertyList', '~> 2.2')
3937
end
4038

41-
if platform == 'x64-mingw32' || platform == 'x86-mingw32'
42-
# ffi 1.16.0 - 1.16.2 are broken on Windows
43-
s.add_runtime_dependency('ffi', '>= 1.15.5', '< 1.17.0', '!= 1.16.0', '!= 1.16.1', '!= 1.16.2')
44-
s.add_runtime_dependency('minitar', '~> 0.9')
45-
end
39+
if platform == 'x64-mingw32' || platform == 'x86-mingw32'
40+
# ffi 1.16.0 - 1.16.2 are broken on Windows
41+
spec.add_runtime_dependency('ffi', '>= 1.15.5', '< 1.17.0', '!= 1.16.0', '!= 1.16.1', '!= 1.16.2')
42+
spec.add_runtime_dependency('minitar', '~> 0.9')
43+
end
4644
end

0 commit comments

Comments
 (0)