Sha256: 3d9560508276405ab33daebed5a7cdbd19a054089c63eb362f220d62c2793e21

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

skip_docs

lane :release do
  code_review
  sh('bundle exec rake build')
  gem_path = "pkg/xcmonkey-#{version}.gem"
  sh("gem push ../#{gem_path}")
  set_github_release(
    repository_name: 'alteral/xcmonkey',
    api_token: ENV.fetch("GITHUB_TOKEN", nil),
    name: version,
    tag_name: version,
    description: "See [CHANGELOG.md](https://github.com/alteral/xcmonkey/blob/main/CHANGELOG.md##{version.delete('.')})",
    commitish: git_branch,
    upload_assets: [gem_path]
  )
end

lane :code_review do
  sh('bundle exec rake')
end

lane :sonar_upload do
  update_simplecov_report
  sonar_options =
    if ENV['GITHUB_EVENT_NAME'] == 'pull_request'
      {
        sonar_login: ENV.fetch('SONAR_TOKEN', nil),
        pull_request_branch: ENV.fetch('GITHUB_HEAD_REF', nil),
        pull_request_base: ENV.fetch('GITHUB_BASE_REF', nil),
        pull_request_key: ENV.fetch('PR_NUMBER', nil)
      }
    else
      {
        sonar_login: ENV.fetch('SONAR_TOKEN', nil),
        branch_name: ENV['BRANCH_NAME'] || git_branch,
        project_version: version
      }
    end

  sonar(sonar_options)
end

private_lane :update_simplecov_report do
  coverage = JSON.parse(File.read('../coverage/.resultset.json'))["RSpec"]["coverage"]
  transformed_values = coverage.transform_values { |l| l["lines"] }
  new_format = { "RSpec" => { "coverage" => transformed_values, "timestamp" => Time.now.to_i } }
  File.write('../coverage/.sonar.json', JSON.pretty_generate(new_format))
end

def version
  version_path = '../lib/xcmonkey/version.rb'
  File.read(version_path).scan(/\d+/).join('.')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xcmonkey-1.3.1 fastlane/Fastfile