actions-updater 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/VERSION +1 -0
- data/bin/actions-updater +36 -0
- data/lib/action.rb +65 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 16a4e45e4a98b20859261172e2295fbe622d89d3795c2f96f9e6cc163d4327b9
|
4
|
+
data.tar.gz: 5228422533bf62977104b6f52c5d2c0555d20700fdf371cd3487d09ff5eb7199
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e761d5a3c1c404a77554630b36de4593373a2fceec20393cdc2b9ccf7fa3fec448198371f4c0c14444f6431dc7aa081b5dff58e0e176ba2bc203ec928c9ddec9
|
7
|
+
data.tar.gz: f8aedd508c5a0c44a6c4aa1642cdef3c2c1ffff59852647e96ea6155353660c3caba222fadf8ffdfb21d4b56dbc7a055ee5c247a86dbf0490093a6a94dbef0cf
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.10
|
data/bin/actions-updater
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'colorize'
|
6
|
+
require 'action'
|
7
|
+
|
8
|
+
OptionParser.new do |parser|
|
9
|
+
parser.version = File.read("#{__dir__}/../VERSION")
|
10
|
+
parser.banner += ' workflows ...'
|
11
|
+
parser.on('-n', '--newer', 'deal only with actions that have an update') do
|
12
|
+
@newer = true
|
13
|
+
end
|
14
|
+
parser.on('-w', '--write', 'write updates back to workflow files') do
|
15
|
+
@write = true
|
16
|
+
end
|
17
|
+
end.parse!
|
18
|
+
|
19
|
+
ARGV.each do |path|
|
20
|
+
puts "#{'==>'.blue} #{path}".bold
|
21
|
+
yaml = File.read(path)
|
22
|
+
actions = Action.array_from_yaml(yaml)
|
23
|
+
actions.each do |current_action|
|
24
|
+
new_action = current_action.clone
|
25
|
+
new_action.ref = current_action.latest_tag
|
26
|
+
|
27
|
+
next if current_action == new_action && @newer
|
28
|
+
|
29
|
+
puts "#{current_action.print_without_ref.cyan.bold} : #{current_action.ref.red.bold} ==> #{new_action.ref.green.bold}"
|
30
|
+
|
31
|
+
next unless @write
|
32
|
+
|
33
|
+
yaml.gsub!(/#{current_action}/, new_action.to_s)
|
34
|
+
File.open(path, 'w') { |f| f.puts yaml }
|
35
|
+
end
|
36
|
+
end
|
data/lib/action.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
class Action
|
6
|
+
attr_accessor :user, :repo, :dir, :ref
|
7
|
+
attr_reader :url
|
8
|
+
|
9
|
+
USES_REGEX = %r{^(?<user>[^/]+)[/](?<repo>[^/]+)[/]?(?<dir>.+)?[@](?<ref>.+)$}.freeze
|
10
|
+
TAGS_REGEX = %r{refs/tags/(.*)$}.freeze
|
11
|
+
DOMAIN = 'https://github.com'
|
12
|
+
TAG_REJECT_REASONS = %w[
|
13
|
+
alpha
|
14
|
+
beta
|
15
|
+
rc
|
16
|
+
^{}
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
def self.array_from_yaml(yaml)
|
20
|
+
hash = YAML.safe_load(yaml)
|
21
|
+
useses = hash['jobs'].values.map do |job|
|
22
|
+
job['steps'].map do |step|
|
23
|
+
step['uses']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
useses.flatten.compact.uniq.map do |uses|
|
27
|
+
new(uses)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(uses)
|
32
|
+
captures = uses.match(USES_REGEX).named_captures
|
33
|
+
@user = captures['user']
|
34
|
+
@repo = captures['repo']
|
35
|
+
@dir = captures['dir']
|
36
|
+
@ref = captures['ref']
|
37
|
+
@url = "#{DOMAIN}/#{@user}/#{@repo}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
print
|
42
|
+
end
|
43
|
+
|
44
|
+
def print
|
45
|
+
"#{@user}/#{@repo}#{@dir ? '/' : ''}#{@dir}#{@ref ? '@' : ''}#{@ref}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def print_without_ref
|
49
|
+
"#{@user}/#{@repo}#{@dir ? '/' : ''}#{@dir}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def ==(other)
|
53
|
+
to_s == other.to_s
|
54
|
+
end
|
55
|
+
|
56
|
+
def latest_tag
|
57
|
+
tags = `git ls-remote -t #{@url}`.scan(TAGS_REGEX).flatten
|
58
|
+
tags.reject! do |tag|
|
59
|
+
TAG_REJECT_REASONS.any? do |reason|
|
60
|
+
tag.include?(reason)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
tags.last || @ref
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: actions-updater
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dawid Dziurla
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
executables:
|
72
|
+
- actions-updater
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- VERSION
|
77
|
+
- bin/actions-updater
|
78
|
+
- lib/action.rb
|
79
|
+
homepage: https://github.com/dawidd6/actions-updater
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubygems_version: 3.0.6
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Updater of used Github Actions in workflow files
|
102
|
+
test_files: []
|