|
4 | 4 | # - MIN_XCODE_VERSION |
5 | 5 |
|
6 | 6 | require 'json' |
7 | | -require 'pathname' |
8 | 7 | require 'open3' |
| 8 | +require 'pathname' |
9 | 9 |
|
10 | 10 | # Utility functions to run Xcode commands, extract versionning info and logs messages |
11 | 11 | # |
@@ -40,14 +40,43 @@ class Utils |
40 | 40 | File.open('Package.swift').read() |
41 | 41 | .match(/https:\/\/.*artifactbundle.zip/)[0] |
42 | 42 | .match(/\d+\.\d+\.\d+/)[0] |
| 43 | + end |
| 44 | + |
| 45 | + def self.podspec_as_json(file) |
| 46 | + file += '.podspec' unless file.include?('.podspec') |
| 47 | + json, _, _ = Open3.capture3('bundle', 'exec', 'pod', 'ipc', 'spec', file) |
| 48 | + JSON.parse(json) |
| 49 | + end |
| 50 | + |
| 51 | + def self.podspec_version(file) |
| 52 | + podspec_as_json(file)['version'] |
| 53 | + end |
| 54 | + |
| 55 | + def self.pod_trunk_last_version(pod) |
| 56 | + require 'yaml' |
| 57 | + stdout, _, _ = Open3.capture3('bundle', 'exec', 'pod', 'trunk', 'info', pod) |
| 58 | + stdout.sub!("\n#{pod}\n", '') |
| 59 | + last_version_line = YAML.safe_load(stdout).first['Versions'].last |
| 60 | + /^[0-9.]*/.match(last_version_line)[0] # Just the 'x.y.z' part |
| 61 | + end |
| 62 | + |
| 63 | + def self.spm_own_version(dep) |
| 64 | + dependencies = JSON.load(File.new('Package.resolved'))['object']['pins'] |
| 65 | + dependencies.find { |d| d['package'] == dep }['state']['version'] |
43 | 66 | end |
44 | 67 |
|
| 68 | + def self.spm_resolved_version(dep) |
| 69 | + dependencies = JSON.load(File.new('Package.resolved'))['object']['pins'] |
| 70 | + dependencies.find { |d| d['package'] == dep }['state']['version'] |
| 71 | + end |
| 72 | + |
45 | 73 | def self.last_git_tag_version |
46 | 74 | `git describe --tags --abbrev=0`.strip |
47 | 75 | end |
48 | 76 |
|
49 | 77 | def self.octokit_client |
50 | | - token = File.exist?('.apitoken') && File.read('.apitoken') |
| 78 | + token = ENV['DANGER_GITHUB_API_TOKEN'] |
| 79 | + token ||= File.exist?('.apitoken') && File.read('.apitoken') |
51 | 80 | token ||= File.exist?('../.apitoken') && File.read('../.apitoken') |
52 | 81 | Utils.print_error('No .apitoken file found') unless token |
53 | 82 | require 'octokit' |
|
0 commit comments