我想简化在我们的私人github rubygems注册表中部署内部宝石。在大多数情况下,在GEMSpec文件中,该版本是硬编码或从另一个文件中读取的。意思是要发布新版本后,一旦准备好代码库,就必须创建一个拉动请求,修改版本,合并,然后最终发布。
此工作流与我们的MonorePo中的其他服务不符。对于最后的最后,一旦我们想发布,我们就会创建一个触发a REST/REFESS/REVERATIONS“ RER =“ Nofollow Noreferrer”> GitHub部署和专用的CI管道,我们可以在其中检索要发布的版本的名称。
因此,对于我们的宝石,我一直在考虑使用环境变量来设置该版本时,当调用GEM Build rubocop-xxxxx 喜欢这样
Gem::Specification.new do |spec|
spec.platform = Gem::Platform::RUBY
spec.name = 'rubocop-xxxxx'
spec.metadata = {
'github_repo' => 'ssh://github.com/xxxxx/monorepo',
'allowed_push_host' => 'https://rubygems.pkg.github.com/xxxxx',
'source_code_uri' => 'https://github.com/xxxxx/monorepo/tree/main/packages/common/rubocop'
}
spec.version = ENV['PACKAGE_RELEASE_VERSION'] || "0.0.0"
spec.platform = Gem::Platform::RUBY
spec.required_ruby_version = '>= 2.7'
spec.files = Dir[
'rubocop.yml',
'conf/**/*',
'*.gemspec',
'Gemfile',
]
spec.add_dependency('rubocop-performance', '~> 1.13.3')
spec.add_dependency('rubocop-rails', '~> 2.14.2')
spec.add_dependency('rubocop-rake', '~> 0.6.0')
spec.add_dependency('rubocop-rspec', '~> 2.9.0')
spec.add_dependency('rubocop-shopify', '~> 2.5.0')
end
:在运行 gemfile.lock 生成 Bundle bundle install
时发出问题。
拥有这样的Gemspec可以,还是可以看到以后再见?
I want to ease the deployment of an internal gem to our private Github rubygems registry. Most of the time, within the gemspec file, the version is hardcoded or read from another file. Meaning to publish a new release once your code base ready, you have to create a pull request, modified the version, merge, then finally publish.
This workflow does not match the other services in our monorepo. For these last, once we want to release, we create a branch release/service-name/v1.2 that trigger a Github Deployment and a dedicated CI pipeline where we can retrieve the name of the version to release.
So for our gem, I was thinking to use an environment variable to set the version when calling gem build rubocop-xxxxx like this:
Gem::Specification.new do |spec|
spec.platform = Gem::Platform::RUBY
spec.name = 'rubocop-xxxxx'
spec.metadata = {
'github_repo' => 'ssh://github.com/xxxxx/monorepo',
'allowed_push_host' => 'https://rubygems.pkg.github.com/xxxxx',
'source_code_uri' => 'https://github.com/xxxxx/monorepo/tree/main/packages/common/rubocop'
}
spec.version = ENV['PACKAGE_RELEASE_VERSION'] || "0.0.0"
spec.platform = Gem::Platform::RUBY
spec.required_ruby_version = '>= 2.7'
spec.files = Dir[
'rubocop.yml',
'conf/**/*',
'*.gemspec',
'Gemfile',
]
spec.add_dependency('rubocop-performance', '~> 1.13.3')
spec.add_dependency('rubocop-rails', '~> 2.14.2')
spec.add_dependency('rubocop-rake', '~> 0.6.0')
spec.add_dependency('rubocop-rspec', '~> 2.9.0')
spec.add_dependency('rubocop-shopify', '~> 2.5.0')
end
The 0.0.0 fallback is here to avoid issue when generating the Gemfile.lock when running bundle install
.
Is it OK to have such gemspec, or can I see later some issue?
发布评论
评论(1)
我会不是使用环境变量来设置宝石版本。
如果您的目标是测试
rubocop-xxxxx
gem在您的一项服务中的释放候选者,然后才能使用path
选项在gemfile
中,而不是释放每个更改。示例
gemfile:
当宝石的版本按预期工作时,释放它(使用硬编码版本编号),请从 gemfile < /code>再次指定已发布的
版本
。示例
gemfile:
I would not use an environment variable for setting the gem version.
If your goal is to test a release candidate of
rubocop-xxxxx
gem in one of your service before you finally release it, you can use thepath
option in theGemfile
instead of releasing each change.Example
Gemfile:
When the version of the gem works as expected, release it (with a hard-coded version number), remove the
path
option from theGemfile
again and specify the releasedversion
instead.Example
Gemfile: