Skip to content

Commit

Permalink
Migrate to a version.rb file for tracking version internally
Browse files Browse the repository at this point in the history
  • Loading branch information
arothian committed Oct 15, 2021
1 parent d6193cb commit e1cb0fc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/cfn_nag_rules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'cfn-nag'
require 'rubygems/specification'

opts = Optimist.options do
version Gem::Specification.find_by_name('cfn-nag').version
version CfnNagVersion::VERSION

opt :rule_directory, 'Extra rule directories', type: :io,
required: false,
Expand Down
4 changes: 3 additions & 1 deletion cfn-nag.gemspec
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require_relative 'lib/cfn-nag/version'

Gem::Specification.new do |s|
s.name = 'cfn-nag'
s.license = 'MIT'
s.version = ENV['GEM_VERSION'] || '0.0.0'
s.version = ENV['GEM_VERSION'] || CfnNagVersion::VERSION
s.bindir = 'bin'
s.executables = %w[cfn_nag cfn_nag_rules cfn_nag_scan spcm_scan]
s.authors = ['Eric Kascic']
Expand Down
3 changes: 2 additions & 1 deletion lib/cfn-nag/cli_options.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# frozen_string_literal: true

require 'optimist'
require_relative 'version'

# rubocop:disable Metrics/ClassLength
class Options
@custom_rule_exceptions_message = 'Isolate custom rule exceptions - just ' \
'emit the exception without stack trace ' \
'and keep chugging'

@version = Gem::Specification.find_by_name('cfn-nag').version
@version = CfnNagVersion::VERSION

def self.for(type)
case type
Expand Down
2 changes: 1 addition & 1 deletion lib/cfn-nag/result_view/sarif_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def driver(rules)
{
name: 'cfn_nag',
informationUri: 'https://github.com/stelligent/cfn_nag',
semanticVersion: Gem.loaded_specs['cfn-nag'].version.to_s,
semanticVersion: CfnNagVersion::VERSION,
rules: rules.map do |rule_definition|
{
id: "CFN_NAG_#{rule_definition.id}",
Expand Down
6 changes: 6 additions & 0 deletions lib/cfn-nag/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module CfnNagVersion
# This is managed at release time via scripts/publish.sh
VERSION = '0.0.0'
end
2 changes: 1 addition & 1 deletion scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ else
new_version="${minor_version}.$((current_version+1))"
fi

sed -i.bak "s/0\.0\.0/${new_version}/g" cfn-nag.gemspec
sed -i.bak "s/0\.0\.0/${new_version}/g" lib/cfn-nag/version.rb

# publish rubygem to rubygems.org, https://rubygems.org/gems/cfn-nag
gem build cfn-nag.gemspec
Expand Down

0 comments on commit e1cb0fc

Please sign in to comment.